Don't trigger an assert if we start a directory authority with a

private IP address (like 127.0.0.1).


svn:r13371
This commit is contained in:
Roger Dingledine 2008-02-04 16:58:50 +00:00
parent dad9f434e0
commit 426a9bbde1
5 changed files with 33 additions and 23 deletions

View File

@ -16,6 +16,8 @@ Changes in version 0.2.0.19-alpha - 2008-0?-??
0.1.2.x.
- Stop incorrectly truncating zlib responses to directory authority
signature download requests. Fix for bug 593. Bugfix on 0.2.0.x.
- Don't trigger an assert if we start a directory authority with a
private IP address (like 127.0.0.1).
Changes in version 0.2.0.18-alpha - 2008-01-25

View File

@ -2872,7 +2872,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
options->V1AuthoritativeDir || options->V2AuthoritativeDir ||
options->V3AuthoritativeDir))
REJECT("AuthoritativeDir is set, but none of "
"(Bridge/HS/V1/V2/V3)AuthoriativeDir is set.");
"(Bridge/HS/V1/V2/V3)AuthoritativeDir is set.");
}
if (options->AuthoritativeDir && !options->DirPort)
@ -3974,12 +3974,12 @@ parse_bridge_line(const char *line, int validate_only)
return r;
}
/** Read the contents of a DirServer line from <b>line</b>. Return 0
* if the line is well-formed, and -1 if it isn't. If
/** Read the contents of a DirServer line from <b>line</b>. If
* <b>validate_only</b> is 0, and the line is well-formed, and it
* shares any bits with <b>required_type</b> or <b>required_type</b>
* is 0, then add the dirserver described in the line (minus whatever
* bits it's missing) as a valid authority. */
* bits it's missing) as a valid authority. Return 0 on success,
* or -1 if the line isn't well-formed or if we can't add it. */
static int
parse_dir_server_line(const char *line, authority_type_t required_type,
int validate_only)
@ -4088,8 +4088,9 @@ parse_dir_server_line(const char *line, authority_type_t required_type,
* authority for. */
log_debug(LD_DIR, "Trusted %d dirserver at %s:%d (%s)", (int)type,
address, (int)dir_port, (char*)smartlist_get(items,0));
add_trusted_dir_server(nickname, address, dir_port, or_port, digest,
v3_digest, type);
if (!add_trusted_dir_server(nickname, address, dir_port, or_port,
digest, v3_digest, type))
goto err;
}
r = 0;

View File

@ -3929,10 +3929,11 @@ void routerlist_retry_directory_downloads(time_t now);
int router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port,
int need_uptime);
int router_exit_policy_rejects_all(routerinfo_t *router);
void add_trusted_dir_server(const char *nickname, const char *address,
uint16_t dir_port, uint16_t or_port,
const char *digest, const char *v3_auth_digest,
authority_type_t type);
trusted_dir_server_t *add_trusted_dir_server(const char *nickname,
const char *address,
uint16_t dir_port, uint16_t or_port,
const char *digest, const char *v3_auth_digest,
authority_type_t type);
void authority_cert_free(authority_cert_t *cert);
void clear_trusted_dir_servers(void);
int any_trusted_dir_is_v1_authority(void);

View File

@ -559,16 +559,20 @@ init_keys(void)
(options->BridgeAuthoritativeDir ? BRIDGE_AUTHORITY : NO_AUTHORITY) |
(options->HSAuthoritativeDir ? HIDSERV_AUTHORITY : NO_AUTHORITY));
if (!router_get_trusteddirserver_by_digest(digest)) {
add_trusted_dir_server(options->Nickname, NULL,
(uint16_t)options->DirPort,
(uint16_t)options->ORPort,
digest,
v3_digest,
type);
}
ds = router_get_trusteddirserver_by_digest(digest);
tor_assert(ds);
if (!ds) {
ds = add_trusted_dir_server(options->Nickname, NULL,
(uint16_t)options->DirPort,
(uint16_t)options->ORPort,
digest,
v3_digest,
type);
if (!ds) {
log_err(LD_GENERAL,"We want to be a directory authority, but we "
"couldn't add ourselves to the authority list. Failing.");
return -1;
}
}
if (ds->type != type) {
log_warn(LD_DIR, "Configured authority type does not match authority "
"type in DirServer list. Adjusting. (%d v %d)",

View File

@ -3366,8 +3366,9 @@ router_exit_policy_rejects_all(routerinfo_t *router)
/** Add to the list of authorized directory servers one at
* <b>address</b>:<b>port</b>, with identity key <b>digest</b>. If
* <b>address</b> is NULL, add ourself. */
void
* <b>address</b> is NULL, add ourself. Return 0 if success, -1 if
* we couldn't add it. */
trusted_dir_server_t *
add_trusted_dir_server(const char *nickname, const char *address,
uint16_t dir_port, uint16_t or_port,
const char *digest, const char *v3_auth_digest,
@ -3385,14 +3386,14 @@ add_trusted_dir_server(const char *nickname, const char *address,
log_warn(LD_CONFIG,
"Couldn't find a suitable address when adding ourself as a "
"trusted directory server.");
return;
return NULL;
}
} else {
if (tor_lookup_hostname(address, &a)) {
log_warn(LD_CONFIG,
"Unable to lookup address for directory server at '%s'",
address);
return;
return NULL;
}
hostname = tor_strdup(address);
}
@ -3433,6 +3434,7 @@ add_trusted_dir_server(const char *nickname, const char *address,
smartlist_add(trusted_dir_servers, ent);
router_dir_info_changed();
return ent;
}
/** Free storage held in <b>cert</b>. */