Mon, 06 Jul 2009 05:33:27 +0000
Remove periods and newlines from many error messages that end up being used
when calling purple_connection_error(). I think these look cleaner this
way. I'm hoping this won't harm many other places... I know
purple_proxy_connect() is used all over the place
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1 | /** |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2 | * @file proxy.c Proxy API |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
3 | * @ingroup core |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
20055
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
20055
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
20055
diff
changeset
|
6 | /* purple |
| 1 | 7 | * |
| 15884 | 8 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 1 | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19840
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 1 | 25 | * |
| 26 | */ | |
| 27 | ||
| 28 | /* this is a little piece of code to handle proxy connection */ | |
| 29 | /* it is intended to : 1st handle http proxy, using the CONNECT command | |
|
6856
5ed6b8356ebc
[gaim-migrate @ 7401]
Mark Doliner <markdoliner@pidgin.im>
parents:
6621
diff
changeset
|
30 | , 2nd provide an easy way to add socks support |
|
5ed6b8356ebc
[gaim-migrate @ 7401]
Mark Doliner <markdoliner@pidgin.im>
parents:
6621
diff
changeset
|
31 | , 3rd draw women to it like flies to honey */ |
| 1 | 32 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
33 | #include "internal.h" |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10626
diff
changeset
|
34 | #include "cipher.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
35 | #include "debug.h" |
|
14243
0bda01972ff2
[gaim-migrate @ 16833]
Mark Doliner <markdoliner@pidgin.im>
parents:
14226
diff
changeset
|
36 | #include "dnsquery.h" |
|
6621
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6320
diff
changeset
|
37 | #include "notify.h" |
| 12391 | 38 | #include "ntlm.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
39 | #include "prefs.h" |
| 1 | 40 | #include "proxy.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
41 | #include "util.h" |
| 3630 | 42 | |
| 15884 | 43 | struct _PurpleProxyConnectData { |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
44 | void *handle; |
| 15884 | 45 | PurpleProxyConnectFunction connect_cb; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
46 | gpointer data; |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
47 | gchar *host; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
48 | int port; |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
49 | int fd; |
|
27249
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
50 | int socket_type; |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
51 | guint inpa; |
| 15884 | 52 | PurpleProxyInfo *gpi; |
| 53 | PurpleDnsQueryData *query_data; | |
|
14159
0fcdaa463a32
[gaim-migrate @ 16726]
Mark Doliner <markdoliner@pidgin.im>
parents:
14158
diff
changeset
|
54 | |
|
0fcdaa463a32
[gaim-migrate @ 16726]
Mark Doliner <markdoliner@pidgin.im>
parents:
14158
diff
changeset
|
55 | /** |
|
0fcdaa463a32
[gaim-migrate @ 16726]
Mark Doliner <markdoliner@pidgin.im>
parents:
14158
diff
changeset
|
56 | * This contains alternating length/char* values. The char* |
|
0fcdaa463a32
[gaim-migrate @ 16726]
Mark Doliner <markdoliner@pidgin.im>
parents:
14158
diff
changeset
|
57 | * values need to be freed when removed from the linked list. |
|
0fcdaa463a32
[gaim-migrate @ 16726]
Mark Doliner <markdoliner@pidgin.im>
parents:
14158
diff
changeset
|
58 | */ |
| 9129 | 59 | GSList *hosts; |
|
14159
0fcdaa463a32
[gaim-migrate @ 16726]
Mark Doliner <markdoliner@pidgin.im>
parents:
14158
diff
changeset
|
60 | |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
61 | /* |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
62 | * All of the following variables are used when establishing a |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
63 | * connection through a proxy. |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
64 | */ |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
65 | guchar *write_buffer; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
66 | gsize write_buf_len; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
67 | gsize written_len; |
| 15884 | 68 | PurpleInputFunction read_cb; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
69 | guchar *read_buffer; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
70 | gsize read_buf_len; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
71 | gsize read_len; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
72 | }; |
|
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
73 | |
|
21091
07fe1a99c47b
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents:
20251
diff
changeset
|
74 | static const char * const socks5errors[] = { |
|
7982
db8c1b6137eb
[gaim-migrate @ 8659]
Gavan Fantom <gavan@users.sourceforge.net>
parents:
7834
diff
changeset
|
75 | "succeeded\n", |
|
db8c1b6137eb
[gaim-migrate @ 8659]
Gavan Fantom <gavan@users.sourceforge.net>
parents:
7834
diff
changeset
|
76 | "general SOCKS server failure\n", |
|
db8c1b6137eb
[gaim-migrate @ 8659]
Gavan Fantom <gavan@users.sourceforge.net>
parents:
7834
diff
changeset
|
77 | "connection not allowed by ruleset\n", |
|
db8c1b6137eb
[gaim-migrate @ 8659]
Gavan Fantom <gavan@users.sourceforge.net>
parents:
7834
diff
changeset
|
78 | "Network unreachable\n", |
|
db8c1b6137eb
[gaim-migrate @ 8659]
Gavan Fantom <gavan@users.sourceforge.net>
parents:
7834
diff
changeset
|
79 | "Host unreachable\n", |
|
db8c1b6137eb
[gaim-migrate @ 8659]
Gavan Fantom <gavan@users.sourceforge.net>
parents:
7834
diff
changeset
|
80 | "Connection refused\n", |
|
db8c1b6137eb
[gaim-migrate @ 8659]
Gavan Fantom <gavan@users.sourceforge.net>
parents:
7834
diff
changeset
|
81 | "TTL expired\n", |
|
db8c1b6137eb
[gaim-migrate @ 8659]
Gavan Fantom <gavan@users.sourceforge.net>
parents:
7834
diff
changeset
|
82 | "Command not supported\n", |
|
db8c1b6137eb
[gaim-migrate @ 8659]
Gavan Fantom <gavan@users.sourceforge.net>
parents:
7834
diff
changeset
|
83 | "Address type not supported\n" |
|
db8c1b6137eb
[gaim-migrate @ 8659]
Gavan Fantom <gavan@users.sourceforge.net>
parents:
7834
diff
changeset
|
84 | }; |
|
db8c1b6137eb
[gaim-migrate @ 8659]
Gavan Fantom <gavan@users.sourceforge.net>
parents:
7834
diff
changeset
|
85 | |
| 15884 | 86 | static PurpleProxyInfo *global_proxy_info = NULL; |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
87 | |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
88 | static GSList *handles = NULL; |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
89 | |
| 15884 | 90 | static void try_connect(PurpleProxyConnectData *connect_data); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
91 | |
|
16037
e00a903d17a2
I commonly see a crash in which socket_ready_cb(), shortly after a laptop wakes from sleep, is passed invalid (previously freed) connect_data. It looks like this:
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
92 | /* |
|
e00a903d17a2
I commonly see a crash in which socket_ready_cb(), shortly after a laptop wakes from sleep, is passed invalid (previously freed) connect_data. It looks like this:
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
93 | * TODO: Eventually (GObjectification) this bad boy will be removed, because it is |
|
e00a903d17a2
I commonly see a crash in which socket_ready_cb(), shortly after a laptop wakes from sleep, is passed invalid (previously freed) connect_data. It looks like this:
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
94 | * a gross fix for a crashy problem. |
|
e00a903d17a2
I commonly see a crash in which socket_ready_cb(), shortly after a laptop wakes from sleep, is passed invalid (previously freed) connect_data. It looks like this:
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
95 | */ |
|
e00a903d17a2
I commonly see a crash in which socket_ready_cb(), shortly after a laptop wakes from sleep, is passed invalid (previously freed) connect_data. It looks like this:
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
96 | #define PURPLE_PROXY_CONNECT_DATA_IS_VALID(connect_data) g_slist_find(handles, connect_data) |
|
e00a903d17a2
I commonly see a crash in which socket_ready_cb(), shortly after a laptop wakes from sleep, is passed invalid (previously freed) connect_data. It looks like this:
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
97 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
98 | /************************************************************************** |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
99 | * Proxy structure API |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
100 | **************************************************************************/ |
| 15884 | 101 | PurpleProxyInfo * |
| 102 | purple_proxy_info_new(void) | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
103 | { |
| 15884 | 104 | return g_new0(PurpleProxyInfo, 1); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
105 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
106 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
107 | void |
| 15884 | 108 | purple_proxy_info_destroy(PurpleProxyInfo *info) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
109 | { |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
110 | g_return_if_fail(info != NULL); |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
111 | |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13991
diff
changeset
|
112 | g_free(info->host); |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13991
diff
changeset
|
113 | g_free(info->username); |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13991
diff
changeset
|
114 | g_free(info->password); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
115 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
116 | g_free(info); |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
117 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
118 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
119 | void |
| 15884 | 120 | purple_proxy_info_set_type(PurpleProxyInfo *info, PurpleProxyType type) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
121 | { |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
122 | g_return_if_fail(info != NULL); |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
123 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
124 | info->type = type; |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
125 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
126 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
127 | void |
| 15884 | 128 | purple_proxy_info_set_host(PurpleProxyInfo *info, const char *host) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
129 | { |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
130 | g_return_if_fail(info != NULL); |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
131 | |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13991
diff
changeset
|
132 | g_free(info->host); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14030
diff
changeset
|
133 | info->host = g_strdup(host); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
134 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
135 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
136 | void |
| 15884 | 137 | purple_proxy_info_set_port(PurpleProxyInfo *info, int port) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
138 | { |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
139 | g_return_if_fail(info != NULL); |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
140 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
141 | info->port = port; |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
142 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
143 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
144 | void |
| 15884 | 145 | purple_proxy_info_set_username(PurpleProxyInfo *info, const char *username) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
146 | { |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
147 | g_return_if_fail(info != NULL); |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
148 | |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13991
diff
changeset
|
149 | g_free(info->username); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14030
diff
changeset
|
150 | info->username = g_strdup(username); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
151 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
152 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
153 | void |
| 15884 | 154 | purple_proxy_info_set_password(PurpleProxyInfo *info, const char *password) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
155 | { |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
156 | g_return_if_fail(info != NULL); |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
157 | |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13991
diff
changeset
|
158 | g_free(info->password); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14030
diff
changeset
|
159 | info->password = g_strdup(password); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
160 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
161 | |
| 15884 | 162 | PurpleProxyType |
| 163 | purple_proxy_info_get_type(const PurpleProxyInfo *info) | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
164 | { |
| 15884 | 165 | g_return_val_if_fail(info != NULL, PURPLE_PROXY_NONE); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
166 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
167 | return info->type; |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
168 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
169 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
170 | const char * |
| 15884 | 171 | purple_proxy_info_get_host(const PurpleProxyInfo *info) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
172 | { |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
173 | g_return_val_if_fail(info != NULL, NULL); |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
174 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
175 | return info->host; |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
176 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
177 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
178 | int |
| 15884 | 179 | purple_proxy_info_get_port(const PurpleProxyInfo *info) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
180 | { |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
181 | g_return_val_if_fail(info != NULL, 0); |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
182 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
183 | return info->port; |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
184 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
185 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
186 | const char * |
| 15884 | 187 | purple_proxy_info_get_username(const PurpleProxyInfo *info) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
188 | { |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
189 | g_return_val_if_fail(info != NULL, NULL); |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
190 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
191 | return info->username; |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
192 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
193 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
194 | const char * |
| 15884 | 195 | purple_proxy_info_get_password(const PurpleProxyInfo *info) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
196 | { |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
197 | g_return_val_if_fail(info != NULL, NULL); |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
198 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
199 | return info->password; |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
200 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
201 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
202 | /************************************************************************** |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
203 | * Global Proxy API |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
204 | **************************************************************************/ |
| 15884 | 205 | PurpleProxyInfo * |
| 206 | purple_global_proxy_get_info(void) | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
207 | { |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
208 | return global_proxy_info; |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
209 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
210 | |
|
25858
ec60fbe5a4ab
Patch from fqueze to add API for setting the global proxy settings. Fixes #7610.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
211 | void |
|
ec60fbe5a4ab
Patch from fqueze to add API for setting the global proxy settings. Fixes #7610.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
212 | purple_global_proxy_set_info(PurpleProxyInfo *info) |
|
ec60fbe5a4ab
Patch from fqueze to add API for setting the global proxy settings. Fixes #7610.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
213 | { |
|
ec60fbe5a4ab
Patch from fqueze to add API for setting the global proxy settings. Fixes #7610.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
214 | g_return_if_fail(info != NULL); |
|
ec60fbe5a4ab
Patch from fqueze to add API for setting the global proxy settings. Fixes #7610.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
215 | |
|
ec60fbe5a4ab
Patch from fqueze to add API for setting the global proxy settings. Fixes #7610.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
216 | purple_proxy_info_destroy(global_proxy_info); |
|
ec60fbe5a4ab
Patch from fqueze to add API for setting the global proxy settings. Fixes #7610.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
217 | |
|
ec60fbe5a4ab
Patch from fqueze to add API for setting the global proxy settings. Fixes #7610.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
218 | global_proxy_info = info; |
|
ec60fbe5a4ab
Patch from fqueze to add API for setting the global proxy settings. Fixes #7610.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
219 | } |
|
ec60fbe5a4ab
Patch from fqueze to add API for setting the global proxy settings. Fixes #7610.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
220 | |
| 15884 | 221 | static PurpleProxyInfo * |
| 222 | purple_gnome_proxy_get_info(void) | |
| 11878 | 223 | { |
| 15884 | 224 | static PurpleProxyInfo info = {0, NULL, 0, NULL, NULL}; |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
225 | gboolean use_same_proxy = FALSE; |
|
24316
88c65c05a21e
Some minor cleanup; removal of unnecessary frees and setting stuff to NULL
Daniel Atallah <datallah@pidgin.im>
parents:
24315
diff
changeset
|
226 | gchar *tmp, *err = NULL; |
|
12156
58a027264d6c
[gaim-migrate @ 14457]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11878
diff
changeset
|
227 | |
|
22554
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
228 | tmp = g_find_program_in_path("gconftool-2"); |
|
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
229 | if (tmp == NULL) |
|
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
230 | return purple_global_proxy_get_info(); |
|
12156
58a027264d6c
[gaim-migrate @ 14457]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11878
diff
changeset
|
231 | |
|
22554
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
232 | g_free(tmp); |
|
24316
88c65c05a21e
Some minor cleanup; removal of unnecessary frees and setting stuff to NULL
Daniel Atallah <datallah@pidgin.im>
parents:
24315
diff
changeset
|
233 | tmp = NULL; |
|
12156
58a027264d6c
[gaim-migrate @ 14457]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11878
diff
changeset
|
234 | |
|
22555
04cfb0cf0974
Improve our error handling of Gnome proxy settings.
Mark Doliner <markdoliner@pidgin.im>
parents:
22554
diff
changeset
|
235 | /* Check whether to use a proxy. */ |
|
04cfb0cf0974
Improve our error handling of Gnome proxy settings.
Mark Doliner <markdoliner@pidgin.im>
parents:
22554
diff
changeset
|
236 | if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/mode", |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
237 | &tmp, &err, NULL, NULL)) |
|
22554
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
238 | return purple_global_proxy_get_info(); |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
239 | g_free(err); |
|
24316
88c65c05a21e
Some minor cleanup; removal of unnecessary frees and setting stuff to NULL
Daniel Atallah <datallah@pidgin.im>
parents:
24315
diff
changeset
|
240 | err = NULL; |
|
22558
11833f17f394
disapproval of revision 'd5101ee4e1e1f1243a7800561a51ab22bff97705'
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
241 | |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
242 | if (purple_strequal(tmp, "none\n")) { |
|
22554
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
243 | info.type = PURPLE_PROXY_NONE; |
|
12156
58a027264d6c
[gaim-migrate @ 14457]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11878
diff
changeset
|
244 | g_free(tmp); |
| 11878 | 245 | return &info; |
| 246 | } | |
|
22555
04cfb0cf0974
Improve our error handling of Gnome proxy settings.
Mark Doliner <markdoliner@pidgin.im>
parents:
22554
diff
changeset
|
247 | |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
248 | if (purple_strequal(tmp, "manual\n")) { |
|
22555
04cfb0cf0974
Improve our error handling of Gnome proxy settings.
Mark Doliner <markdoliner@pidgin.im>
parents:
22554
diff
changeset
|
249 | /* Unknown setting. Fallback to using our global proxy settings. */ |
|
22554
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
250 | g_free(tmp); |
|
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
251 | return purple_global_proxy_get_info(); |
|
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
252 | } |
|
12156
58a027264d6c
[gaim-migrate @ 14457]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11878
diff
changeset
|
253 | |
|
22554
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
254 | g_free(tmp); |
|
24316
88c65c05a21e
Some minor cleanup; removal of unnecessary frees and setting stuff to NULL
Daniel Atallah <datallah@pidgin.im>
parents:
24315
diff
changeset
|
255 | tmp = NULL; |
|
22555
04cfb0cf0974
Improve our error handling of Gnome proxy settings.
Mark Doliner <markdoliner@pidgin.im>
parents:
22554
diff
changeset
|
256 | |
|
22560
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
257 | /* Free the old fields */ |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
258 | if (info.host) { |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
259 | g_free(info.host); |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
260 | info.host = NULL; |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
261 | } |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
262 | if (info.username) { |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
263 | g_free(info.username); |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
264 | info.username = NULL; |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
265 | } |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
266 | if (info.password) { |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
267 | g_free(info.password); |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
268 | info.password = NULL; |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
269 | } |
|
510c8edb3854
Bring back the lines that free info.whatever on subsequent calls to
Mark Doliner <markdoliner@pidgin.im>
parents:
22559
diff
changeset
|
270 | |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
271 | if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/use_same_proxy", |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
272 | &tmp, &err, NULL, NULL)) |
|
22554
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
273 | return purple_global_proxy_get_info(); |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
274 | g_free(err); |
|
24316
88c65c05a21e
Some minor cleanup; removal of unnecessary frees and setting stuff to NULL
Daniel Atallah <datallah@pidgin.im>
parents:
24315
diff
changeset
|
275 | err = NULL; |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
276 | |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
277 | if (purple_strequal(tmp, "true\n")) |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
278 | use_same_proxy = TRUE; |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
279 | g_free(tmp); |
|
24316
88c65c05a21e
Some minor cleanup; removal of unnecessary frees and setting stuff to NULL
Daniel Atallah <datallah@pidgin.im>
parents:
24315
diff
changeset
|
280 | tmp = NULL; |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
281 | |
|
24315
98e4a5f1d662
Fix a double free. Fixes #7047
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
24298
diff
changeset
|
282 | if (!use_same_proxy) { |
|
98e4a5f1d662
Fix a double free. Fixes #7047
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
24298
diff
changeset
|
283 | if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/socks_host", |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
284 | &info.host, &err, NULL, NULL)) |
|
24315
98e4a5f1d662
Fix a double free. Fixes #7047
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
24298
diff
changeset
|
285 | return purple_global_proxy_get_info(); |
|
98e4a5f1d662
Fix a double free. Fixes #7047
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
24298
diff
changeset
|
286 | g_free(err); |
|
24316
88c65c05a21e
Some minor cleanup; removal of unnecessary frees and setting stuff to NULL
Daniel Atallah <datallah@pidgin.im>
parents:
24315
diff
changeset
|
287 | err = NULL; |
|
24315
98e4a5f1d662
Fix a double free. Fixes #7047
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
24298
diff
changeset
|
288 | } |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
289 | |
|
24315
98e4a5f1d662
Fix a double free. Fixes #7047
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
24298
diff
changeset
|
290 | if(info.host != NULL) |
|
98e4a5f1d662
Fix a double free. Fixes #7047
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
24298
diff
changeset
|
291 | g_strchomp(info.host); |
|
98e4a5f1d662
Fix a double free. Fixes #7047
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
24298
diff
changeset
|
292 | |
|
98e4a5f1d662
Fix a double free. Fixes #7047
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
24298
diff
changeset
|
293 | if (!use_same_proxy && (info.host != NULL) && (*info.host != '\0')) { |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
294 | info.type = PURPLE_PROXY_SOCKS5; |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
295 | if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/socks_port", |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
296 | &tmp, &err, NULL, NULL)) |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
297 | { |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
298 | g_free(info.host); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
299 | info.host = NULL; |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
300 | return purple_global_proxy_get_info(); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
301 | } |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
302 | g_free(err); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
303 | info.port = atoi(tmp); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
304 | g_free(tmp); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
305 | } else { |
|
22555
04cfb0cf0974
Improve our error handling of Gnome proxy settings.
Mark Doliner <markdoliner@pidgin.im>
parents:
22554
diff
changeset
|
306 | g_free(info.host); |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
307 | if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/host", |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
308 | &info.host, &err, NULL, NULL)) |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
309 | return purple_global_proxy_get_info(); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
310 | g_free(err); |
|
24316
88c65c05a21e
Some minor cleanup; removal of unnecessary frees and setting stuff to NULL
Daniel Atallah <datallah@pidgin.im>
parents:
24315
diff
changeset
|
311 | err = NULL; |
|
88c65c05a21e
Some minor cleanup; removal of unnecessary frees and setting stuff to NULL
Daniel Atallah <datallah@pidgin.im>
parents:
24315
diff
changeset
|
312 | |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
313 | /* If we get this far then we know we're using an HTTP proxy */ |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
314 | info.type = PURPLE_PROXY_HTTP; |
| 11878 | 315 | |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
316 | g_strchomp(info.host); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
317 | if (*info.host == '\0') |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
318 | { |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
319 | purple_debug_info("proxy", "Gnome proxy settings are set to " |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
320 | "'manual' but no suitable proxy server is specified. Using " |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
321 | "Pidgin's proxy settings instead.\n"); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
322 | g_free(info.host); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
323 | info.host = NULL; |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
324 | return purple_global_proxy_get_info(); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
325 | } |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
326 | |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
327 | if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_user", |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
328 | &info.username, &err, NULL, NULL)) |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
329 | { |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
330 | g_free(info.host); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
331 | info.host = NULL; |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
332 | return purple_global_proxy_get_info(); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
333 | } |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
334 | g_free(err); |
|
24316
88c65c05a21e
Some minor cleanup; removal of unnecessary frees and setting stuff to NULL
Daniel Atallah <datallah@pidgin.im>
parents:
24315
diff
changeset
|
335 | err = NULL; |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
336 | g_strchomp(info.username); |
| 11878 | 337 | |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
338 | if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_password", |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
339 | &info.password, &err, NULL, NULL)) |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
340 | { |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
341 | g_free(info.host); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
342 | info.host = NULL; |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
343 | g_free(info.username); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
344 | info.username = NULL; |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
345 | return purple_global_proxy_get_info(); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
346 | } |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
347 | g_free(err); |
|
24316
88c65c05a21e
Some minor cleanup; removal of unnecessary frees and setting stuff to NULL
Daniel Atallah <datallah@pidgin.im>
parents:
24315
diff
changeset
|
348 | err = NULL; |
|
24156
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
349 | g_strchomp(info.password); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
350 | |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
351 | if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/port", |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
352 | &tmp, &err, NULL, NULL)) |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
353 | { |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
354 | g_free(info.host); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
355 | info.host = NULL; |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
356 | g_free(info.username); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
357 | info.username = NULL; |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
358 | g_free(info.password); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
359 | info.password = NULL; |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
360 | return purple_global_proxy_get_info(); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
361 | } |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
362 | g_free(err); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
363 | info.port = atoi(tmp); |
|
6c7631ae7571
Use SOCKS proxy if specified when running in GNOME
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23532
diff
changeset
|
364 | g_free(tmp); |
|
22555
04cfb0cf0974
Improve our error handling of Gnome proxy settings.
Mark Doliner <markdoliner@pidgin.im>
parents:
22554
diff
changeset
|
365 | } |
| 11878 | 366 | |
|
22554
dff2ca00b045
Short circuit and return out of the function early if gconftool-2
Mark Doliner <markdoliner@pidgin.im>
parents:
22553
diff
changeset
|
367 | return &info; |
| 11878 | 368 | } |
|
24171
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
369 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
370 | #ifdef _WIN32 |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
371 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
372 | typedef BOOL (CALLBACK* LPFNWINHTTPGETIEPROXYCONFIG)(/*IN OUT*/ WINHTTP_CURRENT_USER_IE_PROXY_CONFIG* pProxyConfig); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
373 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
374 | /* This modifies "host" in-place evilly */ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
375 | static void |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
376 | _proxy_fill_hostinfo(PurpleProxyInfo *info, char *host, int default_port) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
377 | { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
378 | int port = default_port; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
379 | char *d; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
380 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
381 | d = g_strrstr(host, ":"); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
382 | if (d) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
383 | *d = '\0'; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
384 | d++; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
385 | if (*d) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
386 | sscanf(d, "%d", &port); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
387 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
388 | purple_proxy_info_set_host(info, host); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
389 | purple_proxy_info_set_port(info, port); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
390 | } |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
391 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
392 | static PurpleProxyInfo * |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
393 | purple_win32_proxy_get_info(void) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
394 | { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
395 | static LPFNWINHTTPGETIEPROXYCONFIG MyWinHttpGetIEProxyConfig = NULL; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
396 | static gboolean loaded = FALSE; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
397 | static PurpleProxyInfo info = {0, NULL, 0, NULL, NULL}; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
398 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
399 | WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ie_proxy_config; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
400 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
401 | if (!loaded) { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
402 | loaded = TRUE; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
403 | MyWinHttpGetIEProxyConfig = (LPFNWINHTTPGETIEPROXYCONFIG) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
404 | wpurple_find_and_loadproc("winhttp.dll", "WinHttpGetIEProxyConfigForCurrentUser"); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
405 | if (!MyWinHttpGetIEProxyConfig) |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27249
diff
changeset
|
406 | purple_debug_warning("proxy", "Unable to read Windows Proxy Settings.\n"); |
|
24171
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
407 | } |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
408 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
409 | if (!MyWinHttpGetIEProxyConfig) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
410 | return NULL; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
411 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
412 | ZeroMemory(&ie_proxy_config, sizeof(ie_proxy_config)); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
413 | if (!MyWinHttpGetIEProxyConfig(&ie_proxy_config)) { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
414 | purple_debug_error("proxy", "Error reading Windows Proxy Settings(%lu).\n", GetLastError()); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
415 | return NULL; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
416 | } |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
417 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
418 | /* We can't do much if it is autodetect*/ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
419 | if (ie_proxy_config.fAutoDetect) { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
420 | purple_debug_error("proxy", "Windows Proxy Settings set to autodetect (not supported).\n"); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
421 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
422 | /* TODO: For 3.0.0 we'll revisit this (maybe)*/ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
423 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
424 | return NULL; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
425 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
426 | } else if (ie_proxy_config.lpszProxy) { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
427 | gchar *proxy_list = g_utf16_to_utf8(ie_proxy_config.lpszProxy, -1, |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
428 | NULL, NULL, NULL); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
429 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
430 | /* We can't do anything about the bypass list, as we don't have the url */ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
431 | /* TODO: For 3.0.0 we'll revisit this*/ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
432 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
433 | /* There are proxy settings for several protocols */ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
434 | if (proxy_list && *proxy_list) { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
435 | char *specific = NULL, *tmp; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
436 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
437 | /* If there is only a global proxy, which means "HTTP" */ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
438 | if (!strchr(proxy_list, ';') || (specific = g_strstr_len(proxy_list, -1, "http=")) != NULL) { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
439 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
440 | if (specific) { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
441 | specific += strlen("http="); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
442 | tmp = strchr(specific, ';'); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
443 | if (tmp) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
444 | *tmp = '\0'; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
445 | /* specific now points the proxy server (and port) */ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
446 | } else |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
447 | specific = proxy_list; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
448 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
449 | purple_proxy_info_set_type(&info, PURPLE_PROXY_HTTP); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
450 | _proxy_fill_hostinfo(&info, specific, 80); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
451 | /* TODO: is there a way to set the username/password? */ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
452 | purple_proxy_info_set_username(&info, NULL); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
453 | purple_proxy_info_set_password(&info, NULL); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
454 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
455 | purple_debug_info("proxy", "Windows Proxy Settings: HTTP proxy: '%s:%d'.\n", |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
456 | purple_proxy_info_get_host(&info), |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
457 | purple_proxy_info_get_port(&info)); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
458 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
459 | } else if ((specific = g_strstr_len(proxy_list, -1, "socks=")) != NULL) { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
460 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
461 | specific += strlen("socks="); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
462 | tmp = strchr(specific, ';'); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
463 | if (tmp) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
464 | *tmp = '\0'; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
465 | /* specific now points the proxy server (and port) */ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
466 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
467 | purple_proxy_info_set_type(&info, PURPLE_PROXY_SOCKS5); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
468 | _proxy_fill_hostinfo(&info, specific, 1080); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
469 | /* TODO: is there a way to set the username/password? */ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
470 | purple_proxy_info_set_username(&info, NULL); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
471 | purple_proxy_info_set_password(&info, NULL); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
472 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
473 | purple_debug_info("proxy", "Windows Proxy Settings: SOCKS5 proxy: '%s:%d'.\n", |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
474 | purple_proxy_info_get_host(&info), |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
475 | purple_proxy_info_get_port(&info)); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
476 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
477 | } else { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
478 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
479 | purple_debug_info("proxy", "Windows Proxy Settings: No supported proxy specified.\n"); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
480 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
481 | purple_proxy_info_set_type(&info, PURPLE_PROXY_NONE); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
482 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
483 | } |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
484 | } |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
485 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
486 | /* TODO: Fix API to be able look at proxy bypass settings */ |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
487 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
488 | g_free(proxy_list); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
489 | } else { |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
490 | purple_debug_info("proxy", "No Windows proxy set.\n"); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
491 | purple_proxy_info_set_type(&info, PURPLE_PROXY_NONE); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
492 | } |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
493 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
494 | if (ie_proxy_config.lpszAutoConfigUrl) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
495 | GlobalFree(ie_proxy_config.lpszAutoConfigUrl); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
496 | if (ie_proxy_config.lpszProxy) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
497 | GlobalFree(ie_proxy_config.lpszProxy); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
498 | if (ie_proxy_config.lpszProxyBypass) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
499 | GlobalFree(ie_proxy_config.lpszProxyBypass); |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
500 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
501 | return &info; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
502 | } |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
503 | #endif |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
504 | |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
505 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
506 | /************************************************************************** |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
507 | * Proxy API |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
508 | **************************************************************************/ |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
509 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
510 | /** |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
511 | * Whoever calls this needs to have called |
| 15884 | 512 | * purple_proxy_connect_data_disconnect() beforehand. |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
513 | */ |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
514 | static void |
| 15884 | 515 | purple_proxy_connect_data_destroy(PurpleProxyConnectData *connect_data) |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
516 | { |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
517 | handles = g_slist_remove(handles, connect_data); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
518 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
519 | if (connect_data->query_data != NULL) |
| 15884 | 520 | purple_dnsquery_destroy(connect_data->query_data); |
|
14300
68a0aa63f3b8
[gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
521 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
522 | while (connect_data->hosts != NULL) |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
523 | { |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
524 | /* Discard the length... */ |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
525 | connect_data->hosts = g_slist_remove(connect_data->hosts, connect_data->hosts->data); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
526 | /* Free the address... */ |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
527 | g_free(connect_data->hosts->data); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
528 | connect_data->hosts = g_slist_remove(connect_data->hosts, connect_data->hosts->data); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
529 | } |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
530 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
531 | g_free(connect_data->host); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
532 | g_free(connect_data); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
533 | } |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
534 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
535 | /** |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
536 | * Free all information dealing with a connection attempt and |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
537 | * reset the connect_data to prepare for it to try to connect |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
538 | * to another IP address. |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
539 | * |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
540 | * If an error message is passed in, then we know the connection |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
541 | * attempt failed. If the connection attempt failed and |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
542 | * connect_data->hosts is not empty then we try the next IP address. |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
543 | * If the connection attempt failed and we have no more hosts |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
544 | * try try then we call the callback with the given error message, |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
545 | * then destroy the connect_data. |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
546 | * |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
547 | * @param error_message An error message explaining why the connection |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
548 | * failed. This will be passed to the callback function |
| 15884 | 549 | * specified in the call to purple_proxy_connect(). If the |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
550 | * connection was successful then pass in null. |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
551 | */ |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
552 | static void |
| 15884 | 553 | purple_proxy_connect_data_disconnect(PurpleProxyConnectData *connect_data, const gchar *error_message) |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
554 | { |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
555 | if (connect_data->inpa > 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
556 | { |
| 15884 | 557 | purple_input_remove(connect_data->inpa); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
558 | connect_data->inpa = 0; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
559 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
560 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
561 | if (connect_data->fd >= 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
562 | { |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
563 | close(connect_data->fd); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
564 | connect_data->fd = -1; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
565 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
566 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
567 | g_free(connect_data->write_buffer); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
568 | connect_data->write_buffer = NULL; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
569 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
570 | g_free(connect_data->read_buffer); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
571 | connect_data->read_buffer = NULL; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
572 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
573 | if (error_message != NULL) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
574 | { |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27249
diff
changeset
|
575 | purple_debug_error("proxy", "Connection attempt failed: %s\n", |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
576 | error_message); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
577 | if (connect_data->hosts != NULL) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
578 | try_connect(connect_data); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
579 | else |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
580 | { |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
581 | /* Everything failed! Tell the originator of the request. */ |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
582 | connect_data->connect_cb(connect_data->data, -1, error_message); |
| 15884 | 583 | purple_proxy_connect_data_destroy(connect_data); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
584 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
585 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
586 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
587 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
588 | /** |
| 15884 | 589 | * This calls purple_proxy_connect_data_disconnect(), but it lets you |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
590 | * specify the error_message using a printf()-like syntax. |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
591 | */ |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
592 | static void |
| 15884 | 593 | purple_proxy_connect_data_disconnect_formatted(PurpleProxyConnectData *connect_data, const char *format, ...) |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
594 | { |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
595 | va_list args; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
596 | gchar *tmp; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
597 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
598 | va_start(args, format); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
599 | tmp = g_strdup_vprintf(format, args); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
600 | va_end(args); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
601 | |
| 15884 | 602 | purple_proxy_connect_data_disconnect(connect_data, tmp); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
603 | g_free(tmp); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
604 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
605 | |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
606 | static void |
| 15884 | 607 | purple_proxy_connect_data_connected(PurpleProxyConnectData *connect_data) |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
608 | { |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
609 | connect_data->connect_cb(connect_data->data, connect_data->fd, NULL); |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
610 | |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
611 | /* |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
612 | * We've passed the file descriptor to the protocol, so it's no longer |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
613 | * our responsibility, and we should be careful not to free it when |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
614 | * we destroy the connect_data. |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
615 | */ |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
616 | connect_data->fd = -1; |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
617 | |
| 15884 | 618 | purple_proxy_connect_data_disconnect(connect_data, NULL); |
| 619 | purple_proxy_connect_data_destroy(connect_data); | |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
620 | } |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
621 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
622 | static void |
| 15884 | 623 | socket_ready_cb(gpointer data, gint source, PurpleInputCondition cond) |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
624 | { |
| 15884 | 625 | PurpleProxyConnectData *connect_data = data; |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
626 | int error = 0; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
627 | int ret; |
|
3717
2fc0789e04e8
[gaim-migrate @ 3850]
Herman Bloggs <herman@bluedigits.com>
parents:
3630
diff
changeset
|
628 | |
|
16037
e00a903d17a2
I commonly see a crash in which socket_ready_cb(), shortly after a laptop wakes from sleep, is passed invalid (previously freed) connect_data. It looks like this:
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
629 | /* If the socket-connected message had already been triggered when connect_data |
|
e00a903d17a2
I commonly see a crash in which socket_ready_cb(), shortly after a laptop wakes from sleep, is passed invalid (previously freed) connect_data. It looks like this:
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
630 | * was destroyed via purple_proxy_connect_cancel(), we may get here with a freed connect_data. |
|
e00a903d17a2
I commonly see a crash in which socket_ready_cb(), shortly after a laptop wakes from sleep, is passed invalid (previously freed) connect_data. It looks like this:
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
631 | */ |
|
e00a903d17a2
I commonly see a crash in which socket_ready_cb(), shortly after a laptop wakes from sleep, is passed invalid (previously freed) connect_data. It looks like this:
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
632 | if (!PURPLE_PROXY_CONNECT_DATA_IS_VALID(connect_data)) |
|
e00a903d17a2
I commonly see a crash in which socket_ready_cb(), shortly after a laptop wakes from sleep, is passed invalid (previously freed) connect_data. It looks like this:
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
633 | return; |
|
20053
68ce40196f8a
grab revision 6be36979d022284283217c2a32f2b812740cbbf3
Luke Schierer <lschiere@pidgin.im>
parents:
19985
diff
changeset
|
634 | |
|
24411
fdf9068e4492
This string appears before the connection attempt, so it shouldn't be
Kevin Stange <kstange@pidgin.im>
parents:
24316
diff
changeset
|
635 | purple_debug_info("proxy", "Connecting to %s:%d.\n", |
|
15746
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15558
diff
changeset
|
636 | connect_data->host, connect_data->port); |
|
3717
2fc0789e04e8
[gaim-migrate @ 3850]
Herman Bloggs <herman@bluedigits.com>
parents:
3630
diff
changeset
|
637 | |
| 8273 | 638 | /* |
| 15884 | 639 | * purple_input_get_error after a non-blocking connect returns -1 if something is |
| 8273 | 640 | * really messed up (bad descriptor, usually). Otherwise, it returns 0 and |
| 641 | * error holds what connect would have returned if it blocked until now. | |
| 642 | * Thus, error == 0 is success, error == EINPROGRESS means "try again", | |
| 643 | * and anything else is a real error. | |
| 644 | * | |
| 645 | * (error == EINPROGRESS can happen after a select because the kernel can | |
| 646 | * be overly optimistic sometimes. select is just a hint that you might be | |
| 647 | * able to do something.) | |
| 648 | */ | |
| 15884 | 649 | ret = purple_input_get_error(connect_data->fd, &error); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
650 | |
|
15746
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15558
diff
changeset
|
651 | if (ret == 0 && error == EINPROGRESS) { |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
652 | /* No worries - we'll be called again later */ |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
653 | /* TODO: Does this ever happen? */ |
|
19832
84b69b21672b
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17519
diff
changeset
|
654 | purple_debug_info("proxy", "(ret == 0 && error == EINPROGRESS)\n"); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
655 | return; |
|
15746
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15558
diff
changeset
|
656 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
657 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
658 | if (ret != 0 || error != 0) { |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
659 | if (ret != 0) |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
660 | error = errno; |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27249
diff
changeset
|
661 | purple_debug_error("proxy", "Error connecting to %s:%d (%s).\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21091
diff
changeset
|
662 | connect_data->host, connect_data->port, g_strerror(error)); |
|
15746
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15558
diff
changeset
|
663 | |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21091
diff
changeset
|
664 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(error)); |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
665 | return; |
|
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
666 | } |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
667 | |
| 15884 | 668 | purple_proxy_connect_data_connected(connect_data); |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
669 | } |
|
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
670 | |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
671 | static gboolean |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
672 | clean_connect(gpointer data) |
|
1868
31b44ef2b061
[gaim-migrate @ 1878]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1844
diff
changeset
|
673 | { |
| 15884 | 674 | purple_proxy_connect_data_connected(data); |
|
1868
31b44ef2b061
[gaim-migrate @ 1878]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1844
diff
changeset
|
675 | |
|
31b44ef2b061
[gaim-migrate @ 1878]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1844
diff
changeset
|
676 | return FALSE; |
|
31b44ef2b061
[gaim-migrate @ 1878]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1844
diff
changeset
|
677 | } |
|
31b44ef2b061
[gaim-migrate @ 1878]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1844
diff
changeset
|
678 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
679 | static void |
|
27249
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
680 | proxy_connect_udp_none(PurpleProxyConnectData *connect_data, struct sockaddr *addr, socklen_t addrlen) |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
681 | { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
682 | int flags; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
683 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
684 | purple_debug_info("proxy", "UDP Connecting to %s:%d with no proxy\n", |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
685 | connect_data->host, connect_data->port); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
686 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
687 | connect_data->fd = socket(addr->sa_family, SOCK_DGRAM, 0); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
688 | if (connect_data->fd < 0) |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
689 | { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
690 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
691 | _("Unable to create socket: %s"), g_strerror(errno)); |
|
27249
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
692 | return; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
693 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
694 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
695 | flags = fcntl(connect_data->fd, F_GETFL); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
696 | fcntl(connect_data->fd, F_SETFL, flags | O_NONBLOCK); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
697 | #ifndef _WIN32 |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
698 | fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
699 | #endif |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
700 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
701 | if (connect(connect_data->fd, addr, addrlen) != 0) |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
702 | { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
703 | if ((errno == EINPROGRESS) || (errno == EINTR)) |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
704 | { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
705 | purple_debug_info("proxy", "UDP Connection in progress\n"); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
706 | connect_data->inpa = purple_input_add(connect_data->fd, |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
707 | PURPLE_INPUT_WRITE, socket_ready_cb, connect_data); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
708 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
709 | else |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
710 | { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
711 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(errno)); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
712 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
713 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
714 | else |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
715 | { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
716 | /* |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
717 | * The connection happened IMMEDIATELY... strange, but whatever. |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
718 | */ |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
719 | int error = ETIMEDOUT; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
720 | int ret; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
721 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
722 | purple_debug_info("proxy", "UDP Connected immediately.\n"); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
723 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
724 | ret = purple_input_get_error(connect_data->fd, &error); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
725 | if ((ret != 0) || (error != 0)) |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
726 | { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
727 | if (ret != 0) |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
728 | error = errno; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
729 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(error)); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
730 | return; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
731 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
732 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
733 | /* |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
734 | * We want to call the "connected" callback eventually, but we |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
735 | * don't want to call it before we return, just in case. |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
736 | */ |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
737 | purple_timeout_add(10, clean_connect, connect_data); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
738 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
739 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
740 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
741 | static void |
| 15884 | 742 | proxy_connect_none(PurpleProxyConnectData *connect_data, struct sockaddr *addr, socklen_t addrlen) |
| 1 | 743 | { |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
744 | int flags; |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
745 | |
| 15884 | 746 | purple_debug_info("proxy", "Connecting to %s:%d with no proxy\n", |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
747 | connect_data->host, connect_data->port); |
|
3717
2fc0789e04e8
[gaim-migrate @ 3850]
Herman Bloggs <herman@bluedigits.com>
parents:
3630
diff
changeset
|
748 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
749 | connect_data->fd = socket(addr->sa_family, SOCK_STREAM, 0); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
750 | if (connect_data->fd < 0) |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
751 | { |
| 15884 | 752 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
753 | _("Unable to create socket: %s"), g_strerror(errno)); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
754 | return; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
755 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
756 | |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
757 | flags = fcntl(connect_data->fd, F_GETFL); |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
758 | fcntl(connect_data->fd, F_SETFL, flags | O_NONBLOCK); |
|
10172
8400788b226c
[gaim-migrate @ 11275]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10170
diff
changeset
|
759 | #ifndef _WIN32 |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
760 | fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC); |
|
10172
8400788b226c
[gaim-migrate @ 11275]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10170
diff
changeset
|
761 | #endif |
|
3717
2fc0789e04e8
[gaim-migrate @ 3850]
Herman Bloggs <herman@bluedigits.com>
parents:
3630
diff
changeset
|
762 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
763 | if (connect(connect_data->fd, addr, addrlen) != 0) |
|
14161
e959d0e476be
[gaim-migrate @ 16728]
Mark Doliner <markdoliner@pidgin.im>
parents:
14159
diff
changeset
|
764 | { |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
765 | if ((errno == EINPROGRESS) || (errno == EINTR)) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
766 | { |
| 15884 | 767 | purple_debug_info("proxy", "Connection in progress\n"); |
| 768 | connect_data->inpa = purple_input_add(connect_data->fd, | |
| 769 | PURPLE_INPUT_WRITE, socket_ready_cb, connect_data); | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
770 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
771 | else |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
772 | { |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21091
diff
changeset
|
773 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(errno)); |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
774 | } |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
775 | } |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
776 | else |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
777 | { |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
778 | /* |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
779 | * The connection happened IMMEDIATELY... strange, but whatever. |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
780 | */ |
|
2048
4ac8b9622c9e
[gaim-migrate @ 2058]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1881
diff
changeset
|
781 | int error = ETIMEDOUT; |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
782 | int ret; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
783 | |
| 15884 | 784 | purple_debug_info("proxy", "Connected immediately.\n"); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
785 | |
| 15884 | 786 | ret = purple_input_get_error(connect_data->fd, &error); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
787 | if ((ret != 0) || (error != 0)) |
|
14161
e959d0e476be
[gaim-migrate @ 16728]
Mark Doliner <markdoliner@pidgin.im>
parents:
14159
diff
changeset
|
788 | { |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
789 | if (ret != 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
790 | error = errno; |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21091
diff
changeset
|
791 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(error)); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
792 | return; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
793 | } |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
794 | |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
795 | /* |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
796 | * We want to call the "connected" callback eventually, but we |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
797 | * don't want to call it before we return, just in case. |
|
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
798 | */ |
| 15884 | 799 | purple_timeout_add(10, clean_connect, connect_data); |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
800 | } |
|
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
801 | } |
|
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
802 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
803 | /** |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
804 | * This is a utility function used by the HTTP, SOCKS4 and SOCKS5 |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
805 | * connect functions. It writes data from a buffer to a socket. |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
806 | * When all the data is written it sets up a watcher to read a |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
807 | * response and call a specified function. |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
808 | */ |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
809 | static void |
| 15884 | 810 | proxy_do_write(gpointer data, gint source, PurpleInputCondition cond) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
811 | { |
| 15884 | 812 | PurpleProxyConnectData *connect_data; |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
813 | const guchar *request; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
814 | gsize request_len; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
815 | int ret; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
816 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
817 | connect_data = data; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
818 | request = connect_data->write_buffer + connect_data->written_len; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
819 | request_len = connect_data->write_buf_len - connect_data->written_len; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
820 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
821 | ret = write(connect_data->fd, request, request_len); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
822 | if (ret <= 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
823 | { |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
824 | if (errno == EAGAIN) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
825 | /* No worries */ |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
826 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
827 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
828 | /* Error! */ |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21091
diff
changeset
|
829 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(errno)); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
830 | return; |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
831 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
832 | if (ret < request_len) { |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
833 | connect_data->written_len += ret; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
834 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
835 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
836 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
837 | /* We're done writing data! Wait for a response. */ |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
838 | g_free(connect_data->write_buffer); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
839 | connect_data->write_buffer = NULL; |
| 15884 | 840 | purple_input_remove(connect_data->inpa); |
| 841 | connect_data->inpa = purple_input_add(connect_data->fd, | |
| 842 | PURPLE_INPUT_READ, connect_data->read_cb, connect_data); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
843 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
844 | |
| 3376 | 845 | #define HTTP_GOODSTRING "HTTP/1.0 200" |
| 846 | #define HTTP_GOODSTRING2 "HTTP/1.1 200" | |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
847 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
848 | /** |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
849 | * We're using an HTTP proxy for a non-port 80 tunnel. Read the |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
850 | * response to the CONNECT request. |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
851 | */ |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
852 | static void |
| 15884 | 853 | http_canread(gpointer data, gint source, PurpleInputCondition cond) |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
854 | { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
855 | int len, headers_len, status = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
856 | gboolean error; |
| 15884 | 857 | PurpleProxyConnectData *connect_data = data; |
|
17519
500d04f3bf87
Eliminate some type punning warnings in proxy.c. This was inspired by a
Richard Laager <rlaager@pidgin.im>
parents:
17446
diff
changeset
|
858 | char *p; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
859 | gsize max_read; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
860 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
861 | if (connect_data->read_buffer == NULL) { |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
862 | connect_data->read_buf_len = 8192; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
863 | connect_data->read_buffer = g_malloc(connect_data->read_buf_len); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
864 | connect_data->read_len = 0; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
865 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
866 | |
|
17519
500d04f3bf87
Eliminate some type punning warnings in proxy.c. This was inspired by a
Richard Laager <rlaager@pidgin.im>
parents:
17446
diff
changeset
|
867 | p = (char *)connect_data->read_buffer + connect_data->read_len; |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
868 | max_read = connect_data->read_buf_len - connect_data->read_len - 1; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
869 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
870 | len = read(connect_data->fd, p, max_read); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
871 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
872 | if (len == 0) { |
| 15884 | 873 | purple_proxy_connect_data_disconnect(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
874 | _("Server closed the connection")); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
875 | return; |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
876 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
877 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
878 | if (len < 0) { |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
879 | if (errno == EAGAIN) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
880 | /* No worries */ |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
881 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
882 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
883 | /* Error! */ |
| 15884 | 884 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
885 | _("Lost connection with server: %s"), g_strerror(errno)); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
886 | return; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
887 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
888 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
889 | connect_data->read_len += len; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
890 | p[len] = '\0'; |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
891 | |
|
17519
500d04f3bf87
Eliminate some type punning warnings in proxy.c. This was inspired by a
Richard Laager <rlaager@pidgin.im>
parents:
17446
diff
changeset
|
892 | p = g_strstr_len((const gchar *)connect_data->read_buffer, |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
893 | connect_data->read_len, "\r\n\r\n"); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
894 | if (p != NULL) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
895 | *p = '\0'; |
|
17519
500d04f3bf87
Eliminate some type punning warnings in proxy.c. This was inspired by a
Richard Laager <rlaager@pidgin.im>
parents:
17446
diff
changeset
|
896 | headers_len = (p - (char *)connect_data->read_buffer) + 4; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
897 | } else if(len == max_read) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
898 | headers_len = len; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
899 | else |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
900 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
901 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
902 | error = strncmp((const char *)connect_data->read_buffer, "HTTP/", 5) != 0; |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
903 | if (!error) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
904 | int major; |
|
17519
500d04f3bf87
Eliminate some type punning warnings in proxy.c. This was inspired by a
Richard Laager <rlaager@pidgin.im>
parents:
17446
diff
changeset
|
905 | p = (char *)connect_data->read_buffer + 5; |
|
500d04f3bf87
Eliminate some type punning warnings in proxy.c. This was inspired by a
Richard Laager <rlaager@pidgin.im>
parents:
17446
diff
changeset
|
906 | major = strtol(p, &p, 10); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
907 | error = (major == 0) || (*p != '.'); |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
908 | if(!error) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
909 | int minor; |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
910 | p++; |
|
17519
500d04f3bf87
Eliminate some type punning warnings in proxy.c. This was inspired by a
Richard Laager <rlaager@pidgin.im>
parents:
17446
diff
changeset
|
911 | minor = strtol(p, &p, 10); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
912 | error = (*p != ' '); |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
913 | if(!error) { |
|
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
914 | p++; |
|
17519
500d04f3bf87
Eliminate some type punning warnings in proxy.c. This was inspired by a
Richard Laager <rlaager@pidgin.im>
parents:
17446
diff
changeset
|
915 | status = strtol(p, &p, 10); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
916 | error = (*p != ' '); |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
917 | } |
|
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
918 | } |
|
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
919 | } |
| 9129 | 920 | |
| 12391 | 921 | /* Read the contents */ |
|
17519
500d04f3bf87
Eliminate some type punning warnings in proxy.c. This was inspired by a
Richard Laager <rlaager@pidgin.im>
parents:
17446
diff
changeset
|
922 | p = g_strrstr((const gchar *)connect_data->read_buffer, "Content-Length: "); |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
923 | if (p != NULL) { |
| 12391 | 924 | gchar *tmp; |
| 925 | int len = 0; | |
| 926 | char tmpc; | |
| 927 | p += strlen("Content-Length: "); | |
|
17519
500d04f3bf87
Eliminate some type punning warnings in proxy.c. This was inspired by a
Richard Laager <rlaager@pidgin.im>
parents:
17446
diff
changeset
|
928 | tmp = strchr(p, '\r'); |
|
13405
9abc78d6db91
[gaim-migrate @ 15779]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13387
diff
changeset
|
929 | if(tmp) |
|
9abc78d6db91
[gaim-migrate @ 15779]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13387
diff
changeset
|
930 | *tmp = '\0'; |
|
17519
500d04f3bf87
Eliminate some type punning warnings in proxy.c. This was inspired by a
Richard Laager <rlaager@pidgin.im>
parents:
17446
diff
changeset
|
931 | len = atoi(p); |
|
13405
9abc78d6db91
[gaim-migrate @ 15779]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13387
diff
changeset
|
932 | if(tmp) |
|
9abc78d6db91
[gaim-migrate @ 15779]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13387
diff
changeset
|
933 | *tmp = '\r'; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
934 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
935 | /* Compensate for what has already been read */ |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
936 | len -= connect_data->read_len - headers_len; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
937 | /* I'm assuming that we're doing this to prevent the server from |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
938 | complaining / breaking since we don't read the whole page */ |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
939 | while (len--) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
940 | /* TODO: deal with EAGAIN (and other errors) better */ |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
941 | if (read(connect_data->fd, &tmpc, 1) < 0 && errno != EAGAIN) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
942 | break; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
943 | } |
| 12391 | 944 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
945 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
946 | if (error) { |
| 15884 | 947 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
948 | _("Unable to parse response from HTTP proxy: %s"), |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
949 | connect_data->read_buffer); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
950 | return; |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
951 | } |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
952 | else if (status != 200) { |
| 15884 | 953 | purple_debug_error("proxy", |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
954 | "Proxy server replied with:\n%s\n", |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
955 | connect_data->read_buffer); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
956 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
957 | if (status == 407 /* Proxy Auth */) { |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
958 | const char *header; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
959 | gchar *request; |
|
19985
b3d60f27292e
This is parts 1 and 2 of patch #2910 from Vladimir (thecrux) to improve NTLM proxy handling. Specifically, it specifies that we're using Unicode strings and uses the hostname of the local machine instead of incorrectly using the proxy server's hostname for authentication. References #2910.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
960 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
961 | header = g_strrstr((const gchar *)connect_data->read_buffer, |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
962 | "Proxy-Authenticate: NTLM"); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
963 | if (header != NULL) { |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
964 | const char *header_end = header + strlen("Proxy-Authenticate: NTLM"); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
965 | const char *domain = purple_proxy_info_get_username(connect_data->gpi); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
966 | char *username = NULL, hostname[256]; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
967 | gchar *response; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
968 | int ret; |
|
19985
b3d60f27292e
This is parts 1 and 2 of patch #2910 from Vladimir (thecrux) to improve NTLM proxy handling. Specifically, it specifies that we're using Unicode strings and uses the hostname of the local machine instead of incorrectly using the proxy server's hostname for authentication. References #2910.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
969 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
970 | ret = gethostname(hostname, sizeof(hostname)); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
971 | hostname[sizeof(hostname) - 1] = '\0'; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
972 | if (ret < 0 || hostname[0] == '\0') { |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
973 | purple_debug_warning("proxy", "gethostname() failed -- is your hostname set?"); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
974 | strcpy(hostname, "localhost"); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
975 | } |
|
19985
b3d60f27292e
This is parts 1 and 2 of patch #2910 from Vladimir (thecrux) to improve NTLM proxy handling. Specifically, it specifies that we're using Unicode strings and uses the hostname of the local machine instead of incorrectly using the proxy server's hostname for authentication. References #2910.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
976 | |
|
20251
a606cd1aa177
applied changes from e33c17e58da161b8cffaf13e9d79e9bb4b9ce4ce
Luke Schierer <lschiere@pidgin.im>
parents:
20239
diff
changeset
|
977 | if (domain != NULL) |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
978 | username = (char*) strchr(domain, '\\'); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
979 | if (username == NULL) { |
| 15884 | 980 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
14418
95ecfabb1797
[gaim-migrate @ 17062]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
981 | _("HTTP proxy connection error %d"), status); |
| 12391 | 982 | return; |
| 983 | } | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
984 | *username = '\0'; |
| 12391 | 985 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
986 | /* Is there a message? */ |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
987 | if (*header_end == ' ') { |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
988 | /* Check for Type-2 */ |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
989 | char *tmp = (char*) header; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
990 | guint8 *nonce; |
| 12391 | 991 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
992 | header_end++; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
993 | username++; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
994 | while(*tmp != '\r' && *tmp != '\0') tmp++; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
995 | *tmp = '\0'; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
996 | nonce = purple_ntlm_parse_type2(header_end, NULL); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
997 | response = purple_ntlm_gen_type3(username, |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
998 | (gchar*) purple_proxy_info_get_password(connect_data->gpi), |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
999 | hostname, |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1000 | domain, nonce, NULL); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1001 | username--; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1002 | } else /* Empty message */ |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1003 | response = purple_ntlm_gen_type1(hostname, domain); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1004 | |
| 12391 | 1005 | *username = '\\'; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1006 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1007 | request = g_strdup_printf( |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1008 | "CONNECT %s:%d HTTP/1.1\r\n" |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1009 | "Host: %s:%d\r\n" |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1010 | "Proxy-Authorization: NTLM %s\r\n" |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1011 | "Proxy-Connection: Keep-Alive\r\n\r\n", |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1012 | connect_data->host, connect_data->port, |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1013 | connect_data->host, connect_data->port, |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1014 | response); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1015 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1016 | g_free(response); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1017 | |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1018 | } else if((header = g_strrstr((const char *)connect_data->read_buffer, "Proxy-Authenticate: Basic"))) { |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1019 | gchar *t1, *t2; |
|
24788
302028de1bff
Prevent a NULL printf crash.
Daniel Atallah <datallah@pidgin.im>
parents:
24683
diff
changeset
|
1020 | const char *username, *password; |
|
302028de1bff
Prevent a NULL printf crash.
Daniel Atallah <datallah@pidgin.im>
parents:
24683
diff
changeset
|
1021 | |
|
302028de1bff
Prevent a NULL printf crash.
Daniel Atallah <datallah@pidgin.im>
parents:
24683
diff
changeset
|
1022 | username = purple_proxy_info_get_username(connect_data->gpi); |
|
302028de1bff
Prevent a NULL printf crash.
Daniel Atallah <datallah@pidgin.im>
parents:
24683
diff
changeset
|
1023 | password = purple_proxy_info_get_password(connect_data->gpi); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1024 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1025 | t1 = g_strdup_printf("%s:%s", |
|
24788
302028de1bff
Prevent a NULL printf crash.
Daniel Atallah <datallah@pidgin.im>
parents:
24683
diff
changeset
|
1026 | username ? username : "", |
|
302028de1bff
Prevent a NULL printf crash.
Daniel Atallah <datallah@pidgin.im>
parents:
24683
diff
changeset
|
1027 | password ? password : ""); |
|
302028de1bff
Prevent a NULL printf crash.
Daniel Atallah <datallah@pidgin.im>
parents:
24683
diff
changeset
|
1028 | t2 = purple_base64_encode((guchar *)t1, strlen(t1)); |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1029 | g_free(t1); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1030 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1031 | request = g_strdup_printf( |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1032 | "CONNECT %s:%d HTTP/1.1\r\n" |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1033 | "Host: %s:%d\r\n" |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1034 | "Proxy-Authorization: Basic %s\r\n", |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1035 | connect_data->host, connect_data->port, |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1036 | connect_data->host, connect_data->port, |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1037 | t2); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1038 | |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1039 | g_free(t2); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1040 | |
| 12391 | 1041 | } else { |
| 15884 | 1042 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
14418
95ecfabb1797
[gaim-migrate @ 17062]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
1043 | _("HTTP proxy connection error %d"), status); |
|
13209
439ad2dad2e1
[gaim-migrate @ 15572]
Daniel Atallah <datallah@pidgin.im>
parents:
13201
diff
changeset
|
1044 | return; |
| 12391 | 1045 | } |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1046 | |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1047 | purple_input_remove(connect_data->inpa); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1048 | g_free(connect_data->read_buffer); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1049 | connect_data->read_buffer = NULL; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1050 | |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1051 | connect_data->write_buffer = (guchar *)request; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1052 | connect_data->write_buf_len = strlen(request); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1053 | connect_data->written_len = 0; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1054 | |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1055 | connect_data->read_cb = http_canread; |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1056 | |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1057 | connect_data->inpa = purple_input_add(connect_data->fd, |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1058 | PURPLE_INPUT_WRITE, proxy_do_write, connect_data); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1059 | |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1060 | proxy_do_write(connect_data, connect_data->fd, cond); |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1061 | |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1062 | return; |
| 12391 | 1063 | } |
|
24188
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1064 | |
|
c061c6d246c4
Add support for sending authorization for Basic proxy authentication when the
Daniel Atallah <datallah@pidgin.im>
parents:
24171
diff
changeset
|
1065 | if (status == 403) { |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1066 | /* Forbidden */ |
| 15884 | 1067 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1068 | _("Access denied: HTTP proxy server forbids port %d tunneling"), |
|
14418
95ecfabb1797
[gaim-migrate @ 17062]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
1069 | connect_data->port); |
|
8917
1301b17bc141
[gaim-migrate @ 9687]
Mark Doliner <markdoliner@pidgin.im>
parents:
8889
diff
changeset
|
1070 | } else { |
| 15884 | 1071 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
14418
95ecfabb1797
[gaim-migrate @ 17062]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
1072 | _("HTTP proxy connection error %d"), status); |
| 7834 | 1073 | } |
| 1074 | } else { | |
| 15884 | 1075 | purple_input_remove(connect_data->inpa); |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1076 | connect_data->inpa = 0; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1077 | g_free(connect_data->read_buffer); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1078 | connect_data->read_buffer = NULL; |
| 15884 | 1079 | purple_debug_info("proxy", "HTTP proxy connection established\n"); |
| 1080 | purple_proxy_connect_data_connected(connect_data); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1081 | return; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1082 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1083 | } |
| 9129 | 1084 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1085 | static void |
|
23234
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1086 | http_start_connect_tunneling(PurpleProxyConnectData *connect_data) { |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1087 | GString *request; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1088 | int ret; |
|
3717
2fc0789e04e8
[gaim-migrate @ 3850]
Herman Bloggs <herman@bluedigits.com>
parents:
3630
diff
changeset
|
1089 | |
| 15884 | 1090 | purple_debug_info("proxy", "Using CONNECT tunneling for %s:%d\n", |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1091 | connect_data->host, connect_data->port); |
|
1843
aeeac3ee7ac5
[gaim-migrate @ 1853]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1840
diff
changeset
|
1092 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1093 | request = g_string_sized_new(4096); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1094 | g_string_append_printf(request, |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1095 | "CONNECT %s:%d HTTP/1.1\r\nHost: %s:%d\r\n", |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1096 | connect_data->host, connect_data->port, |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1097 | connect_data->host, connect_data->port); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1098 | |
| 15884 | 1099 | if (purple_proxy_info_get_username(connect_data->gpi) != NULL) |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1100 | { |
|
22454
e7d161907c67
Patch from eperez to plug a leak in the ntlm proxy authentication. Fixes #4702
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
1101 | char *t1, *t2, *ntlm_type1; |
|
19985
b3d60f27292e
This is parts 1 and 2 of patch #2910 from Vladimir (thecrux) to improve NTLM proxy handling. Specifically, it specifies that we're using Unicode strings and uses the hostname of the local machine instead of incorrectly using the proxy server's hostname for authentication. References #2910.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
1102 | char hostname[256]; |
|
b3d60f27292e
This is parts 1 and 2 of patch #2910 from Vladimir (thecrux) to improve NTLM proxy handling. Specifically, it specifies that we're using Unicode strings and uses the hostname of the local machine instead of incorrectly using the proxy server's hostname for authentication. References #2910.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
1103 | |
|
b3d60f27292e
This is parts 1 and 2 of patch #2910 from Vladimir (thecrux) to improve NTLM proxy handling. Specifically, it specifies that we're using Unicode strings and uses the hostname of the local machine instead of incorrectly using the proxy server's hostname for authentication. References #2910.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
1104 | ret = gethostname(hostname, sizeof(hostname)); |
|
b3d60f27292e
This is parts 1 and 2 of patch #2910 from Vladimir (thecrux) to improve NTLM proxy handling. Specifically, it specifies that we're using Unicode strings and uses the hostname of the local machine instead of incorrectly using the proxy server's hostname for authentication. References #2910.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
1105 | hostname[sizeof(hostname) - 1] = '\0'; |
|
b3d60f27292e
This is parts 1 and 2 of patch #2910 from Vladimir (thecrux) to improve NTLM proxy handling. Specifically, it specifies that we're using Unicode strings and uses the hostname of the local machine instead of incorrectly using the proxy server's hostname for authentication. References #2910.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
1106 | if (ret < 0 || hostname[0] == '\0') { |
|
b3d60f27292e
This is parts 1 and 2 of patch #2910 from Vladimir (thecrux) to improve NTLM proxy handling. Specifically, it specifies that we're using Unicode strings and uses the hostname of the local machine instead of incorrectly using the proxy server's hostname for authentication. References #2910.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
1107 | purple_debug_warning("proxy", "gethostname() failed -- is your hostname set?"); |
|
b3d60f27292e
This is parts 1 and 2 of patch #2910 from Vladimir (thecrux) to improve NTLM proxy handling. Specifically, it specifies that we're using Unicode strings and uses the hostname of the local machine instead of incorrectly using the proxy server's hostname for authentication. References #2910.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
1108 | strcpy(hostname, "localhost"); |
|
b3d60f27292e
This is parts 1 and 2 of patch #2910 from Vladimir (thecrux) to improve NTLM proxy handling. Specifically, it specifies that we're using Unicode strings and uses the hostname of the local machine instead of incorrectly using the proxy server's hostname for authentication. References #2910.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
1109 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1110 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1111 | t1 = g_strdup_printf("%s:%s", |
| 15884 | 1112 | purple_proxy_info_get_username(connect_data->gpi), |
| 1113 | purple_proxy_info_get_password(connect_data->gpi) ? | |
| 1114 | purple_proxy_info_get_password(connect_data->gpi) : ""); | |
| 1115 | t2 = purple_base64_encode((const guchar *)t1, strlen(t1)); | |
|
1843
aeeac3ee7ac5
[gaim-migrate @ 1853]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1840
diff
changeset
|
1116 | g_free(t1); |
|
13387
c6be7551b0a6
[gaim-migrate @ 15759]
Mark Doliner <markdoliner@pidgin.im>
parents:
13313
diff
changeset
|
1117 | |
|
22454
e7d161907c67
Patch from eperez to plug a leak in the ntlm proxy authentication. Fixes #4702
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
1118 | ntlm_type1 = purple_ntlm_gen_type1(hostname, ""); |
|
e7d161907c67
Patch from eperez to plug a leak in the ntlm proxy authentication. Fixes #4702
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
1119 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1120 | g_string_append_printf(request, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1121 | "Proxy-Authorization: Basic %s\r\n" |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1122 | "Proxy-Authorization: NTLM %s\r\n" |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1123 | "Proxy-Connection: Keep-Alive\r\n", |
|
22454
e7d161907c67
Patch from eperez to plug a leak in the ntlm proxy authentication. Fixes #4702
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
1124 | t2, ntlm_type1); |
|
e7d161907c67
Patch from eperez to plug a leak in the ntlm proxy authentication. Fixes #4702
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
1125 | g_free(ntlm_type1); |
|
1843
aeeac3ee7ac5
[gaim-migrate @ 1853]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1840
diff
changeset
|
1126 | g_free(t2); |
|
aeeac3ee7ac5
[gaim-migrate @ 1853]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1840
diff
changeset
|
1127 | } |
|
aeeac3ee7ac5
[gaim-migrate @ 1853]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1840
diff
changeset
|
1128 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1129 | g_string_append(request, "\r\n"); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1130 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1131 | connect_data->write_buf_len = request->len; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1132 | connect_data->write_buffer = (guchar *)g_string_free(request, FALSE); |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1133 | connect_data->written_len = 0; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1134 | connect_data->read_cb = http_canread; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1135 | |
| 15884 | 1136 | connect_data->inpa = purple_input_add(connect_data->fd, |
| 1137 | PURPLE_INPUT_WRITE, proxy_do_write, connect_data); | |
|
23234
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1138 | proxy_do_write(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1139 | } |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1140 | |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1141 | static void |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1142 | http_canwrite(gpointer data, gint source, PurpleInputCondition cond) { |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1143 | PurpleProxyConnectData *connect_data = data; |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1144 | int ret, error = ETIMEDOUT; |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1145 | |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1146 | purple_debug_info("proxy", "Connected to %s:%d.\n", |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1147 | connect_data->host, connect_data->port); |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1148 | |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1149 | if (connect_data->inpa > 0) { |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1150 | purple_input_remove(connect_data->inpa); |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1151 | connect_data->inpa = 0; |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1152 | } |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1153 | |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1154 | ret = purple_input_get_error(connect_data->fd, &error); |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1155 | if (ret != 0 || error != 0) { |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1156 | if (ret != 0) |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1157 | error = errno; |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1158 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(error)); |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1159 | return; |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1160 | } |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1161 | |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1162 | if (connect_data->port == 80) { |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1163 | /* |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1164 | * If we're trying to connect to something running on |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1165 | * port 80 then we assume the traffic using this |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1166 | * connection is going to be HTTP traffic. If it's |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1167 | * not then this will fail (uglily). But it's good |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1168 | * to avoid using the CONNECT method because it's |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1169 | * not always allowed. |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1170 | */ |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1171 | purple_debug_info("proxy", "HTTP proxy connection established\n"); |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1172 | purple_proxy_connect_data_connected(connect_data); |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1173 | } else { |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1174 | http_start_connect_tunneling(connect_data); |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1175 | } |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1176 | |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1177 | } |
|
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1178 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1179 | static void |
| 15884 | 1180 | proxy_connect_http(PurpleProxyConnectData *connect_data, struct sockaddr *addr, socklen_t addrlen) |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
1181 | { |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
1182 | int flags; |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
1183 | |
| 15884 | 1184 | purple_debug_info("proxy", |
|
5211
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4993
diff
changeset
|
1185 | "Connecting to %s:%d via %s:%d using HTTP\n", |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1186 | connect_data->host, connect_data->port, |
| 15884 | 1187 | (purple_proxy_info_get_host(connect_data->gpi) ? purple_proxy_info_get_host(connect_data->gpi) : "(null)"), |
| 1188 | purple_proxy_info_get_port(connect_data->gpi)); | |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
1189 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1190 | connect_data->fd = socket(addr->sa_family, SOCK_STREAM, 0); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1191 | if (connect_data->fd < 0) |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1192 | { |
| 15884 | 1193 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1194 | _("Unable to create socket: %s"), g_strerror(errno)); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1195 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1196 | } |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
1197 | |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
1198 | flags = fcntl(connect_data->fd, F_GETFL); |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
1199 | fcntl(connect_data->fd, F_SETFL, flags | O_NONBLOCK); |
|
10172
8400788b226c
[gaim-migrate @ 11275]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10170
diff
changeset
|
1200 | #ifndef _WIN32 |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1201 | fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC); |
|
10172
8400788b226c
[gaim-migrate @ 11275]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10170
diff
changeset
|
1202 | #endif |
|
3717
2fc0789e04e8
[gaim-migrate @ 3850]
Herman Bloggs <herman@bluedigits.com>
parents:
3630
diff
changeset
|
1203 | |
|
23234
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1204 | if (connect(connect_data->fd, addr, addrlen) != 0) { |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1205 | if (errno == EINPROGRESS || errno == EINTR) { |
| 15884 | 1206 | purple_debug_info("proxy", "Connection in progress\n"); |
| 9655 | 1207 | |
|
23234
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1208 | connect_data->inpa = purple_input_add(connect_data->fd, |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1209 | PURPLE_INPUT_WRITE, http_canwrite, connect_data); |
|
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1210 | } else |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21091
diff
changeset
|
1211 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(errno)); |
|
23234
01e07d16cc75
Rearrange some of the HTTP proxy handling to make sure that we're actually
Daniel Atallah <datallah@pidgin.im>
parents:
23232
diff
changeset
|
1212 | } else { |
| 15884 | 1213 | purple_debug_info("proxy", "Connected immediately.\n"); |
|
5211
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4993
diff
changeset
|
1214 | |
| 15884 | 1215 | http_canwrite(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); |
|
1695
30db76d87de8
[gaim-migrate @ 1705]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1451
diff
changeset
|
1216 | } |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1217 | } |
|
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1218 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1219 | static void |
| 15884 | 1220 | s4_canread(gpointer data, gint source, PurpleInputCondition cond) |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1221 | { |
| 15884 | 1222 | PurpleProxyConnectData *connect_data = data; |
|
13387
c6be7551b0a6
[gaim-migrate @ 15759]
Mark Doliner <markdoliner@pidgin.im>
parents:
13313
diff
changeset
|
1223 | guchar *buf; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1224 | int len, max_read; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1225 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1226 | /* This is really not going to block under normal circumstances, but to |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1227 | * be correct, we deal with the unlikely scenario */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1228 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1229 | if (connect_data->read_buffer == NULL) { |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1230 | connect_data->read_buf_len = 12; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1231 | connect_data->read_buffer = g_malloc(connect_data->read_buf_len); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1232 | connect_data->read_len = 0; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1233 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1234 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1235 | buf = connect_data->read_buffer + connect_data->read_len; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1236 | max_read = connect_data->read_buf_len - connect_data->read_len; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1237 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1238 | len = read(connect_data->fd, buf, max_read); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1239 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1240 | if ((len < 0 && errno == EAGAIN) || (len > 0 && len + connect_data->read_len < 4)) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1241 | return; |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1242 | else if (len + connect_data->read_len >= 4) { |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1243 | if (connect_data->read_buffer[1] == 90) { |
| 15884 | 1244 | purple_proxy_connect_data_connected(connect_data); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1245 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1246 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1247 | } |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1248 | |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21091
diff
changeset
|
1249 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(errno)); |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1250 | } |
|
1705
cc63a8819c1c
[gaim-migrate @ 1715]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1695
diff
changeset
|
1251 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1252 | static void |
|
25622
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1253 | s4_host_resolved(GSList *hosts, gpointer data, const char *error_message) |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1254 | { |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1255 | PurpleProxyConnectData *connect_data = data; |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1256 | unsigned char packet[9]; |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1257 | struct sockaddr *addr; |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1258 | |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1259 | connect_data->query_data = NULL; |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1260 | |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1261 | if (error_message != NULL) { |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1262 | purple_proxy_connect_data_disconnect(connect_data, error_message); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1263 | return; |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1264 | } |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1265 | |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1266 | if (hosts == NULL) { |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1267 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1268 | _("Error resolving %s"), connect_data->host); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1269 | return; |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1270 | } |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1271 | |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1272 | /* Discard the length... */ |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1273 | hosts = g_slist_delete_link(hosts, hosts); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1274 | addr = hosts->data; |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1275 | hosts = g_slist_delete_link(hosts, hosts); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1276 | |
|
25624
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1277 | packet[0] = 0x04; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1278 | packet[1] = 0x01; |
|
25622
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1279 | packet[2] = connect_data->port >> 8; |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1280 | packet[3] = connect_data->port & 0xff; |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1281 | memcpy(packet + 4, &((struct sockaddr_in *)addr)->sin_addr.s_addr, 4); |
|
25624
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1282 | packet[8] = 0x00; |
|
25622
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1283 | |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1284 | g_free(addr); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1285 | |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1286 | /* We could try the other hosts, but hopefully that shouldn't be necessary */ |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1287 | while (hosts != NULL) { |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1288 | /* Discard the length... */ |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1289 | hosts = g_slist_delete_link(hosts, hosts); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1290 | /* Free the address... */ |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1291 | g_free(hosts->data); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1292 | hosts = g_slist_delete_link(hosts, hosts); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1293 | } |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1294 | |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1295 | connect_data->write_buffer = g_memdup(packet, sizeof(packet)); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1296 | connect_data->write_buf_len = sizeof(packet); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1297 | connect_data->written_len = 0; |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1298 | connect_data->read_cb = s4_canread; |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1299 | |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1300 | connect_data->inpa = purple_input_add(connect_data->fd, PURPLE_INPUT_WRITE, proxy_do_write, connect_data); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1301 | |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1302 | proxy_do_write(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1303 | } |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1304 | |
|
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1305 | static void |
| 15884 | 1306 | s4_canwrite(gpointer data, gint source, PurpleInputCondition cond) |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1307 | { |
| 15884 | 1308 | PurpleProxyConnectData *connect_data = data; |
|
2048
4ac8b9622c9e
[gaim-migrate @ 2058]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1881
diff
changeset
|
1309 | int error = ETIMEDOUT; |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1310 | int ret; |
|
3717
2fc0789e04e8
[gaim-migrate @ 3850]
Herman Bloggs <herman@bluedigits.com>
parents:
3630
diff
changeset
|
1311 | |
| 15884 | 1312 | purple_debug_info("socks4 proxy", "Connected.\n"); |
|
5211
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4993
diff
changeset
|
1313 | |
|
25622
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1314 | if (connect_data->inpa > 0) { |
| 15884 | 1315 | purple_input_remove(connect_data->inpa); |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1316 | connect_data->inpa = 0; |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
1317 | } |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1318 | |
| 15884 | 1319 | ret = purple_input_get_error(connect_data->fd, &error); |
|
25622
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1320 | if ((ret != 0) || (error != 0)) { |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1321 | if (ret != 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1322 | error = errno; |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21091
diff
changeset
|
1323 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(error)); |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1324 | return; |
|
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1325 | } |
|
3717
2fc0789e04e8
[gaim-migrate @ 3850]
Herman Bloggs <herman@bluedigits.com>
parents:
3630
diff
changeset
|
1326 | |
| 10561 | 1327 | /* |
|
25624
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1328 | * The socks4 spec doesn't include support for doing host name lookups by |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1329 | * the proxy. Many socks4 servers do this via the "socks4a" extension to |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1330 | * the protocol. There doesn't appear to be a way to detect if a server |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1331 | * supports this, so we require that the user set a global option. |
| 10561 | 1332 | */ |
|
25624
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1333 | if (purple_prefs_get_bool("/purple/proxy/socks4_remotedns")) { |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1334 | unsigned char packet[9]; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1335 | int len; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1336 | |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1337 | purple_debug_info("socks4 proxy", "Attempting to use remote DNS.\n"); |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1338 | |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1339 | packet[0] = 0x04; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1340 | packet[1] = 0x01; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1341 | packet[2] = connect_data->port >> 8; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1342 | packet[3] = connect_data->port & 0xff; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1343 | packet[4] = 0x00; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1344 | packet[5] = 0x00; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1345 | packet[6] = 0x00; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1346 | packet[7] = 0x01; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1347 | packet[8] = 0x00; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1348 | |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1349 | len = sizeof(packet) + strlen(connect_data->host) + 1; |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
1350 | |
|
25624
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1351 | connect_data->write_buffer = g_malloc0(len); |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1352 | memcpy(connect_data->write_buffer, packet, sizeof(packet)); |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1353 | memcpy(connect_data->write_buffer + sizeof(packet), connect_data->host, strlen(connect_data->host)); |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1354 | connect_data->write_buf_len = len; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1355 | connect_data->written_len = 0; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1356 | connect_data->read_cb = s4_canread; |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1357 | |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1358 | connect_data->inpa = purple_input_add(connect_data->fd, PURPLE_INPUT_WRITE, proxy_do_write, connect_data); |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1359 | |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1360 | proxy_do_write(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1361 | } else { |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1362 | connect_data->query_data = purple_dnsquery_a(connect_data->host, |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1363 | connect_data->port, s4_host_resolved, connect_data); |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1364 | |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1365 | if (connect_data->query_data == NULL) { |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1366 | purple_debug_error("proxy", "dns query failed unexpectedly.\n"); |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1367 | purple_proxy_connect_data_destroy(connect_data); |
|
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
1368 | } |
|
25622
6db20d0b5950
Use asynchronous DNS lookups for SOCKS4.
Daniel Atallah <datallah@pidgin.im>
parents:
24866
diff
changeset
|
1369 | } |
| 1 | 1370 | } |
| 1371 | ||
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1372 | static void |
| 15884 | 1373 | proxy_connect_socks4(PurpleProxyConnectData *connect_data, struct sockaddr *addr, socklen_t addrlen) |
| 1 | 1374 | { |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
1375 | int flags; |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
1376 | |
| 15884 | 1377 | purple_debug_info("proxy", |
|
5211
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4993
diff
changeset
|
1378 | "Connecting to %s:%d via %s:%d using SOCKS4\n", |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1379 | connect_data->host, connect_data->port, |
| 15884 | 1380 | purple_proxy_info_get_host(connect_data->gpi), |
| 1381 | purple_proxy_info_get_port(connect_data->gpi)); | |
| 1 | 1382 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1383 | connect_data->fd = socket(addr->sa_family, SOCK_STREAM, 0); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1384 | if (connect_data->fd < 0) |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1385 | { |
| 15884 | 1386 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1387 | _("Unable to create socket: %s"), g_strerror(errno)); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1388 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1389 | } |
| 1 | 1390 | |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
1391 | flags = fcntl(connect_data->fd, F_GETFL); |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
1392 | fcntl(connect_data->fd, F_SETFL, flags | O_NONBLOCK); |
|
10172
8400788b226c
[gaim-migrate @ 11275]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10170
diff
changeset
|
1393 | #ifndef _WIN32 |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1394 | fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC); |
|
10172
8400788b226c
[gaim-migrate @ 11275]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10170
diff
changeset
|
1395 | #endif |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1396 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1397 | if (connect(connect_data->fd, addr, addrlen) != 0) |
|
14161
e959d0e476be
[gaim-migrate @ 16728]
Mark Doliner <markdoliner@pidgin.im>
parents:
14159
diff
changeset
|
1398 | { |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1399 | if ((errno == EINPROGRESS) || (errno == EINTR)) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1400 | { |
| 15884 | 1401 | purple_debug_info("proxy", "Connection in progress.\n"); |
| 1402 | connect_data->inpa = purple_input_add(connect_data->fd, | |
| 1403 | PURPLE_INPUT_WRITE, s4_canwrite, connect_data); | |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1404 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1405 | else |
|
14161
e959d0e476be
[gaim-migrate @ 16728]
Mark Doliner <markdoliner@pidgin.im>
parents:
14159
diff
changeset
|
1406 | { |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21091
diff
changeset
|
1407 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(errno)); |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1408 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1409 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1410 | else |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1411 | { |
| 15884 | 1412 | purple_debug_info("proxy", "Connected immediately.\n"); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1413 | |
| 15884 | 1414 | s4_canwrite(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1415 | } |
|
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1416 | } |
|
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1417 | |
|
17446
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1418 | static gboolean |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1419 | s5_ensure_buffer_length(PurpleProxyConnectData *connect_data, int len) |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1420 | { |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1421 | if(connect_data->read_len < len) { |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1422 | if(connect_data->read_buf_len < len) { |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1423 | /* it's not just that we haven't read enough, it's that we haven't tried to read enough yet */ |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22560
diff
changeset
|
1424 | purple_debug_info("s5", "reallocing from %" G_GSIZE_FORMAT |
|
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22560
diff
changeset
|
1425 | " to %d\n", connect_data->read_buf_len, len); |
|
17446
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1426 | connect_data->read_buf_len = len; |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1427 | connect_data->read_buffer = g_realloc(connect_data->read_buffer, connect_data->read_buf_len); |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1428 | } |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1429 | return FALSE; |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1430 | } |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1431 | |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1432 | return TRUE; |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1433 | } |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1434 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1435 | static void |
| 15884 | 1436 | s5_canread_again(gpointer data, gint source, PurpleInputCondition cond) |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1437 | { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1438 | guchar *dest, *buf; |
| 15884 | 1439 | PurpleProxyConnectData *connect_data = data; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1440 | int len; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1441 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1442 | if (connect_data->read_buffer == NULL) { |
|
23232
4042947ec6c4
Fix SOCK5 error handling to abort when we get a bogus ATYP response. Make the
Daniel Atallah <datallah@pidgin.im>
parents:
22674
diff
changeset
|
1443 | connect_data->read_buf_len = 5; |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1444 | connect_data->read_buffer = g_malloc(connect_data->read_buf_len); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1445 | connect_data->read_len = 0; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1446 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1447 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1448 | dest = connect_data->read_buffer + connect_data->read_len; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1449 | buf = connect_data->read_buffer; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1450 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1451 | len = read(connect_data->fd, dest, (connect_data->read_buf_len - connect_data->read_len)); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1452 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1453 | if (len == 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1454 | { |
| 15884 | 1455 | purple_proxy_connect_data_disconnect(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1456 | _("Server closed the connection")); |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1457 | return; |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
1458 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1459 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1460 | if (len < 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1461 | { |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1462 | if (errno == EAGAIN) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1463 | /* No worries */ |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1464 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1465 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1466 | /* Error! */ |
| 15884 | 1467 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1468 | _("Lost connection with server: %s"), g_strerror(errno)); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1469 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1470 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1471 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1472 | connect_data->read_len += len; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1473 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1474 | if(connect_data->read_len < 4) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1475 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1476 | |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1477 | if ((buf[0] != 0x05) || (buf[1] != 0x00)) { |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1478 | if ((buf[0] == 0x05) && (buf[1] < 0x09)) { |
|
24683
3481a3320313
Backport the 'purple_debug_*(msg)' -> 'purple_debug_*("%s", msg);' fixes.
Richard Laager <rlaager@pidgin.im>
parents:
24491
diff
changeset
|
1479 | purple_debug_error("socks5 proxy", "%s", socks5errors[buf[1]]); |
| 15884 | 1480 | purple_proxy_connect_data_disconnect(connect_data, |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1481 | socks5errors[buf[1]]); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1482 | } else { |
| 15884 | 1483 | purple_debug_error("socks5 proxy", "Bad data.\n"); |
| 1484 | purple_proxy_connect_data_disconnect(connect_data, | |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1485 | _("Received invalid data on connection with server")); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1486 | } |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1487 | return; |
|
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1488 | } |
|
670
1690e6b432ae
[gaim-migrate @ 680]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
664
diff
changeset
|
1489 | |
| 8262 | 1490 | /* Skip past BND.ADDR */ |
| 1491 | switch(buf[3]) { | |
| 1492 | case 0x01: /* the address is a version-4 IP address, with a length of 4 octets */ | |
|
17446
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1493 | if(!s5_ensure_buffer_length(connect_data, 4 + 4)) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1494 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1495 | buf += 4 + 4; |
| 8262 | 1496 | break; |
| 1497 | case 0x03: /* the address field contains a fully-qualified domain name. The first | |
| 1498 | octet of the address field contains the number of octets of name that | |
| 1499 | follow, there is no terminating NUL octet. */ | |
|
17446
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1500 | if(!s5_ensure_buffer_length(connect_data, 4 + 1)) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1501 | return; |
|
17446
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1502 | buf += 4; |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1503 | if(!s5_ensure_buffer_length(connect_data, 4 + 1 + buf[0])) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1504 | return; |
|
17446
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1505 | buf += buf[0] + 1; |
| 8262 | 1506 | break; |
| 1507 | case 0x04: /* the address is a version-6 IP address, with a length of 16 octets */ | |
|
17446
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1508 | if(!s5_ensure_buffer_length(connect_data, 4 + 16)) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1509 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1510 | buf += 4 + 16; |
| 8262 | 1511 | break; |
|
23232
4042947ec6c4
Fix SOCK5 error handling to abort when we get a bogus ATYP response. Make the
Daniel Atallah <datallah@pidgin.im>
parents:
22674
diff
changeset
|
1512 | default: |
|
4042947ec6c4
Fix SOCK5 error handling to abort when we get a bogus ATYP response. Make the
Daniel Atallah <datallah@pidgin.im>
parents:
22674
diff
changeset
|
1513 | purple_debug_error("socks5 proxy", "Invalid ATYP received (0x%X)\n", buf[3]); |
|
4042947ec6c4
Fix SOCK5 error handling to abort when we get a bogus ATYP response. Make the
Daniel Atallah <datallah@pidgin.im>
parents:
22674
diff
changeset
|
1514 | purple_proxy_connect_data_disconnect(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1515 | _("Received invalid data on connection with server")); |
|
23232
4042947ec6c4
Fix SOCK5 error handling to abort when we get a bogus ATYP response. Make the
Daniel Atallah <datallah@pidgin.im>
parents:
22674
diff
changeset
|
1516 | return; |
| 8262 | 1517 | } |
| 1518 | ||
|
17446
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1519 | /* Skip past BND.PORT */ |
|
fd9e235a88e7
fix socks5 from over-reading the headers, and throwing away data (fixes jabber file receiving)
Nathan Walp <nwalp@pidgin.im>
parents:
17102
diff
changeset
|
1520 | if(!s5_ensure_buffer_length(connect_data, (buf - connect_data->read_buffer) + 2)) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1521 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1522 | |
| 15884 | 1523 | purple_proxy_connect_data_connected(connect_data); |
| 1 | 1524 | } |
| 1525 | ||
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1526 | static void |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
1527 | s5_sendconnect(gpointer data, int source) |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
1528 | { |
| 15884 | 1529 | PurpleProxyConnectData *connect_data = data; |
| 25623 | 1530 | size_t hlen = strlen(connect_data->host); |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1531 | connect_data->write_buf_len = 5 + hlen + 2; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1532 | connect_data->write_buffer = g_malloc(connect_data->write_buf_len); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1533 | connect_data->written_len = 0; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1534 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1535 | connect_data->write_buffer[0] = 0x05; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1536 | connect_data->write_buffer[1] = 0x01; /* CONNECT */ |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1537 | connect_data->write_buffer[2] = 0x00; /* reserved */ |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1538 | connect_data->write_buffer[3] = 0x03; /* address type -- host name */ |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1539 | connect_data->write_buffer[4] = hlen; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1540 | memcpy(connect_data->write_buffer + 5, connect_data->host, hlen); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1541 | connect_data->write_buffer[5 + hlen] = connect_data->port >> 8; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1542 | connect_data->write_buffer[5 + hlen + 1] = connect_data->port & 0xff; |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
1543 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1544 | connect_data->read_cb = s5_canread_again; |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1545 | |
| 15884 | 1546 | connect_data->inpa = purple_input_add(connect_data->fd, PURPLE_INPUT_WRITE, proxy_do_write, connect_data); |
| 1547 | proxy_do_write(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); | |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1548 | } |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
1549 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1550 | static void |
| 15884 | 1551 | s5_readauth(gpointer data, gint source, PurpleInputCondition cond) |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1552 | { |
| 15884 | 1553 | PurpleProxyConnectData *connect_data = data; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1554 | int len; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1555 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1556 | if (connect_data->read_buffer == NULL) { |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1557 | connect_data->read_buf_len = 2; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1558 | connect_data->read_buffer = g_malloc(connect_data->read_buf_len); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1559 | connect_data->read_len = 0; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1560 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1561 | |
| 15884 | 1562 | purple_debug_info("socks5 proxy", "Got auth response.\n"); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1563 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1564 | len = read(connect_data->fd, connect_data->read_buffer + connect_data->read_len, |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1565 | connect_data->read_buf_len - connect_data->read_len); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1566 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1567 | if (len == 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1568 | { |
| 15884 | 1569 | purple_proxy_connect_data_disconnect(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1570 | _("Server closed the connection")); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1571 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1572 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1573 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1574 | if (len < 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1575 | { |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1576 | if (errno == EAGAIN) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1577 | /* No worries */ |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1578 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1579 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1580 | /* Error! */ |
| 15884 | 1581 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1582 | _("Lost connection with server: %s"), g_strerror(errno)); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1583 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1584 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1585 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1586 | connect_data->read_len += len; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1587 | if (connect_data->read_len < 2) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1588 | return; |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1589 | |
| 15884 | 1590 | purple_input_remove(connect_data->inpa); |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1591 | connect_data->inpa = 0; |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1592 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1593 | if ((connect_data->read_buffer[0] != 0x01) || (connect_data->read_buffer[1] != 0x00)) { |
| 15884 | 1594 | purple_proxy_connect_data_disconnect(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1595 | _("Received invalid data on connection with server")); |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1596 | return; |
|
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1597 | } |
|
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1598 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1599 | g_free(connect_data->read_buffer); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1600 | connect_data->read_buffer = NULL; |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1601 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1602 | s5_sendconnect(connect_data, connect_data->fd); |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1603 | } |
|
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1604 | |
|
14159
0fcdaa463a32
[gaim-migrate @ 16726]
Mark Doliner <markdoliner@pidgin.im>
parents:
14158
diff
changeset
|
1605 | static void |
|
0fcdaa463a32
[gaim-migrate @ 16726]
Mark Doliner <markdoliner@pidgin.im>
parents:
14158
diff
changeset
|
1606 | hmacmd5_chap(const unsigned char * challenge, int challen, const char * passwd, unsigned char * response) |
| 10561 | 1607 | { |
| 15884 | 1608 | PurpleCipher *cipher; |
| 1609 | PurpleCipherContext *ctx; | |
| 10561 | 1610 | int i; |
| 1611 | unsigned char Kxoripad[65]; | |
| 1612 | unsigned char Kxoropad[65]; | |
| 25623 | 1613 | size_t pwlen; |
| 10561 | 1614 | |
| 15884 | 1615 | cipher = purple_ciphers_find_cipher("md5"); |
| 1616 | ctx = purple_cipher_context_new(cipher, NULL); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10626
diff
changeset
|
1617 | |
|
12765
0c1580860d16
[gaim-migrate @ 15112]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12758
diff
changeset
|
1618 | memset(Kxoripad,0,sizeof(Kxoripad)); |
|
0c1580860d16
[gaim-migrate @ 15112]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12758
diff
changeset
|
1619 | memset(Kxoropad,0,sizeof(Kxoropad)); |
|
0c1580860d16
[gaim-migrate @ 15112]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12758
diff
changeset
|
1620 | |
| 10561 | 1621 | pwlen=strlen(passwd); |
| 1622 | if (pwlen>64) { | |
| 15884 | 1623 | purple_cipher_context_append(ctx, (const guchar *)passwd, strlen(passwd)); |
| 1624 | purple_cipher_context_digest(ctx, sizeof(Kxoripad), Kxoripad, NULL); | |
| 10561 | 1625 | pwlen=16; |
|
12765
0c1580860d16
[gaim-migrate @ 15112]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12758
diff
changeset
|
1626 | } else { |
|
0c1580860d16
[gaim-migrate @ 15112]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12758
diff
changeset
|
1627 | memcpy(Kxoripad, passwd, pwlen); |
| 10561 | 1628 | } |
|
12765
0c1580860d16
[gaim-migrate @ 15112]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12758
diff
changeset
|
1629 | memcpy(Kxoropad,Kxoripad,pwlen); |
| 10561 | 1630 | |
| 1631 | for (i=0;i<64;i++) { | |
| 1632 | Kxoripad[i]^=0x36; | |
| 1633 | Kxoropad[i]^=0x5c; | |
| 1634 | } | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10626
diff
changeset
|
1635 | |
| 15884 | 1636 | purple_cipher_context_reset(ctx, NULL); |
| 1637 | purple_cipher_context_append(ctx, Kxoripad, 64); | |
| 1638 | purple_cipher_context_append(ctx, challenge, challen); | |
| 1639 | purple_cipher_context_digest(ctx, sizeof(Kxoripad), Kxoripad, NULL); | |
| 10561 | 1640 | |
| 15884 | 1641 | purple_cipher_context_reset(ctx, NULL); |
| 1642 | purple_cipher_context_append(ctx, Kxoropad, 64); | |
| 1643 | purple_cipher_context_append(ctx, Kxoripad, 16); | |
| 1644 | purple_cipher_context_digest(ctx, 16, response, NULL); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10626
diff
changeset
|
1645 | |
| 15884 | 1646 | purple_cipher_context_destroy(ctx); |
| 10561 | 1647 | } |
| 1648 | ||
| 1649 | static void | |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1650 | s5_readchap(gpointer data, gint source, PurpleInputCondition cond); |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1651 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1652 | /* |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1653 | * Return how many bytes we processed |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1654 | * -1 means we've shouldn't keep reading from the buffer |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1655 | */ |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1656 | static gssize |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1657 | s5_parse_chap_msg(PurpleProxyConnectData *connect_data) |
| 10561 | 1658 | { |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1659 | guchar *buf, *cmdbuf = connect_data->read_buffer; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1660 | int len, navas, currentav; |
| 10561 | 1661 | |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1662 | purple_debug_misc("socks5 proxy", "Reading CHAP message: %x\n", *cmdbuf); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1663 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1664 | if (*cmdbuf != 0x01) { |
| 15884 | 1665 | purple_proxy_connect_data_disconnect(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1666 | _("Received invalid data on connection with server")); |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1667 | return -1; |
| 10561 | 1668 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1669 | cmdbuf++; |
| 10561 | 1670 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1671 | navas = *cmdbuf; |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1672 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1673 | purple_debug_misc("socks5 proxy", "Expecting %d attribute(s).\n", navas); |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1674 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1675 | cmdbuf++; |
| 10561 | 1676 | |
| 1677 | for (currentav = 0; currentav < navas; currentav++) { | |
|
22674
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1678 | |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1679 | len = connect_data->read_len - (cmdbuf - connect_data->read_buffer); |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1680 | /* We don't have enough data to even know how long the next attribute is, |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1681 | * or we don't have the full length of the next attribute. */ |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1682 | if (len < 2 || len < (cmdbuf[1] + 2)) { |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1683 | /* Clear out the attributes that have been read - decrease the attribute count */ |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1684 | connect_data->read_buffer[1] = navas - currentav; |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1685 | /* Move the unprocessed data into the first attribute position */ |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1686 | memmove((connect_data->read_buffer + 2), cmdbuf, len); |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1687 | /* Decrease the read count accordingly */ |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1688 | connect_data->read_len = len + 2; |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1689 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1690 | purple_debug_info("socks5 proxy", "Need more data to retrieve attribute %d.\n", currentav); |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1691 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1692 | return -1; |
|
22674
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1693 | } |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1694 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1695 | buf = cmdbuf + 2; |
|
22674
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1696 | |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1697 | if (cmdbuf[1] == 0) { |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1698 | purple_debug_error("socks5 proxy", "Attribute %x Value length of 0; ignoring.\n", cmdbuf[0]); |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1699 | cmdbuf = buf; |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1700 | continue; |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1701 | } |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1702 | |
| 10561 | 1703 | switch (cmdbuf[0]) { |
| 1704 | case 0x00: | |
|
22674
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1705 | purple_debug_info("socks5 proxy", "Received STATUS of %x\n", buf[0]); |
| 10561 | 1706 | /* Did auth work? */ |
| 1707 | if (buf[0] == 0x00) { | |
| 15884 | 1708 | purple_input_remove(connect_data->inpa); |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1709 | connect_data->inpa = 0; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1710 | g_free(connect_data->read_buffer); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1711 | connect_data->read_buffer = NULL; |
| 10561 | 1712 | /* Success */ |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1713 | s5_sendconnect(connect_data, connect_data->fd); |
| 10561 | 1714 | } else { |
| 1715 | /* Failure */ | |
| 15884 | 1716 | purple_debug_warning("proxy", |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1717 | "socks5 CHAP authentication " |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1718 | "failed. Disconnecting..."); |
| 15884 | 1719 | purple_proxy_connect_data_disconnect(connect_data, |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1720 | _("Authentication failed")); |
| 10561 | 1721 | } |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1722 | return -1; |
|
24298
e4dc493363d7
Add support for printing out the TEXT-MESSAGE in SOCKS5 CHAP auth.
Daniel Atallah <datallah@pidgin.im>
parents:
24297
diff
changeset
|
1723 | case 0x01: |
|
e4dc493363d7
Add support for printing out the TEXT-MESSAGE in SOCKS5 CHAP auth.
Daniel Atallah <datallah@pidgin.im>
parents:
24297
diff
changeset
|
1724 | /* We've already validated that cmdbuf[1] is sane. */ |
|
e4dc493363d7
Add support for printing out the TEXT-MESSAGE in SOCKS5 CHAP auth.
Daniel Atallah <datallah@pidgin.im>
parents:
24297
diff
changeset
|
1725 | purple_debug_info("socks5 proxy", "Received TEXT-MESSAGE of '%.*s'\n", (int) cmdbuf[1], buf); |
|
e4dc493363d7
Add support for printing out the TEXT-MESSAGE in SOCKS5 CHAP auth.
Daniel Atallah <datallah@pidgin.im>
parents:
24297
diff
changeset
|
1726 | break; |
| 10561 | 1727 | case 0x03: |
|
22674
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1728 | purple_debug_info("socks5 proxy", "Received CHALLENGE\n"); |
| 10561 | 1729 | /* Server wants our credentials */ |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1730 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1731 | connect_data->write_buf_len = 16 + 4; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1732 | connect_data->write_buffer = g_malloc(connect_data->write_buf_len); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1733 | connect_data->written_len = 0; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1734 | |
| 10561 | 1735 | hmacmd5_chap(buf, cmdbuf[1], |
| 15884 | 1736 | purple_proxy_info_get_password(connect_data->gpi), |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1737 | connect_data->write_buffer + 4); |
|
24298
e4dc493363d7
Add support for printing out the TEXT-MESSAGE in SOCKS5 CHAP auth.
Daniel Atallah <datallah@pidgin.im>
parents:
24297
diff
changeset
|
1738 | /* TODO: What about USER-IDENTITY? */ |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1739 | connect_data->write_buffer[0] = 0x01; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1740 | connect_data->write_buffer[1] = 0x01; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1741 | connect_data->write_buffer[2] = 0x04; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1742 | connect_data->write_buffer[3] = 0x10; |
| 10561 | 1743 | |
| 15884 | 1744 | purple_input_remove(connect_data->inpa); |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1745 | g_free(connect_data->read_buffer); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1746 | connect_data->read_buffer = NULL; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1747 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1748 | connect_data->read_cb = s5_readchap; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1749 | |
| 15884 | 1750 | connect_data->inpa = purple_input_add(connect_data->fd, |
| 1751 | PURPLE_INPUT_WRITE, proxy_do_write, connect_data); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1752 | |
| 15884 | 1753 | proxy_do_write(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1754 | return -1; |
| 10561 | 1755 | case 0x11: |
|
22674
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1756 | purple_debug_info("socks5 proxy", "Received ALGORIGTHMS of %x\n", buf[0]); |
| 10561 | 1757 | /* Server wants to select an algorithm */ |
| 1758 | if (buf[0] != 0x85) { | |
| 1759 | /* Only currently support HMAC-MD5 */ | |
| 15884 | 1760 | purple_debug_warning("proxy", |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1761 | "Server tried to select an " |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1762 | "algorithm that we did not advertise " |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1763 | "as supporting. This is a violation " |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1764 | "of the socks5 CHAP specification. " |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1765 | "Disconnecting..."); |
| 15884 | 1766 | purple_proxy_connect_data_disconnect(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1767 | _("Received invalid data on connection with server")); |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1768 | return -1; |
| 10561 | 1769 | } |
| 1770 | break; | |
|
22674
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1771 | default: |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1772 | purple_debug_info("socks5 proxy", "Received unused command %x, length=%d\n", cmdbuf[0], cmdbuf[1]); |
| 10561 | 1773 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1774 | cmdbuf = buf + cmdbuf[1]; |
| 10561 | 1775 | } |
|
22674
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1776 | |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1777 | return (cmdbuf - connect_data->read_buffer); |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1778 | } |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1779 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1780 | static void |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1781 | s5_readchap(gpointer data, gint source, PurpleInputCondition cond) |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1782 | { |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1783 | gssize msg_ret; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1784 | PurpleProxyConnectData *connect_data = data; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1785 | int len; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1786 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1787 | purple_debug(PURPLE_DEBUG_INFO, "socks5 proxy", "Got CHAP response.\n"); |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1788 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1789 | if (connect_data->read_buffer == NULL) { |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1790 | /* A big enough butfer to read the message header (2 bytes) and at least one complete attribute and value (1 + 1 + 255). */ |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1791 | connect_data->read_buf_len = 259; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1792 | connect_data->read_buffer = g_malloc(connect_data->read_buf_len); |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1793 | connect_data->read_len = 0; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1794 | } |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1795 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1796 | if (connect_data->read_buf_len - connect_data->read_len == 0) { |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1797 | /*If the stuff below is right, this shouldn't be possible. */ |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1798 | purple_debug_error("socks5 proxy", "This is about to suck because the read buffer is full (shouldn't happen).\n"); |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1799 | } |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1800 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1801 | len = read(connect_data->fd, connect_data->read_buffer + connect_data->read_len, |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1802 | connect_data->read_buf_len - connect_data->read_len); |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1803 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1804 | if (len == 0) { |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1805 | purple_proxy_connect_data_disconnect(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1806 | _("Server closed the connection")); |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1807 | return; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1808 | } |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1809 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1810 | if (len < 0) { |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1811 | if (errno == EAGAIN) |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1812 | /* No worries */ |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1813 | return; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1814 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1815 | /* Error! */ |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1816 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1817 | _("Lost connection with server: %s"), g_strerror(errno)); |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1818 | return; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1819 | } |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1820 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1821 | connect_data->read_len += len; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1822 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1823 | /* We may have read more than one message into the buffer, we need to make sure to process them all */ |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1824 | while (1) { |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1825 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1826 | /* We need more to be able to read this message */ |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1827 | if (connect_data->read_len < 2) |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1828 | return; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1829 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1830 | msg_ret = s5_parse_chap_msg(connect_data); |
| 25623 | 1831 | |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1832 | if (msg_ret < 0) |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1833 | return; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1834 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1835 | /* See if we have another message already in the buffer */ |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1836 | if ((len = connect_data->read_len - msg_ret) > 0) { |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1837 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1838 | /* Move on to the next message */ |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1839 | memmove(connect_data->read_buffer, connect_data->read_buffer + msg_ret, len); |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1840 | /* Decrease the read count accordingly */ |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1841 | connect_data->read_len = len; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1842 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1843 | /* Try to read the message that connect_data->read_buffer now points to */ |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1844 | continue; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1845 | } |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1846 | |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1847 | break; |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1848 | } |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1849 | |
| 10561 | 1850 | /* Fell through. We ran out of CHAP events to process, but haven't |
| 1851 | * succeeded or failed authentication - there may be more to come. | |
| 1852 | * If this is the case, come straight back here. */ | |
|
22674
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1853 | |
|
24297
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1854 | purple_debug_info("socks5 proxy", "Waiting for another message from which to read CHAP info.\n"); |
|
d791093e412f
Fix the SOCKS5 CHAP authentication to parse several messages if they are read at
Daniel Atallah <datallah@pidgin.im>
parents:
24188
diff
changeset
|
1855 | |
|
22674
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1856 | /* We've processed all the available attributes, so get ready for a whole new message */ |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1857 | g_free(connect_data->read_buffer); |
|
2628be97bebd
Fix SOCKS5 CHAP authentication to be more robust; the current stuff depends on the attributes coming in in a specific order and the whole authentication having a maximum length of 20 bytes. Big thanks to Jonathan Rudolph ("simple" on IRC) for helping figure out what was wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
1858 | connect_data->read_buffer = NULL; |
| 10561 | 1859 | } |
| 1860 | ||
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1861 | static void |
| 15884 | 1862 | s5_canread(gpointer data, gint source, PurpleInputCondition cond) |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1863 | { |
| 15884 | 1864 | PurpleProxyConnectData *connect_data = data; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1865 | int len; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1866 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1867 | if (connect_data->read_buffer == NULL) { |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1868 | connect_data->read_buf_len = 2; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1869 | connect_data->read_buffer = g_malloc(connect_data->read_buf_len); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1870 | connect_data->read_len = 0; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1871 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1872 | |
| 15884 | 1873 | purple_debug_info("socks5 proxy", "Able to read.\n"); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1874 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1875 | len = read(connect_data->fd, connect_data->read_buffer + connect_data->read_len, |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1876 | connect_data->read_buf_len - connect_data->read_len); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1877 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1878 | if (len == 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1879 | { |
| 15884 | 1880 | purple_proxy_connect_data_disconnect(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1881 | _("Server closed the connection")); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1882 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1883 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1884 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1885 | if (len < 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1886 | { |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1887 | if (errno == EAGAIN) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1888 | /* No worries */ |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1889 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1890 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1891 | /* Error! */ |
| 15884 | 1892 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1893 | _("Lost connection with server: %s"), g_strerror(errno)); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1894 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1895 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1896 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1897 | connect_data->read_len += len; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1898 | if (connect_data->read_len < 2) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1899 | return; |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1900 | |
| 15884 | 1901 | purple_input_remove(connect_data->inpa); |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1902 | connect_data->inpa = 0; |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1903 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1904 | if ((connect_data->read_buffer[0] != 0x05) || (connect_data->read_buffer[1] == 0xff)) { |
| 15884 | 1905 | purple_proxy_connect_data_disconnect(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
1906 | _("Received invalid data on connection with server")); |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1907 | return; |
|
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1908 | } |
|
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1909 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1910 | if (connect_data->read_buffer[1] == 0x02) { |
| 25623 | 1911 | size_t i, j; |
|
10912
ec7c127a435b
[gaim-migrate @ 12667]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10711
diff
changeset
|
1912 | const char *u, *p; |
| 9129 | 1913 | |
| 15884 | 1914 | u = purple_proxy_info_get_username(connect_data->gpi); |
| 1915 | p = purple_proxy_info_get_password(connect_data->gpi); | |
|
10912
ec7c127a435b
[gaim-migrate @ 12667]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10711
diff
changeset
|
1916 | |
|
ec7c127a435b
[gaim-migrate @ 12667]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10711
diff
changeset
|
1917 | i = (u == NULL) ? 0 : strlen(u); |
|
ec7c127a435b
[gaim-migrate @ 12667]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10711
diff
changeset
|
1918 | j = (p == NULL) ? 0 : strlen(p); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1919 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1920 | connect_data->write_buf_len = 1 + 1 + i + 1 + j; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1921 | connect_data->write_buffer = g_malloc(connect_data->write_buf_len); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1922 | connect_data->written_len = 0; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1923 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1924 | connect_data->write_buffer[0] = 0x01; /* version 1 */ |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1925 | connect_data->write_buffer[1] = i; |
|
10917
f32ea2da503b
[gaim-migrate @ 12678]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10912
diff
changeset
|
1926 | if (u != NULL) |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1927 | memcpy(connect_data->write_buffer + 2, u, i); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1928 | connect_data->write_buffer[2 + i] = j; |
|
10917
f32ea2da503b
[gaim-migrate @ 12678]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10912
diff
changeset
|
1929 | if (p != NULL) |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1930 | memcpy(connect_data->write_buffer + 2 + i + 1, p, j); |
|
3717
2fc0789e04e8
[gaim-migrate @ 3850]
Herman Bloggs <herman@bluedigits.com>
parents:
3630
diff
changeset
|
1931 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1932 | g_free(connect_data->read_buffer); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1933 | connect_data->read_buffer = NULL; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1934 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1935 | connect_data->read_cb = s5_readauth; |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1936 | |
| 15884 | 1937 | connect_data->inpa = purple_input_add(connect_data->fd, PURPLE_INPUT_WRITE, |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1938 | proxy_do_write, connect_data); |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1939 | |
| 15884 | 1940 | proxy_do_write(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1941 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1942 | return; |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1943 | } else if (connect_data->read_buffer[1] == 0x03) { |
| 25623 | 1944 | size_t userlen; |
| 15884 | 1945 | userlen = strlen(purple_proxy_info_get_username(connect_data->gpi)); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1946 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1947 | connect_data->write_buf_len = 7 + userlen; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1948 | connect_data->write_buffer = g_malloc(connect_data->write_buf_len); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1949 | connect_data->written_len = 0; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1950 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1951 | connect_data->write_buffer[0] = 0x01; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1952 | connect_data->write_buffer[1] = 0x02; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1953 | connect_data->write_buffer[2] = 0x11; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1954 | connect_data->write_buffer[3] = 0x01; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1955 | connect_data->write_buffer[4] = 0x85; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1956 | connect_data->write_buffer[5] = 0x02; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1957 | connect_data->write_buffer[6] = userlen; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1958 | memcpy(connect_data->write_buffer + 7, |
| 15884 | 1959 | purple_proxy_info_get_username(connect_data->gpi), userlen); |
| 10561 | 1960 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1961 | g_free(connect_data->read_buffer); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1962 | connect_data->read_buffer = NULL; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1963 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1964 | connect_data->read_cb = s5_readchap; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1965 | |
| 15884 | 1966 | connect_data->inpa = purple_input_add(connect_data->fd, PURPLE_INPUT_WRITE, |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1967 | proxy_do_write, connect_data); |
| 10561 | 1968 | |
| 15884 | 1969 | proxy_do_write(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1970 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1971 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1972 | } else { |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1973 | g_free(connect_data->read_buffer); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1974 | connect_data->read_buffer = NULL; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1975 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1976 | s5_sendconnect(connect_data, connect_data->fd); |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1977 | } |
|
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1978 | } |
|
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
1979 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1980 | static void |
| 15884 | 1981 | s5_canwrite(gpointer data, gint source, PurpleInputCondition cond) |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1982 | { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
1983 | unsigned char buf[5]; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
1984 | int i; |
| 15884 | 1985 | PurpleProxyConnectData *connect_data = data; |
|
2048
4ac8b9622c9e
[gaim-migrate @ 2058]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1881
diff
changeset
|
1986 | int error = ETIMEDOUT; |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1987 | int ret; |
|
3717
2fc0789e04e8
[gaim-migrate @ 3850]
Herman Bloggs <herman@bluedigits.com>
parents:
3630
diff
changeset
|
1988 | |
| 15884 | 1989 | purple_debug_info("socks5 proxy", "Connected.\n"); |
|
5211
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4993
diff
changeset
|
1990 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1991 | if (connect_data->inpa > 0) |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
1992 | { |
| 15884 | 1993 | purple_input_remove(connect_data->inpa); |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
1994 | connect_data->inpa = 0; |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
1995 | } |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1996 | |
| 15884 | 1997 | ret = purple_input_get_error(connect_data->fd, &error); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1998 | if ((ret != 0) || (error != 0)) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
1999 | { |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2000 | if (ret != 0) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2001 | error = errno; |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21091
diff
changeset
|
2002 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(error)); |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
2003 | return; |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
2004 | } |
|
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
2005 | |
|
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
2006 | i = 0; |
|
1252
94fbface2d84
[gaim-migrate @ 1262]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1087
diff
changeset
|
2007 | buf[0] = 0x05; /* SOCKS version 5 */ |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2008 | |
| 15884 | 2009 | if (purple_proxy_info_get_username(connect_data->gpi) != NULL) { |
| 10561 | 2010 | buf[1] = 0x03; /* three methods */ |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
2011 | buf[2] = 0x00; /* no authentication */ |
| 10561 | 2012 | buf[3] = 0x03; /* CHAP authentication */ |
| 2013 | buf[4] = 0x02; /* username/password authentication */ | |
| 2014 | i = 5; | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2015 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2016 | else { |
|
1844
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
2017 | buf[1] = 0x01; |
|
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
2018 | buf[2] = 0x00; |
|
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
2019 | i = 3; |
|
161c00c36474
[gaim-migrate @ 1854]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1843
diff
changeset
|
2020 | } |
|
3717
2fc0789e04e8
[gaim-migrate @ 3850]
Herman Bloggs <herman@bluedigits.com>
parents:
3630
diff
changeset
|
2021 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2022 | connect_data->write_buf_len = i; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2023 | connect_data->write_buffer = g_malloc(connect_data->write_buf_len); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2024 | memcpy(connect_data->write_buffer, buf, i); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2025 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2026 | connect_data->read_cb = s5_canread; |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
2027 | |
| 15884 | 2028 | connect_data->inpa = purple_input_add(connect_data->fd, PURPLE_INPUT_WRITE, proxy_do_write, connect_data); |
| 2029 | proxy_do_write(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); | |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
2030 | } |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
2031 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2032 | static void |
| 15884 | 2033 | proxy_connect_socks5(PurpleProxyConnectData *connect_data, struct sockaddr *addr, socklen_t addrlen) |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
2034 | { |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
2035 | int flags; |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
2036 | |
| 15884 | 2037 | purple_debug_info("proxy", |
|
5211
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4993
diff
changeset
|
2038 | "Connecting to %s:%d via %s:%d using SOCKS5\n", |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2039 | connect_data->host, connect_data->port, |
| 15884 | 2040 | purple_proxy_info_get_host(connect_data->gpi), |
| 2041 | purple_proxy_info_get_port(connect_data->gpi)); | |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
2042 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2043 | connect_data->fd = socket(addr->sa_family, SOCK_STREAM, 0); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2044 | if (connect_data->fd < 0) |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2045 | { |
| 15884 | 2046 | purple_proxy_connect_data_disconnect_formatted(connect_data, |
|
27629
508e7ceb9255
Remove periods and newlines from many error messages that end up being used
Mark Doliner <markdoliner@pidgin.im>
parents:
27497
diff
changeset
|
2047 | _("Unable to create socket: %s"), g_strerror(errno)); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2048 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2049 | } |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
2050 | |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
2051 | flags = fcntl(connect_data->fd, F_GETFL); |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
2052 | fcntl(connect_data->fd, F_SETFL, flags | O_NONBLOCK); |
|
10172
8400788b226c
[gaim-migrate @ 11275]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10170
diff
changeset
|
2053 | #ifndef _WIN32 |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2054 | fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC); |
|
10172
8400788b226c
[gaim-migrate @ 11275]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10170
diff
changeset
|
2055 | #endif |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2056 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2057 | if (connect(connect_data->fd, addr, addrlen) != 0) |
|
14161
e959d0e476be
[gaim-migrate @ 16728]
Mark Doliner <markdoliner@pidgin.im>
parents:
14159
diff
changeset
|
2058 | { |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2059 | if ((errno == EINPROGRESS) || (errno == EINTR)) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2060 | { |
| 15884 | 2061 | purple_debug_info("socks5 proxy", "Connection in progress\n"); |
| 2062 | connect_data->inpa = purple_input_add(connect_data->fd, | |
| 2063 | PURPLE_INPUT_WRITE, s5_canwrite, connect_data); | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2064 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2065 | else |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2066 | { |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21091
diff
changeset
|
2067 | purple_proxy_connect_data_disconnect(connect_data, g_strerror(errno)); |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
2068 | } |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2069 | } |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2070 | else |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2071 | { |
| 15884 | 2072 | purple_debug_info("proxy", "Connected immediately.\n"); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2073 | |
| 15884 | 2074 | s5_canwrite(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
2075 | } |
|
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
2076 | } |
|
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
2077 | |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
2078 | /** |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2079 | * This function attempts to connect to the next IP address in the list |
| 15884 | 2080 | * of IP addresses returned to us by purple_dnsquery_a() and attemps |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
2081 | * to connect to each one. This is called after the hostname is |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2082 | * resolved, and each time a connection attempt fails (assuming there |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2083 | * is another IP address to try). |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
2084 | */ |
|
23352
9714223ca7a7
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
23234
diff
changeset
|
2085 | #ifndef INET6_ADDRSTRLEN |
|
9714223ca7a7
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
23234
diff
changeset
|
2086 | #define INET6_ADDRSTRLEN 46 |
|
9714223ca7a7
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
23234
diff
changeset
|
2087 | #endif |
|
9714223ca7a7
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
23234
diff
changeset
|
2088 | |
| 15884 | 2089 | static void try_connect(PurpleProxyConnectData *connect_data) |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
2090 | { |
| 25623 | 2091 | socklen_t addrlen; |
| 4678 | 2092 | struct sockaddr *addr; |
|
14965
8051becb91fe
[gaim-migrate @ 17675]
Mark Doliner <markdoliner@pidgin.im>
parents:
14899
diff
changeset
|
2093 | char ipaddr[INET6_ADDRSTRLEN]; |
| 4634 | 2094 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2095 | addrlen = GPOINTER_TO_INT(connect_data->hosts->data); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2096 | connect_data->hosts = g_slist_remove(connect_data->hosts, connect_data->hosts->data); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2097 | addr = connect_data->hosts->data; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2098 | connect_data->hosts = g_slist_remove(connect_data->hosts, connect_data->hosts->data); |
|
23352
9714223ca7a7
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
23234
diff
changeset
|
2099 | #ifdef HAVE_INET_NTOP |
|
14965
8051becb91fe
[gaim-migrate @ 17675]
Mark Doliner <markdoliner@pidgin.im>
parents:
14899
diff
changeset
|
2100 | inet_ntop(addr->sa_family, &((struct sockaddr_in *)addr)->sin_addr, |
|
8051becb91fe
[gaim-migrate @ 17675]
Mark Doliner <markdoliner@pidgin.im>
parents:
14899
diff
changeset
|
2101 | ipaddr, sizeof(ipaddr)); |
|
23352
9714223ca7a7
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
23234
diff
changeset
|
2102 | #else |
| 25623 | 2103 | memcpy(ipaddr, inet_ntoa(((struct sockaddr_in *)addr)->sin_addr), |
|
23352
9714223ca7a7
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
23234
diff
changeset
|
2104 | sizeof(ipaddr)); |
|
9714223ca7a7
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
23234
diff
changeset
|
2105 | #endif |
| 15884 | 2106 | purple_debug_info("proxy", "Attempting connection to %s\n", ipaddr); |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
2107 | |
|
27249
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2108 | if (connect_data->socket_type == SOCK_DGRAM) { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2109 | proxy_connect_udp_none(connect_data, addr, addrlen); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2110 | g_free(addr); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2111 | return; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2112 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2113 | |
| 15884 | 2114 | switch (purple_proxy_info_get_type(connect_data->gpi)) { |
| 2115 | case PURPLE_PROXY_NONE: | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2116 | proxy_connect_none(connect_data, addr, addrlen); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2117 | break; |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2118 | |
| 15884 | 2119 | case PURPLE_PROXY_HTTP: |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2120 | proxy_connect_http(connect_data, addr, addrlen); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2121 | break; |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2122 | |
| 15884 | 2123 | case PURPLE_PROXY_SOCKS4: |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2124 | proxy_connect_socks4(connect_data, addr, addrlen); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2125 | break; |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2126 | |
| 15884 | 2127 | case PURPLE_PROXY_SOCKS5: |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2128 | proxy_connect_socks5(connect_data, addr, addrlen); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2129 | break; |
|
6621
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6320
diff
changeset
|
2130 | |
| 15884 | 2131 | case PURPLE_PROXY_USE_ENVVAR: |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2132 | proxy_connect_http(connect_data, addr, addrlen); |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2133 | break; |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2134 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2135 | default: |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
2136 | break; |
| 4678 | 2137 | } |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2138 | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2139 | g_free(addr); |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
2140 | } |
|
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
2141 | |
| 9129 | 2142 | static void |
| 2143 | connection_host_resolved(GSList *hosts, gpointer data, | |
| 2144 | const char *error_message) | |
| 2145 | { | |
| 15884 | 2146 | PurpleProxyConnectData *connect_data; |
| 9129 | 2147 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2148 | connect_data = data; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2149 | connect_data->query_data = NULL; |
|
14300
68a0aa63f3b8
[gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
2150 | |
|
14161
e959d0e476be
[gaim-migrate @ 16728]
Mark Doliner <markdoliner@pidgin.im>
parents:
14159
diff
changeset
|
2151 | if (error_message != NULL) |
|
e959d0e476be
[gaim-migrate @ 16728]
Mark Doliner <markdoliner@pidgin.im>
parents:
14159
diff
changeset
|
2152 | { |
| 15884 | 2153 | purple_proxy_connect_data_disconnect(connect_data, error_message); |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2154 | return; |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2155 | } |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2156 | |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2157 | if (hosts == NULL) |
|
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2158 | { |
| 15884 | 2159 | purple_proxy_connect_data_disconnect(connect_data, _("Could not resolve host name")); |
|
14300
68a0aa63f3b8
[gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
2160 | return; |
|
14161
e959d0e476be
[gaim-migrate @ 16728]
Mark Doliner <markdoliner@pidgin.im>
parents:
14159
diff
changeset
|
2161 | } |
|
e959d0e476be
[gaim-migrate @ 16728]
Mark Doliner <markdoliner@pidgin.im>
parents:
14159
diff
changeset
|
2162 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2163 | connect_data->hosts = hosts; |
| 9129 | 2164 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2165 | try_connect(connect_data); |
| 9129 | 2166 | } |
| 2167 | ||
| 15884 | 2168 | PurpleProxyInfo * |
| 2169 | purple_proxy_get_setup(PurpleAccount *account) | |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
2170 | { |
| 15884 | 2171 | PurpleProxyInfo *gpi = NULL; |
|
6621
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6320
diff
changeset
|
2172 | const gchar *tmp; |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2173 | |
|
15032
65a111aba7a8
[gaim-migrate @ 17749]
Daniel Atallah <datallah@pidgin.im>
parents:
15015
diff
changeset
|
2174 | /* This is used as a fallback so we don't overwrite the selected proxy type */ |
| 15884 | 2175 | static PurpleProxyInfo *tmp_none_proxy_info = NULL; |
|
15032
65a111aba7a8
[gaim-migrate @ 17749]
Daniel Atallah <datallah@pidgin.im>
parents:
15015
diff
changeset
|
2176 | if (!tmp_none_proxy_info) { |
| 15884 | 2177 | tmp_none_proxy_info = purple_proxy_info_new(); |
| 2178 | purple_proxy_info_set_type(tmp_none_proxy_info, PURPLE_PROXY_NONE); | |
|
15032
65a111aba7a8
[gaim-migrate @ 17749]
Daniel Atallah <datallah@pidgin.im>
parents:
15015
diff
changeset
|
2179 | } |
|
65a111aba7a8
[gaim-migrate @ 17749]
Daniel Atallah <datallah@pidgin.im>
parents:
15015
diff
changeset
|
2180 | |
| 15884 | 2181 | if (account && purple_account_get_proxy_info(account) != NULL) { |
| 2182 | gpi = purple_account_get_proxy_info(account); | |
| 2183 | if (purple_proxy_info_get_type(gpi) == PURPLE_PROXY_USE_GLOBAL) | |
|
15041
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2184 | gpi = NULL; |
|
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2185 | } |
|
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2186 | if (gpi == NULL) { |
| 15884 | 2187 | if (purple_running_gnome()) |
| 2188 | gpi = purple_gnome_proxy_get_info(); | |
|
15041
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2189 | else |
| 15884 | 2190 | gpi = purple_global_proxy_get_info(); |
|
15041
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2191 | } |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2192 | |
| 15884 | 2193 | if (purple_proxy_info_get_type(gpi) == PURPLE_PROXY_USE_ENVVAR) { |
|
6621
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6320
diff
changeset
|
2194 | if ((tmp = g_getenv("HTTP_PROXY")) != NULL || |
|
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6320
diff
changeset
|
2195 | (tmp = g_getenv("http_proxy")) != NULL || |
|
10534
c28eef1b882a
[gaim-migrate @ 11866]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10320
diff
changeset
|
2196 | (tmp = g_getenv("HTTPPROXY")) != NULL) { |
|
15032
65a111aba7a8
[gaim-migrate @ 17749]
Daniel Atallah <datallah@pidgin.im>
parents:
15015
diff
changeset
|
2197 | char *proxyhost, *proxyuser, *proxypasswd; |
|
7652
d60ba2565661
[gaim-migrate @ 8296]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7475
diff
changeset
|
2198 | int proxyport; |
|
6621
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6320
diff
changeset
|
2199 | |
| 9129 | 2200 | /* http_proxy-format: |
| 9227 | 2201 | * export http_proxy="http://user:passwd@your.proxy.server:port/" |
|
7652
d60ba2565661
[gaim-migrate @ 8296]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7475
diff
changeset
|
2202 | */ |
| 15884 | 2203 | if(purple_url_parse(tmp, &proxyhost, &proxyport, NULL, &proxyuser, &proxypasswd)) { |
| 2204 | purple_proxy_info_set_host(gpi, proxyhost); | |
|
7652
d60ba2565661
[gaim-migrate @ 8296]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7475
diff
changeset
|
2205 | g_free(proxyhost); |
|
15032
65a111aba7a8
[gaim-migrate @ 17749]
Daniel Atallah <datallah@pidgin.im>
parents:
15015
diff
changeset
|
2206 | |
| 15884 | 2207 | purple_proxy_info_set_username(gpi, proxyuser); |
|
15032
65a111aba7a8
[gaim-migrate @ 17749]
Daniel Atallah <datallah@pidgin.im>
parents:
15015
diff
changeset
|
2208 | g_free(proxyuser); |
|
65a111aba7a8
[gaim-migrate @ 17749]
Daniel Atallah <datallah@pidgin.im>
parents:
15015
diff
changeset
|
2209 | |
| 15884 | 2210 | purple_proxy_info_set_password(gpi, proxypasswd); |
|
15032
65a111aba7a8
[gaim-migrate @ 17749]
Daniel Atallah <datallah@pidgin.im>
parents:
15015
diff
changeset
|
2211 | g_free(proxypasswd); |
|
7652
d60ba2565661
[gaim-migrate @ 8296]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7475
diff
changeset
|
2212 | |
|
d60ba2565661
[gaim-migrate @ 8296]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7475
diff
changeset
|
2213 | /* only for backward compatibility */ |
| 9129 | 2214 | if (proxyport == 80 && |
|
7652
d60ba2565661
[gaim-migrate @ 8296]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7475
diff
changeset
|
2215 | ((tmp = g_getenv("HTTP_PROXY_PORT")) != NULL || |
|
d60ba2565661
[gaim-migrate @ 8296]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7475
diff
changeset
|
2216 | (tmp = g_getenv("http_proxy_port")) != NULL || |
|
d60ba2565661
[gaim-migrate @ 8296]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7475
diff
changeset
|
2217 | (tmp = g_getenv("HTTPPROXYPORT")) != NULL)) |
|
15032
65a111aba7a8
[gaim-migrate @ 17749]
Daniel Atallah <datallah@pidgin.im>
parents:
15015
diff
changeset
|
2218 | proxyport = atoi(tmp); |
| 9129 | 2219 | |
| 15884 | 2220 | purple_proxy_info_set_port(gpi, proxyport); |
|
15041
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2221 | |
|
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2222 | /* XXX: Do we want to skip this step if user/password were part of url? */ |
|
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2223 | if ((tmp = g_getenv("HTTP_PROXY_USER")) != NULL || |
|
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2224 | (tmp = g_getenv("http_proxy_user")) != NULL || |
|
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2225 | (tmp = g_getenv("HTTPPROXYUSER")) != NULL) |
| 15884 | 2226 | purple_proxy_info_set_username(gpi, tmp); |
|
15041
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2227 | |
|
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2228 | if ((tmp = g_getenv("HTTP_PROXY_PASS")) != NULL || |
|
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2229 | (tmp = g_getenv("http_proxy_pass")) != NULL || |
|
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2230 | (tmp = g_getenv("HTTPPROXYPASS")) != NULL) |
| 15884 | 2231 | purple_proxy_info_set_password(gpi, tmp); |
|
15041
18a6f6cdce33
[gaim-migrate @ 17758]
Daniel Atallah <datallah@pidgin.im>
parents:
15032
diff
changeset
|
2232 | |
|
7652
d60ba2565661
[gaim-migrate @ 8296]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7475
diff
changeset
|
2233 | } |
|
10534
c28eef1b882a
[gaim-migrate @ 11866]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10320
diff
changeset
|
2234 | } else { |
|
24171
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
2235 | #ifdef _WIN32 |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
2236 | PurpleProxyInfo *wgpi; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
2237 | if ((wgpi = purple_win32_proxy_get_info()) != NULL) |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
2238 | return wgpi; |
|
d976cc3db118
Add support for reading SOCKS proxy information from the Windows proxy settings.
Daniel Atallah <datallah@pidgin.im>
parents:
24156
diff
changeset
|
2239 | #endif |
|
10534
c28eef1b882a
[gaim-migrate @ 11866]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10320
diff
changeset
|
2240 | /* no proxy environment variable found, don't use a proxy */ |
| 15884 | 2241 | purple_debug_info("proxy", "No environment settings found, not using a proxy\n"); |
|
15032
65a111aba7a8
[gaim-migrate @ 17749]
Daniel Atallah <datallah@pidgin.im>
parents:
15015
diff
changeset
|
2242 | gpi = tmp_none_proxy_info; |
|
6621
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6320
diff
changeset
|
2243 | } |
|
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6320
diff
changeset
|
2244 | |
|
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6320
diff
changeset
|
2245 | } |
|
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6320
diff
changeset
|
2246 | |
| 13515 | 2247 | return gpi; |
| 2248 | } | |
| 2249 | ||
| 15884 | 2250 | PurpleProxyConnectData * |
| 2251 | purple_proxy_connect(void *handle, PurpleAccount *account, | |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2252 | const char *host, int port, |
| 15884 | 2253 | PurpleProxyConnectFunction connect_cb, gpointer data) |
| 13515 | 2254 | { |
| 2255 | const char *connecthost = host; | |
| 2256 | int connectport = port; | |
| 15884 | 2257 | PurpleProxyConnectData *connect_data; |
| 13515 | 2258 | |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2259 | g_return_val_if_fail(host != NULL, NULL); |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2260 | g_return_val_if_fail(port > 0, NULL); |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2261 | g_return_val_if_fail(connect_cb != NULL, NULL); |
| 13515 | 2262 | |
| 15884 | 2263 | connect_data = g_new0(PurpleProxyConnectData, 1); |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2264 | connect_data->fd = -1; |
|
27249
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2265 | connect_data->socket_type = SOCK_STREAM; |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2266 | connect_data->handle = handle; |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2267 | connect_data->connect_cb = connect_cb; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2268 | connect_data->data = data; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2269 | connect_data->host = g_strdup(host); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2270 | connect_data->port = port; |
| 15884 | 2271 | connect_data->gpi = purple_proxy_get_setup(account); |
| 13515 | 2272 | |
| 15884 | 2273 | if ((purple_proxy_info_get_type(connect_data->gpi) != PURPLE_PROXY_NONE) && |
| 2274 | (purple_proxy_info_get_host(connect_data->gpi) == NULL || | |
| 2275 | purple_proxy_info_get_port(connect_data->gpi) <= 0)) { | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2276 | |
| 15884 | 2277 | purple_notify_error(NULL, NULL, _("Invalid proxy settings"), _("Either the host name or port number specified for your given proxy type is invalid.")); |
| 2278 | purple_proxy_connect_data_destroy(connect_data); | |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2279 | return NULL; |
|
1840
770bc15f419c
[gaim-migrate @ 1850]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1705
diff
changeset
|
2280 | } |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
2281 | |
| 15884 | 2282 | switch (purple_proxy_info_get_type(connect_data->gpi)) |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
2283 | { |
| 15884 | 2284 | case PURPLE_PROXY_NONE: |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
2285 | break; |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2286 | |
| 15884 | 2287 | case PURPLE_PROXY_HTTP: |
| 2288 | case PURPLE_PROXY_SOCKS4: | |
| 2289 | case PURPLE_PROXY_SOCKS5: | |
| 2290 | case PURPLE_PROXY_USE_ENVVAR: | |
| 2291 | connecthost = purple_proxy_info_get_host(connect_data->gpi); | |
| 2292 | connectport = purple_proxy_info_get_port(connect_data->gpi); | |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
2293 | break; |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2294 | |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
2295 | default: |
|
24491
70d99d66cceb
Add debug output when proxy configuration issues are seen. This will help to
Daniel Atallah <datallah@pidgin.im>
parents:
24316
diff
changeset
|
2296 | purple_debug_error("proxy", "Invalid Proxy type (%d) specified.\n", |
|
70d99d66cceb
Add debug output when proxy configuration issues are seen. This will help to
Daniel Atallah <datallah@pidgin.im>
parents:
24316
diff
changeset
|
2297 | purple_proxy_info_get_type(connect_data->gpi)); |
| 15884 | 2298 | purple_proxy_connect_data_destroy(connect_data); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2299 | return NULL; |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2300 | } |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2301 | |
| 15884 | 2302 | connect_data->query_data = purple_dnsquery_a(connecthost, |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2303 | connectport, connection_host_resolved, connect_data); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2304 | if (connect_data->query_data == NULL) |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2305 | { |
|
24491
70d99d66cceb
Add debug output when proxy configuration issues are seen. This will help to
Daniel Atallah <datallah@pidgin.im>
parents:
24316
diff
changeset
|
2306 | purple_debug_error("proxy", "dns query failed unexpectedly.\n"); |
| 15884 | 2307 | purple_proxy_connect_data_destroy(connect_data); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2308 | return NULL; |
|
4366
d2b52a5ff6fc
[gaim-migrate @ 4632]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
3867
diff
changeset
|
2309 | } |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2310 | |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2311 | handles = g_slist_prepend(handles, connect_data); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2312 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2313 | return connect_data; |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2314 | } |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2315 | |
|
27249
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2316 | PurpleProxyConnectData * |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2317 | purple_proxy_connect_udp(void *handle, PurpleAccount *account, |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2318 | const char *host, int port, |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2319 | PurpleProxyConnectFunction connect_cb, gpointer data) |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2320 | { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2321 | const char *connecthost = host; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2322 | int connectport = port; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2323 | PurpleProxyConnectData *connect_data; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2324 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2325 | g_return_val_if_fail(host != NULL, NULL); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2326 | g_return_val_if_fail(port > 0, NULL); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2327 | g_return_val_if_fail(connect_cb != NULL, NULL); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2328 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2329 | connect_data = g_new0(PurpleProxyConnectData, 1); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2330 | connect_data->fd = -1; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2331 | connect_data->socket_type = SOCK_DGRAM; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2332 | connect_data->handle = handle; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2333 | connect_data->connect_cb = connect_cb; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2334 | connect_data->data = data; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2335 | connect_data->host = g_strdup(host); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2336 | connect_data->port = port; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2337 | connect_data->gpi = purple_proxy_get_setup(account); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2338 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2339 | if ((purple_proxy_info_get_type(connect_data->gpi) != PURPLE_PROXY_NONE) && |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2340 | (purple_proxy_info_get_host(connect_data->gpi) == NULL || |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2341 | purple_proxy_info_get_port(connect_data->gpi) <= 0)) { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2342 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2343 | purple_notify_error(NULL, NULL, _("Invalid proxy settings"), _("Either the host name or port number specified for your given proxy type is invalid.")); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2344 | purple_proxy_connect_data_destroy(connect_data); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2345 | return NULL; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2346 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2347 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2348 | switch (purple_proxy_info_get_type(connect_data->gpi)) |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2349 | { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2350 | case PURPLE_PROXY_NONE: |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2351 | break; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2352 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2353 | case PURPLE_PROXY_HTTP: |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2354 | case PURPLE_PROXY_SOCKS4: |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2355 | case PURPLE_PROXY_SOCKS5: |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2356 | case PURPLE_PROXY_USE_ENVVAR: |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2357 | purple_debug_info("proxy", "Ignoring Proxy type (%d) for UDP.\n", |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2358 | purple_proxy_info_get_type(connect_data->gpi)); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2359 | break; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2360 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2361 | default: |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2362 | purple_debug_error("proxy", "Invalid Proxy type (%d) specified.\n", |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2363 | purple_proxy_info_get_type(connect_data->gpi)); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2364 | purple_proxy_connect_data_destroy(connect_data); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2365 | return NULL; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2366 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2367 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2368 | connect_data->query_data = purple_dnsquery_a(connecthost, |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2369 | connectport, connection_host_resolved, connect_data); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2370 | if (connect_data->query_data == NULL) |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2371 | { |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2372 | purple_proxy_connect_data_destroy(connect_data); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2373 | return NULL; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2374 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2375 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2376 | handles = g_slist_prepend(handles, connect_data); |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2377 | |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2378 | return connect_data; |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2379 | } |
|
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2380 | |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2381 | /* |
| 15884 | 2382 | * Combine some of this code with purple_proxy_connect() |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2383 | */ |
| 15884 | 2384 | PurpleProxyConnectData * |
| 2385 | purple_proxy_connect_socks5(void *handle, PurpleProxyInfo *gpi, | |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2386 | const char *host, int port, |
| 15884 | 2387 | PurpleProxyConnectFunction connect_cb, |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2388 | gpointer data) |
| 8262 | 2389 | { |
| 15884 | 2390 | PurpleProxyConnectData *connect_data; |
| 8262 | 2391 | |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2392 | g_return_val_if_fail(host != NULL, NULL); |
| 15015 | 2393 | g_return_val_if_fail(port >= 0, NULL); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2394 | g_return_val_if_fail(connect_cb != NULL, NULL); |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2395 | |
| 15884 | 2396 | connect_data = g_new0(PurpleProxyConnectData, 1); |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2397 | connect_data->fd = -1; |
|
27249
3f5b531ae0b3
Add purple_proxy_connect_udp. Closes #6589.
Hu Yong <ccpaging@gmail.com>
parents:
25911
diff
changeset
|
2398 | connect_data->socket_type = SOCK_STREAM; |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2399 | connect_data->handle = handle; |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2400 | connect_data->connect_cb = connect_cb; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2401 | connect_data->data = data; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2402 | connect_data->host = g_strdup(host); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2403 | connect_data->port = port; |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2404 | connect_data->gpi = gpi; |
| 8262 | 2405 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2406 | connect_data->query_data = |
| 15884 | 2407 | purple_dnsquery_a(purple_proxy_info_get_host(gpi), |
| 2408 | purple_proxy_info_get_port(gpi), | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2409 | connection_host_resolved, connect_data); |
|
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2410 | if (connect_data->query_data == NULL) |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2411 | { |
| 15884 | 2412 | purple_proxy_connect_data_destroy(connect_data); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2413 | return NULL; |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2414 | } |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2415 | |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2416 | handles = g_slist_prepend(handles, connect_data); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2417 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14300
diff
changeset
|
2418 | return connect_data; |
| 8262 | 2419 | } |
| 2420 | ||
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
2421 | void |
| 15884 | 2422 | purple_proxy_connect_cancel(PurpleProxyConnectData *connect_data) |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
2423 | { |
| 15884 | 2424 | purple_proxy_connect_data_disconnect(connect_data, NULL); |
| 2425 | purple_proxy_connect_data_destroy(connect_data); | |
|
14165
0f09ac2220f4
[gaim-migrate @ 16734]
Mark Doliner <markdoliner@pidgin.im>
parents:
14161
diff
changeset
|
2426 | } |
| 8262 | 2427 | |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2428 | void |
| 15884 | 2429 | purple_proxy_connect_cancel_with_handle(void *handle) |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2430 | { |
|
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2431 | GSList *l, *l_next; |
|
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2432 | |
|
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2433 | for (l = handles; l != NULL; l = l_next) { |
| 15884 | 2434 | PurpleProxyConnectData *connect_data = l->data; |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2435 | |
|
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2436 | l_next = l->next; |
|
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2437 | |
|
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2438 | if (connect_data->handle == handle) |
| 15884 | 2439 | purple_proxy_connect_cancel(connect_data); |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2440 | } |
|
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2441 | } |
|
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2442 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2443 | static void |
| 15884 | 2444 | proxy_pref_cb(const char *name, PurplePrefType type, |
|
12816
5f93e09fa9a6
[gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents:
12811
diff
changeset
|
2445 | gconstpointer value, gpointer data) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2446 | { |
| 15884 | 2447 | PurpleProxyInfo *info = purple_global_proxy_get_info(); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2448 | |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
2449 | if (purple_strequal(name, "/purple/proxy/type")) { |
|
6001
1abbeff6571c
[gaim-migrate @ 6449]
Mark Doliner <markdoliner@pidgin.im>
parents:
5970
diff
changeset
|
2450 | int proxytype; |
|
12816
5f93e09fa9a6
[gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents:
12811
diff
changeset
|
2451 | const char *type = value; |
|
6001
1abbeff6571c
[gaim-migrate @ 6449]
Mark Doliner <markdoliner@pidgin.im>
parents:
5970
diff
changeset
|
2452 | |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
2453 | if (purple_strequal(type, "none")) |
| 15884 | 2454 | proxytype = PURPLE_PROXY_NONE; |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
2455 | else if (purple_strequal(type, "http")) |
| 15884 | 2456 | proxytype = PURPLE_PROXY_HTTP; |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
2457 | else if (purple_strequal(type, "socks4")) |
| 15884 | 2458 | proxytype = PURPLE_PROXY_SOCKS4; |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
2459 | else if (purple_strequal(type, "socks5")) |
| 15884 | 2460 | proxytype = PURPLE_PROXY_SOCKS5; |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
2461 | else if (purple_strequal(type, "envvar")) |
| 15884 | 2462 | proxytype = PURPLE_PROXY_USE_ENVVAR; |
|
6001
1abbeff6571c
[gaim-migrate @ 6449]
Mark Doliner <markdoliner@pidgin.im>
parents:
5970
diff
changeset
|
2463 | else |
|
1abbeff6571c
[gaim-migrate @ 6449]
Mark Doliner <markdoliner@pidgin.im>
parents:
5970
diff
changeset
|
2464 | proxytype = -1; |
|
1abbeff6571c
[gaim-migrate @ 6449]
Mark Doliner <markdoliner@pidgin.im>
parents:
5970
diff
changeset
|
2465 | |
| 15884 | 2466 | purple_proxy_info_set_type(info, proxytype); |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
2467 | } else if (purple_strequal(name, "/purple/proxy/host")) |
| 15884 | 2468 | purple_proxy_info_set_host(info, value); |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
2469 | else if (purple_strequal(name, "/purple/proxy/port")) |
| 15884 | 2470 | purple_proxy_info_set_port(info, GPOINTER_TO_INT(value)); |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
2471 | else if (purple_strequal(name, "/purple/proxy/username")) |
| 15884 | 2472 | purple_proxy_info_set_username(info, value); |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24866
diff
changeset
|
2473 | else if (purple_strequal(name, "/purple/proxy/password")) |
| 15884 | 2474 | purple_proxy_info_set_password(info, value); |
|
1087
bc9c6b635358
[gaim-migrate @ 1097]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1057
diff
changeset
|
2475 | } |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2476 | |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2477 | void * |
| 15884 | 2478 | purple_proxy_get_handle() |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2479 | { |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2480 | static int handle; |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2481 | |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2482 | return &handle; |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2483 | } |
|
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2484 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2485 | void |
| 15884 | 2486 | purple_proxy_init(void) |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2487 | { |
|
10087
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9863
diff
changeset
|
2488 | void *handle; |
|
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9863
diff
changeset
|
2489 | |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2490 | /* Initialize a default proxy info struct. */ |
| 15884 | 2491 | global_proxy_info = purple_proxy_info_new(); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2492 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2493 | /* Proxy */ |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16037
diff
changeset
|
2494 | purple_prefs_add_none("/purple/proxy"); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16037
diff
changeset
|
2495 | purple_prefs_add_string("/purple/proxy/type", "none"); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16037
diff
changeset
|
2496 | purple_prefs_add_string("/purple/proxy/host", ""); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16037
diff
changeset
|
2497 | purple_prefs_add_int("/purple/proxy/port", 0); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16037
diff
changeset
|
2498 | purple_prefs_add_string("/purple/proxy/username", ""); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16037
diff
changeset
|
2499 | purple_prefs_add_string("/purple/proxy/password", ""); |
|
25624
62b56bc39896
Implement support for resolving DNS via the SOCKS4 proxy in use.
Daniel Atallah <datallah@pidgin.im>
parents:
25623
diff
changeset
|
2500 | purple_prefs_add_bool("/purple/proxy/socks4_remotedns", FALSE); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2501 | |
|
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2502 | /* Setup callbacks for the preferences. */ |
| 15884 | 2503 | handle = purple_proxy_get_handle(); |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16037
diff
changeset
|
2504 | purple_prefs_connect_callback(handle, "/purple/proxy/type", proxy_pref_cb, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
2505 | NULL); |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16037
diff
changeset
|
2506 | purple_prefs_connect_callback(handle, "/purple/proxy/host", proxy_pref_cb, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
2507 | NULL); |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16037
diff
changeset
|
2508 | purple_prefs_connect_callback(handle, "/purple/proxy/port", proxy_pref_cb, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
2509 | NULL); |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16037
diff
changeset
|
2510 | purple_prefs_connect_callback(handle, "/purple/proxy/username", |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
2511 | proxy_pref_cb, NULL); |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16037
diff
changeset
|
2512 | purple_prefs_connect_callback(handle, "/purple/proxy/password", |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13085
diff
changeset
|
2513 | proxy_pref_cb, NULL); |
|
20053
68ce40196f8a
grab revision 6be36979d022284283217c2a32f2b812740cbbf3
Luke Schierer <lschiere@pidgin.im>
parents:
19985
diff
changeset
|
2514 | |
|
68ce40196f8a
grab revision 6be36979d022284283217c2a32f2b812740cbbf3
Luke Schierer <lschiere@pidgin.im>
parents:
19985
diff
changeset
|
2515 | /* Load the initial proxy settings */ |
|
20055
ca7144d5605f
grab revision 240d37f3b465527200f862ff3c0da77618ae32ae
Luke Schierer <lschiere@pidgin.im>
parents:
20053
diff
changeset
|
2516 | purple_prefs_trigger_callback("/purple/proxy/type"); |
|
ca7144d5605f
grab revision 240d37f3b465527200f862ff3c0da77618ae32ae
Luke Schierer <lschiere@pidgin.im>
parents:
20053
diff
changeset
|
2517 | purple_prefs_trigger_callback("/purple/proxy/host"); |
|
ca7144d5605f
grab revision 240d37f3b465527200f862ff3c0da77618ae32ae
Luke Schierer <lschiere@pidgin.im>
parents:
20053
diff
changeset
|
2518 | purple_prefs_trigger_callback("/purple/proxy/port"); |
|
ca7144d5605f
grab revision 240d37f3b465527200f862ff3c0da77618ae32ae
Luke Schierer <lschiere@pidgin.im>
parents:
20053
diff
changeset
|
2519 | purple_prefs_trigger_callback("/purple/proxy/username"); |
|
ca7144d5605f
grab revision 240d37f3b465527200f862ff3c0da77618ae32ae
Luke Schierer <lschiere@pidgin.im>
parents:
20053
diff
changeset
|
2520 | purple_prefs_trigger_callback("/purple/proxy/password"); |
|
5681
514fbc5374dc
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2521 | } |
|
10087
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9863
diff
changeset
|
2522 | |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
2523 | void |
| 15884 | 2524 | purple_proxy_uninit(void) |
|
10087
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9863
diff
changeset
|
2525 | { |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14536
diff
changeset
|
2526 | while (handles != NULL) |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2527 | { |
| 15884 | 2528 | purple_proxy_connect_data_disconnect(handles->data, NULL); |
| 2529 | purple_proxy_connect_data_destroy(handles->data); | |
|
14513
fe63cd247350
[gaim-migrate @ 17165]
Mark Doliner <markdoliner@pidgin.im>
parents:
14454
diff
changeset
|
2530 | } |
|
10087
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9863
diff
changeset
|
2531 | } |