Opened 14 years ago

Last modified 7 years ago

#131 closed defect (Implemented)

Tor dies unnecessarily if its IP address is private

Reported by: goodell Owned by:
Priority: Low Milestone:
Component: Core Tor/Tor Version:
Severity: Keywords:
Cc: goodell Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

After reading the config, Tor commits suicide if its IP address is considered private, even if NoPublish == 1.

[Automatically added by flyspray2trac: Operating System: All]

Child Tickets

Change History (5)

comment:1 Changed 14 years ago by goodell

I want to add something like this, but I have not tested it.

--- config.c 2005-05-08 18:11:15.000000000 -0400
+++ config.c.new 2005-05-08 18:08:44.000000000 -0400
@@ -1299,7 +1299,7 @@

if (server_mode(options)) {

/* confirm that our address isn't broken, so we can complain now */
uint32_t tmp;

  • if (resolve_my_address(options->Address, &tmp) < 0)

+ if ((resolve_my_address(options->Address, &tmp) < 0) && (options->NoPublish == 0))

result = -1;

}

comment:2 Changed 14 years ago by goodell

Perhaps HTML formatting will help

<pre>
--- config.c 2005-05-08 18:11:15.000000000 -0400
+++ config.c.new 2005-05-08 18:08:44.000000000 -0400
@@ -1299,7 +1299,7 @@

if (server_mode(options)) {

/* confirm that our address isn't broken, so we can complain now */
uint32_t tmp;

  • if (resolve_my_address(options->Address, &tmp) < 0)

+ if ((resolve_my_address(options->Address, &tmp) < 0) && (options->NoPublish == 0))

result = -1;

}

</pre>

comment:3 Changed 14 years ago by goodell

My previously proposed patch is broken. This patch seems to work better.

<pre>
diff -u or/config.c or.patch/config.c
--- or/config.c 2005-05-07 00:49:09.000000000 -0400
+++ or.patch/config.c 2005-05-08 19:40:08.000000000 -0400
@@ -952,7 +952,7 @@

  • in <b>addr</b>. */

int

-resolve_my_address(const char *address, uint32_t *addr)
+resolve_my_address(or_options_t *options, uint32_t *addr)

{

struct in_addr in;
struct hostent *rent;

@@ -960,6 +960,7 @@

int explicit_ip=1;
char tmpbuf[INET_NTOA_BUF_LEN];
static uint32_t old_addr=0;

+ const char *address = options->Address;

tor_assert(addr);


@@ -1001,7 +1002,8 @@

log_fn(LOG_WARN,"Address '%s' resolves to private IP '%s'. "

"Please set the Address config option to be the IP you want to use.",
hostname, tmpbuf);

  • return -1;

+ if(!options->NoPublish)
+ return -1;

}


log_fn(LOG_DEBUG, "Resolved Address to %s.", tmpbuf);

@@ -1299,7 +1301,7 @@

if (server_mode(options)) {

/* confirm that our address isn't broken, so we can complain now */
uint32_t tmp;

  • if (resolve_my_address(options->Address, &tmp) < 0)

+ if (resolve_my_address(options, &tmp) < 0)

result = -1;

}


diff -u or/or.h or.patch/or.h
--- or/or.h 2005-05-07 01:55:06.000000000 -0400
+++ or.patch/or.h 2005-05-08 19:26:46.000000000 -0400
@@ -1249,7 +1249,7 @@

int config_get_lines(char *string, struct config_line_t result);
void config_free_lines(struct config_line_t *front);
int config_trial_assign(struct config_line_t *list, int reset);

-int resolve_my_address(const char *address, uint32_t *addr);
+int resolve_my_address(or_options_t *options, uint32_t *addr);

void options_init(or_options_t *options);
int init_from_config(int argc, char argv);
int config_init_logs(or_options_t *options, int validate_only);

diff -u or/router.c or.patch/router.c
--- or/router.c 2005-05-07 01:17:36.000000000 -0400
+++ or.patch/router.c 2005-05-08 19:27:17.000000000 -0400
@@ -672,7 +672,7 @@

if (!desc_is_dirty && !force)

return 0;


  • if (resolve_my_address(options->Address, &addr) < 0) {

+ if (resolve_my_address(options, &addr) < 0) {

log_fn(LOG_WARN,"options->Address didn't resolve into an IP.");
return -1;

}

</pre>

comment:4 Changed 14 years ago by nickm

flyspray2trac: bug closed.
Applied patch.

comment:5 Changed 7 years ago by nickm

Component: Tor RelayTor
Note: See TracTickets for help on using tickets.