mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
make it warn about internal IPs not only if we had to guess,
but also if they used a hostname rather than an IP svn:r1285
This commit is contained in:
parent
39835dd9f6
commit
0b9c140102
@ -349,10 +349,10 @@ static int resolve_my_address(or_options_t *options) {
|
|||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
struct hostent *rent;
|
struct hostent *rent;
|
||||||
char localhostname[256];
|
char localhostname[256];
|
||||||
int guessed=0;
|
int explicit_ip=1;
|
||||||
|
|
||||||
if(!options->Address) { /* then we need to guess our address */
|
if(!options->Address) { /* then we need to guess our address */
|
||||||
guessed = 1;
|
explicit_ip = 0; /* it's implicit */
|
||||||
|
|
||||||
if(gethostname(localhostname,sizeof(localhostname)) < 0) {
|
if(gethostname(localhostname,sizeof(localhostname)) < 0) {
|
||||||
log_fn(LOG_WARN,"Error obtaining local hostname");
|
log_fn(LOG_WARN,"Error obtaining local hostname");
|
||||||
@ -371,16 +371,20 @@ static int resolve_my_address(or_options_t *options) {
|
|||||||
|
|
||||||
/* now we know options->Address is set. resolve it and keep only the IP */
|
/* now we know options->Address is set. resolve it and keep only the IP */
|
||||||
|
|
||||||
rent = (struct hostent *)gethostbyname(options->Address);
|
if(tor_inet_aton(options->Address, &in) == 0) {
|
||||||
if (!rent) {
|
/* then we have to resolve it */
|
||||||
log_fn(LOG_WARN,"Could not resolve Address %s. Failing.", options->Address);
|
explicit_ip = 0;
|
||||||
return -1;
|
rent = (struct hostent *)gethostbyname(options->Address);
|
||||||
|
if (!rent) {
|
||||||
|
log_fn(LOG_WARN,"Could not resolve Address %s. Failing.", options->Address);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
assert(rent->h_length == 4);
|
||||||
|
memcpy(&in.s_addr, rent->h_addr,rent->h_length);
|
||||||
}
|
}
|
||||||
assert(rent->h_length == 4);
|
if(!explicit_ip && is_internal_IP(htonl(in.s_addr))) {
|
||||||
memcpy(&in.s_addr, rent->h_addr,rent->h_length);
|
|
||||||
if(guessed==1 && is_internal_IP(htonl(in.s_addr))) {
|
|
||||||
log_fn(LOG_WARN,"Address '%s' resolves to private IP '%s'. "
|
log_fn(LOG_WARN,"Address '%s' resolves to private IP '%s'. "
|
||||||
"Please set the Address config option to be your public IP.",
|
"Please set the Address config option to be the IP you want to use.",
|
||||||
options->Address, inet_ntoa(in));
|
options->Address, inet_ntoa(in));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user