Mercurial > pidgin
comparison libpurple/proxy.c @ 32317:d72f2f13b60f
merge of 'c8c73eea7431e6f940916315ace40a41c8da3faa'
and 'fec428131bde0ae8247941bd6a3d996c984c9189'
| author | Ethan Blanton <elb@pidgin.im> |
|---|---|
| date | Fri, 21 Oct 2011 14:36:18 +0000 |
| parents | 06e0b6be6432 |
| children | f07501af8bae |
comparison
equal
deleted
inserted
replaced
| 32316:14787acaf9d7 | 32317:d72f2f13b60f |
|---|---|
| 39 #include "ntlm.h" | 39 #include "ntlm.h" |
| 40 #include "prefs.h" | 40 #include "prefs.h" |
| 41 #include "proxy.h" | 41 #include "proxy.h" |
| 42 #include "util.h" | 42 #include "util.h" |
| 43 | 43 |
| 44 struct _PurpleProxyInfo | |
| 45 { | |
| 46 PurpleProxyType type; /**< The proxy type. */ | |
| 47 | |
| 48 char *host; /**< The host. */ | |
| 49 int port; /**< The port number. */ | |
| 50 char *username; /**< The username. */ | |
| 51 char *password; /**< The password. */ | |
| 52 }; | |
| 53 | |
| 44 struct _PurpleProxyConnectData { | 54 struct _PurpleProxyConnectData { |
| 45 void *handle; | 55 void *handle; |
| 46 PurpleProxyConnectFunction connect_cb; | 56 PurpleProxyConnectFunction connect_cb; |
| 47 gpointer data; | 57 gpointer data; |
| 48 gchar *host; | 58 gchar *host; |
| 1367 | 1377 |
| 1368 connect_data->inpa = purple_input_add(connect_data->fd, PURPLE_INPUT_WRITE, proxy_do_write, connect_data); | 1378 connect_data->inpa = purple_input_add(connect_data->fd, PURPLE_INPUT_WRITE, proxy_do_write, connect_data); |
| 1369 | 1379 |
| 1370 proxy_do_write(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); | 1380 proxy_do_write(connect_data, connect_data->fd, PURPLE_INPUT_WRITE); |
| 1371 } else { | 1381 } else { |
| 1372 connect_data->query_data = purple_dnsquery_a_account( | 1382 connect_data->query_data = purple_dnsquery_a( |
| 1373 connect_data->account, connect_data->host, | 1383 connect_data->account, connect_data->host, |
| 1374 connect_data->port, s4_host_resolved, connect_data); | 1384 connect_data->port, s4_host_resolved, connect_data); |
| 1375 | 1385 |
| 1376 if (connect_data->query_data == NULL) { | 1386 if (connect_data->query_data == NULL) { |
| 1377 purple_debug_error("proxy", "dns query failed unexpectedly.\n"); | 1387 purple_debug_error("proxy", "dns query failed unexpectedly.\n"); |
| 2086 } | 2096 } |
| 2087 } | 2097 } |
| 2088 | 2098 |
| 2089 /** | 2099 /** |
| 2090 * This function attempts to connect to the next IP address in the list | 2100 * This function attempts to connect to the next IP address in the list |
| 2091 * of IP addresses returned to us by purple_dnsquery_a() and attemps | 2101 * of IP addresses returned to us by purple_dnsquery_a() and attempts |
| 2092 * to connect to each one. This is called after the hostname is | 2102 * to connect to each one. This is called after the hostname is |
| 2093 * resolved, and each time a connection attempt fails (assuming there | 2103 * resolved, and each time a connection attempt fails (assuming there |
| 2094 * is another IP address to try). | 2104 * is another IP address to try). |
| 2095 */ | 2105 */ |
| 2096 #ifndef INET6_ADDRSTRLEN | 2106 #ifndef INET6_ADDRSTRLEN |
| 2315 purple_proxy_info_get_type(connect_data->gpi)); | 2325 purple_proxy_info_get_type(connect_data->gpi)); |
| 2316 purple_proxy_connect_data_destroy(connect_data); | 2326 purple_proxy_connect_data_destroy(connect_data); |
| 2317 return NULL; | 2327 return NULL; |
| 2318 } | 2328 } |
| 2319 | 2329 |
| 2320 connect_data->query_data = purple_dnsquery_a_account(account, connecthost, | 2330 connect_data->query_data = purple_dnsquery_a(account, connecthost, |
| 2321 connectport, connection_host_resolved, connect_data); | 2331 connectport, connection_host_resolved, connect_data); |
| 2322 if (connect_data->query_data == NULL) | 2332 if (connect_data->query_data == NULL) |
| 2323 { | 2333 { |
| 2324 purple_debug_error("proxy", "dns query failed unexpectedly.\n"); | 2334 purple_debug_error("proxy", "dns query failed unexpectedly.\n"); |
| 2325 purple_proxy_connect_data_destroy(connect_data); | 2335 purple_proxy_connect_data_destroy(connect_data); |
| 2383 purple_proxy_info_get_type(connect_data->gpi)); | 2393 purple_proxy_info_get_type(connect_data->gpi)); |
| 2384 purple_proxy_connect_data_destroy(connect_data); | 2394 purple_proxy_connect_data_destroy(connect_data); |
| 2385 return NULL; | 2395 return NULL; |
| 2386 } | 2396 } |
| 2387 | 2397 |
| 2388 connect_data->query_data = purple_dnsquery_a_account(account, connecthost, | 2398 connect_data->query_data = purple_dnsquery_a(account, connecthost, |
| 2389 connectport, connection_host_resolved, connect_data); | 2399 connectport, connection_host_resolved, connect_data); |
| 2390 if (connect_data->query_data == NULL) | 2400 if (connect_data->query_data == NULL) |
| 2391 { | 2401 { |
| 2392 purple_proxy_connect_data_destroy(connect_data); | 2402 purple_proxy_connect_data_destroy(connect_data); |
| 2393 return NULL; | 2403 return NULL; |
| 2395 | 2405 |
| 2396 handles = g_slist_prepend(handles, connect_data); | 2406 handles = g_slist_prepend(handles, connect_data); |
| 2397 | 2407 |
| 2398 return connect_data; | 2408 return connect_data; |
| 2399 } | 2409 } |
| 2400 | |
| 2401 PurpleProxyConnectData * | |
| 2402 purple_proxy_connect_socks5(void *handle, PurpleProxyInfo *gpi, | |
| 2403 const char *host, int port, | |
| 2404 PurpleProxyConnectFunction connect_cb, | |
| 2405 gpointer data) | |
| 2406 { | |
| 2407 return purple_proxy_connect_socks5_account(NULL, handle, gpi, | |
| 2408 host, port, connect_cb, data); | |
| 2409 } | |
| 2410 | |
| 2411 | 2410 |
| 2412 /* This is called when we connect to the SOCKS5 proxy server (through any | 2411 /* This is called when we connect to the SOCKS5 proxy server (through any |
| 2413 * relevant account proxy) | 2412 * relevant account proxy) |
| 2414 */ | 2413 */ |
| 2415 static void socks5_connected_to_proxy(gpointer data, gint source, | 2414 static void socks5_connected_to_proxy(gpointer data, gint source, |
