Mercurial > pidgin.yaz
comparison libpurple/dnsquery.c @ 31930:0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Combined with the new "Tor/Privacy" proxy setting, this allows us to prevent
DNS lookups when the user has selected a proxy that they may want to use to
for privacy.
Refs #11110
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 19 Apr 2011 04:58:17 +0000 |
parents | 68a1efda3654 |
children | 92f3d821653f |
comparison
equal
deleted
inserted
replaced
31929:9a7c5d242521 | 31930:0eceb1304f53 |
---|---|
52 char *hostname; | 52 char *hostname; |
53 int port; | 53 int port; |
54 PurpleDnsQueryConnectFunction callback; | 54 PurpleDnsQueryConnectFunction callback; |
55 gpointer data; | 55 gpointer data; |
56 guint timeout; | 56 guint timeout; |
57 PurpleAccount *account; | |
57 | 58 |
58 #if defined(PURPLE_DNSQUERY_USE_FORK) | 59 #if defined(PURPLE_DNSQUERY_USE_FORK) |
59 PurpleDnsQueryResolverProcess *resolver; | 60 PurpleDnsQueryResolverProcess *resolver; |
60 #elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK */ | 61 #elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK */ |
61 GThread *resolver; | 62 GThread *resolver; |
859 | 860 |
860 static gboolean | 861 static gboolean |
861 initiate_resolving(gpointer data) | 862 initiate_resolving(gpointer data) |
862 { | 863 { |
863 PurpleDnsQueryData *query_data; | 864 PurpleDnsQueryData *query_data; |
865 PurpleProxyType proxy_type; | |
864 | 866 |
865 query_data = data; | 867 query_data = data; |
866 query_data->timeout = 0; | 868 query_data->timeout = 0; |
867 | 869 |
868 if (resolve_ip(query_data)) | 870 if (resolve_ip(query_data)) |
869 /* resolve_ip calls purple_dnsquery_resolved */ | 871 /* resolve_ip calls purple_dnsquery_resolved */ |
870 return FALSE; | 872 return FALSE; |
871 | 873 |
874 proxy_type = purple_proxy_info_get_type( | |
875 purple_proxy_get_setup(query_data->account)); | |
876 if (proxy_type == PURPLE_PROXY_TOR) { | |
877 purple_dnsquery_failed(query_data, | |
878 _("Aborting DNS lookup in Tor Proxy mode.")); | |
879 return FALSE; | |
880 } | |
881 | |
872 if (purple_dnsquery_ui_resolve(query_data)) | 882 if (purple_dnsquery_ui_resolve(query_data)) |
873 /* The UI is handling the resolve; we're done */ | 883 /* The UI is handling the resolve; we're done */ |
874 return FALSE; | 884 return FALSE; |
875 | 885 |
876 resolve_host(query_data); | 886 resolve_host(query_data); |
877 | 887 |
878 return FALSE; | 888 return FALSE; |
879 } | 889 } |
880 | 890 |
881 | |
882 PurpleDnsQueryData * | 891 PurpleDnsQueryData * |
883 purple_dnsquery_a(const char *hostname, int port, | 892 purple_dnsquery_a_account(PurpleAccount *account, const char *hostname, int port, |
884 PurpleDnsQueryConnectFunction callback, gpointer data) | 893 PurpleDnsQueryConnectFunction callback, gpointer data) |
885 { | 894 { |
886 PurpleDnsQueryData *query_data; | 895 PurpleDnsQueryData *query_data; |
887 | 896 |
888 g_return_val_if_fail(hostname != NULL, NULL); | 897 g_return_val_if_fail(hostname != NULL, NULL); |
895 query_data->hostname = g_strdup(hostname); | 904 query_data->hostname = g_strdup(hostname); |
896 g_strstrip(query_data->hostname); | 905 g_strstrip(query_data->hostname); |
897 query_data->port = port; | 906 query_data->port = port; |
898 query_data->callback = callback; | 907 query_data->callback = callback; |
899 query_data->data = data; | 908 query_data->data = data; |
909 query_data->account = account; | |
900 | 910 |
901 if (*query_data->hostname == '\0') | 911 if (*query_data->hostname == '\0') |
902 { | 912 { |
903 purple_dnsquery_destroy(query_data); | 913 purple_dnsquery_destroy(query_data); |
904 g_return_val_if_reached(NULL); | 914 g_return_val_if_reached(NULL); |
907 query_data->timeout = purple_timeout_add(0, initiate_resolving, query_data); | 917 query_data->timeout = purple_timeout_add(0, initiate_resolving, query_data); |
908 | 918 |
909 return query_data; | 919 return query_data; |
910 } | 920 } |
911 | 921 |
922 PurpleDnsQueryData * | |
923 purple_dnsquery_a(const char *hostname, int port, | |
924 PurpleDnsQueryConnectFunction callback, gpointer data) | |
925 { | |
926 return purple_dnsquery_a_account(NULL, hostname, port, callback, data); | |
927 } | |
912 | 928 |
913 void | 929 void |
914 purple_dnsquery_destroy(PurpleDnsQueryData *query_data) | 930 purple_dnsquery_destroy(PurpleDnsQueryData *query_data) |
915 { | 931 { |
916 PurpleDnsQueryUiOps *ops = purple_dnsquery_get_ui_ops(); | 932 PurpleDnsQueryUiOps *ops = purple_dnsquery_get_ui_ops(); |