populate router_get_my_routerinfo()->is_verified

svn:r2097
This commit is contained in:
Roger Dingledine 2004-07-22 06:03:53 +00:00
parent 38d8e36919
commit b48cdc9d40
4 changed files with 34 additions and 9 deletions

View File

@ -207,8 +207,20 @@ connection_t *connection_or_connect(uint32_t addr, uint16_t port,
* Return -1 if <b>conn</b> is broken, else return 0.
*/
int connection_tls_start_handshake(connection_t *conn, int receiving) {
int use_no_cert=0;
conn->state = OR_CONN_STATE_HANDSHAKING;
conn->tls = tor_tls_new(conn->s, receiving);
if(receiving) { /* check if he's 0.0.7 and I'm unverified */
routerinfo_t *him, *me;
him = router_get_by_digest(conn->identity_digest);
me = router_get_my_routerinfo();
if(him && !strncmp(him->platform, "Tor 0.0.7", 9) &&
(!me || !me->is_verified)) {
log_fn(LOG_INFO,"He's running 0.0.7, and I'm unverified. Acting like OP.");
use_no_cert = 1;
}
}
conn->tls = tor_tls_new(conn->s, receiving, use_no_cert);
if(!conn->tls) {
log_fn(LOG_WARN,"tor_tls_new failed. Closing.");
return -1;

View File

@ -126,14 +126,12 @@ void rotate_onion_key(void)
/** The last calculated bandwidth usage for our node. */
static int advertised_bw = 0;
/** Tuck <b>bw</b> away so we can produce it when somebody
* calls router_get_advertised_bandwidth() below.
*/
void router_set_advertised_bandwidth(int bw) {
advertised_bw = bw;
}
/** Return the value we tucked away above, or zero by default. */
int router_get_advertised_bandwidth(void) {
return advertised_bw;
@ -142,8 +140,9 @@ int router_get_advertised_bandwidth(void) {
/* Read an RSA secret key key from a file that was once named fname_old,
* but is now named fname_new. Rename the file from old to new as needed.
*/
crypto_pk_env_t *init_key_from_file_name_changed(const char *fname_old,
const char *fname_new)
static crypto_pk_env_t *
init_key_from_file_name_changed(const char *fname_old,
const char *fname_new)
{
int fs;
@ -532,6 +531,9 @@ int router_rebuild_descriptor(void) {
ri->exit_policy = NULL; /* zero it out first */
router_add_exit_policy_from_config(ri);
ri->is_trusted_dir = authdir_mode();
if(desc_routerinfo) /* inherit values */
ri->is_verified = desc_routerinfo->is_verified;
if (desc_routerinfo)
routerinfo_free(desc_routerinfo);
desc_routerinfo = ri;

View File

@ -794,7 +794,7 @@ void routerlist_update_from_runningrouters(routerlist_t *list,
running_routers_t *rr)
{
int n_routers, i;
routerinfo_t *router;
routerinfo_t *router, *me = router_get_my_routerinfo();
if (!list)
return;
if (list->published_on >= rr->published_on)
@ -802,6 +802,10 @@ void routerlist_update_from_runningrouters(routerlist_t *list,
if (list->running_routers_updated_on >= rr->published_on)
return;
if(me) /* learn if the dirservers think I'm verified */
router_update_status_from_smartlist(me,
rr->published_on,
rr->running_routers);
n_routers = smartlist_len(list->routers);
for (i=0; i<n_routers; ++i) {
router = smartlist_get(list->routers, i);

View File

@ -313,8 +313,8 @@ int check_software_version_against_directory(const char *directory,
*/
int /* Should be static; exposed for unit tests */
router_parse_routerlist_from_directory(const char *str,
routerlist_t **dest,
crypto_pk_env_t *pkey)
routerlist_t **dest,
crypto_pk_env_t *pkey)
{
directory_token_t *tok;
char digest[DIGEST_LEN];
@ -389,11 +389,18 @@ router_parse_routerlist_from_directory(const char *str,
}
tok->n_args = 0; /* Don't free the strings in good_nickname_lst yet. */
/* Determine if my routerinfo is considered verified. */
{
routerinfo_t *me = router_get_my_routerinfo();
if(me)
router_update_status_from_smartlist(me, time(NULL), good_nickname_list);
}
/* Read the router list from s, advancing s up past the end of the last
* router. */
str = end;
if (router_parse_list_from_string(&str, &new_dir,
good_nickname_list)) {
good_nickname_list)) {
log_fn(LOG_WARN, "Error reading routers from directory");
goto err;
}