more debugging info, to track down bruce's IP problems

svn:r85
This commit is contained in:
Roger Dingledine 2002-08-27 19:28:35 +00:00
parent 26587827b2
commit db4c2140c3
2 changed files with 17 additions and 4 deletions

View File

@ -207,7 +207,7 @@ int connection_handle_listener_read(connection_t *conn, int new_type, int new_st
/* learn things from parent, so we can perform auth */
memcpy(&newconn->local,&conn->local,sizeof(struct sockaddr_in));
newconn->prkey = conn->prkey;
newconn->address = strdup(inet_ntoa(*(struct in_addr *)&remote.sin_addr.s_addr)); /* remember the remote address */
newconn->address = strdup(inet_ntoa(remote.sin_addr)); /* remember the remote address */
if(connection_add(newconn) < 0) { /* no space, forget it */
connection_free(newconn);
@ -232,6 +232,7 @@ static int learn_local(struct sockaddr_in *local) {
log(LOG_ERR,"Error obtaining local hostname.");
return -1;
}
log(LOG_DEBUG,"learn_local: localhostname is '%s'.",localhostname);
localhost = gethostbyname(localhostname);
if (!localhost) {
log(LOG_ERR,"Error obtaining local host info.");
@ -239,8 +240,8 @@ static int learn_local(struct sockaddr_in *local) {
}
memset((void *)local,0,sizeof(struct sockaddr_in));
local->sin_family = AF_INET;
local->sin_addr.s_addr = INADDR_ANY;
memcpy((void *)&local->sin_addr,(void *)localhost->h_addr,sizeof(struct in_addr));
log(LOG_DEBUG,"learn_local: chose address as '%s'.",inet_ntoa(local->sin_addr));
return 0;
}

View File

@ -20,6 +20,8 @@ static int router_is_me(uint32_t or_address, uint16_t or_listenport, uint16_t my
/* local host information */
char localhostname[512];
struct hostent *localhost;
struct in_addr *a;
char *tmp1;
char *addr = NULL;
int i = 0;
@ -39,11 +41,21 @@ static int router_is_me(uint32_t or_address, uint16_t or_listenport, uint16_t my
addr = localhost->h_addr_list[i++]; /* set to the first local address */
while(addr)
{
a = (struct in_addr *)addr;
tmp1 = strdup(inet_ntoa(*a)); /* can't call inet_ntoa twice in the same
printf, since it overwrites its static
memory each time */
log(LOG_DEBUG,"router_is_me(): Comparing '%s' to '%s'.",tmp1,
inet_ntoa( *((struct in_addr *)&or_address) ) );
free(tmp1);
if (!memcmp((void *)&or_address, (void *)addr, sizeof(uint32_t))) { /* addresses match */
/* FIXME one's a string, one's a uint32_t? does this make sense? */
if (or_listenport == my_or_listenport) /* ports also match */
log(LOG_DEBUG,"router_is_me(): Addresses match. Comparing ports.");
if (or_listenport == my_or_listenport) { /* ports also match */
log(LOG_DEBUG,"router_is_me(): Ports match too.");
return 1;
}
}
addr = localhost->h_addr_list[i++];
}