summaryrefslogtreecommitdiff
path: root/src/or/dns.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-01-06 20:50:55 +0000
committerNick Mathewson <nickm@torproject.org>2009-01-06 20:50:55 +0000
commit462f64b6b993d46f5b61c7e2333cc526d15ba884 (patch)
treee5c9ff1ec2a7a77da5a46fc7016d5cad79ff0a4d /src/or/dns.c
parent585d4a12b50aa0151411c777a6c7d266d71fb46f (diff)
downloadtor-462f64b6b993d46f5b61c7e2333cc526d15ba884.tar.gz
tor-462f64b6b993d46f5b61c7e2333cc526d15ba884.zip
Make outgoing DNS requests respect OutboundBindAddress.
Fixes the bug part of bug 789. svn:r17983
Diffstat (limited to 'src/or/dns.c')
-rw-r--r--src/or/dns.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/or/dns.c b/src/or/dns.c
index 3266cf99dc..f8191679bf 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -1102,6 +1102,25 @@ configure_nameservers(int force)
conf_fname = "/etc/resolv.conf";
#endif
+ if (options->OutboundBindAddress) {
+ tor_addr_t addr;
+ if (tor_addr_from_str(&addr, options->OutboundBindAddress) < 0) {
+ log_warn(LD_CONFIG,"Outbound bind address '%s' didn't parse. Ignoring.",
+ options->OutboundBindAddress);
+ } else {
+ int socklen;
+ struct sockaddr_storage ss;
+ socklen = tor_addr_to_sockaddr(&addr, 0,
+ (struct sockaddr *)&ss, sizeof(ss));
+ if (socklen < 0) {
+ log_warn(LD_BUG, "Couldn't convert outboung bind address to sockaddr."
+ " Ignoring.");
+ } else {
+ evdns_set_default_outgoing_bind_address((struct sockaddr *)&ss,socklen);
+ }
+ }
+ }
+
evdns_set_log_fn(evdns_log_cb);
if (conf_fname) {
if (stat(conf_fname, &st)) {