summaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-08-16 11:43:18 +0000
committerRoger Dingledine <arma@torproject.org>2004-08-16 11:43:18 +0000
commit0a6e27208b53089d7f171fd131b3eb6cb3fd0901 (patch)
treea76bb3bda12d7933ddcfe40a1c09e765e6ee6b26 /src/or/connection.c
parentc90ff6f8b39b1f4dc95c5aac585291bdfbbb9d58 (diff)
downloadtor-0a6e27208b53089d7f171fd131b3eb6cb3fd0901.tar.gz
tor-0a6e27208b53089d7f171fd131b3eb6cb3fd0901.zip
o Handle servers with dynamic IP addresses: don't replace
options->Address with the resolved one at startup. o detect our address right before we make a routerinfo each time. o external IP vs bind-IP. Already done, just use options->Address. o OutboundBindAddress config option, to bind to a specific IP address for outgoing connect()s. svn:r2241
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index f37cae100a..74da0d6d07 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -482,6 +482,25 @@ int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_
tor_socket_strerror(tor_socket_errno(-1)));
return -1;
}
+
+ if (options.OutboundBindAddress) {
+ struct sockaddr_in ext_addr;
+
+ memset(&ext_addr, 0, sizeof(ext_addr));
+ ext_addr.sin_family = AF_INET;
+ ext_addr.sin_port = 0;
+ if (!tor_inet_aton(options.OutboundBindAddress, &ext_addr.sin_addr)) {
+ log_fn(LOG_WARN,"Outbound bind address '%s' didn't parse. Ignoring.",
+ options.OutboundBindAddress);
+ } else {
+ if(bind(s, (struct sockaddr*)&ext_addr, sizeof(ext_addr) < 0)) {
+ log_fn(LOG_WARN,"Error binding network socket: %s",
+ tor_socket_strerror(tor_socket_errno(s)));
+ return -1;
+ }
+ }
+ }
+
set_socket_nonblocking(s);
memset(&dest_addr,0,sizeof(dest_addr));