[or-cvs] use tor_lookup_hostname for binding local addresses too

Roger Dingledine arma at seul.org
Wed Apr 28 20:57:05 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	connection.c 
Log Message:
use tor_lookup_hostname for binding local addresses too


Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -d -r1.203 -r1.204
--- connection.c	26 Apr 2004 21:15:06 -0000	1.203
+++ connection.c	28 Apr 2004 20:57:03 -0000	1.204
@@ -257,7 +257,6 @@
 
 int connection_create_listener(char *bindaddress, uint16_t bindport, int type) {
   struct sockaddr_in bindaddr; /* where to bind */
-  struct hostent *rent;
   connection_t *conn;
   int s; /* the socket we're going to make */
   int one=1;
@@ -265,14 +264,10 @@
   memset(&bindaddr,0,sizeof(struct sockaddr_in));
   bindaddr.sin_family = AF_INET;
   bindaddr.sin_port = htons(bindport);
-  rent = gethostbyname(bindaddress);
-  if (!rent) {
+  if(tor_lookup_hostname(bindaddress, &(bindaddr.sin_addr.s_addr)) != 0) {
     log_fn(LOG_WARN,"Can't resolve BindAddress %s",bindaddress);
     return -1;
   }
-  if(rent->h_length != 4)
-    return -1; /* XXX complain */
-  memcpy(&(bindaddr.sin_addr.s_addr),rent->h_addr,rent->h_length);
 
   s = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
   if (s < 0) {



More information about the tor-commits mailing list