diff options
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 7 | ||||
-rw-r--r-- | src/or/connection.c | 4 | ||||
-rw-r--r-- | src/or/connection_edge.c | 6 | ||||
-rw-r--r-- | src/or/directory.c | 30 | ||||
-rw-r--r-- | src/or/or.h | 1 | ||||
-rw-r--r-- | src/or/routers.c | 15 | ||||
-rw-r--r-- | src/or/test.c | 2 |
7 files changed, 31 insertions, 34 deletions
diff --git a/src/or/config.c b/src/or/config.c index 02948a6f0..f9518aead 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -213,7 +213,7 @@ void print_usage(void) { "-e <policy>\t\tExit policy\n" "-l <level>\t\tLog level\n" "-m <max>\t\tMax number of connections\n" - "-s <IP>\t\t\tAddress to bind to for Socks\n" + "-s <IP>\t\t\tPort to bind to for Socks\n" ); /* split things up to be ANSI compliant */ printf("-n <nick>\t\tNickname of router\n" @@ -353,6 +353,11 @@ int getconfig(int argc, char **argv, or_options_t *options) { result = -1; } + if(options->SocksPort == 0 && options->ORPort == 0) { + log(LOG_WARN,"SocksPort and ORPort are both undefined? Quitting."); + result = -1; + } + if(options->DirPort < 0) { log(LOG_WARN,"DirPort option can't be negative."); result = -1; diff --git a/src/or/connection.c b/src/or/connection.c index 237e47f1a..685c5b1ae 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -429,10 +429,6 @@ int connection_outbuf_too_full(connection_t *conn) { return (conn->outbuf_flushlen > 10*CELL_PAYLOAD_SIZE); } -int connection_flush_buf(connection_t *conn) { - return flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); -} - /* return -1 if you want to break the conn, else return 0 */ int connection_handle_write(connection_t *conn) { diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 710d4bd62..d7927f436 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -578,7 +578,7 @@ static int connection_ap_handshake_socks_reply(connection_t *conn, char *reply, if(replylen) { /* we already have a reply in mind */ connection_write_to_buf(reply, replylen, conn); - return connection_flush_buf(conn); /* try to flush it */ + return flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); /* try to flush it */ } if(conn->socks_version == 4) { memset(buf,0,SOCKS4_NETWORK_LEN); @@ -587,7 +587,7 @@ static int connection_ap_handshake_socks_reply(connection_t *conn, char *reply, buf[1] = (success ? SOCKS4_GRANTED : SOCKS4_REJECT); /* leave version, destport, destip zero */ connection_write_to_buf(buf, SOCKS4_NETWORK_LEN, conn); - return connection_flush_buf(conn); /* try to flush it */ + return flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); /* try to flush it */ } if(conn->socks_version == 5) { buf[0] = 5; /* version 5 */ @@ -598,7 +598,7 @@ static int connection_ap_handshake_socks_reply(connection_t *conn, char *reply, buf[3] = 1; /* ipv4 addr */ memset(buf+4,0,6); /* XXX set external addr/port to 0, see what breaks */ connection_write_to_buf(buf,10,conn); - return connection_flush_buf(conn); /* try to flush it */ + return flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); /* try to flush it */ } return 0; /* if socks_version isn't 4 or 5, don't send anything */ } diff --git a/src/or/directory.c b/src/or/directory.c index fb92bf75a..204909ee8 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -21,25 +21,16 @@ static int directorylen=0; void directory_initiate_command(routerinfo_t *router, int command) { connection_t *conn; - if(!router) { /* i guess they didn't have one in mind for me to use */ - log_fn(LOG_WARN,"No running dirservers known. This is really bad."); - /* XXX never again will a directory fetch work. Should we exit here, or what? */ - return; - } - -#if 0 /* there's no problem with parallel get/posts now. whichever 'get' ends - last is the directory. */ - if(connection_get_by_type(CONN_TYPE_DIR)) { /* there's already a dir conn running */ - log_fn(LOG_DEBUG,"Canceling connect, dir conn already active."); - return; - } -#endif - - if(command == DIR_CONN_STATE_CONNECTING_FETCH) + if (command == DIR_CONN_STATE_CONNECTING_FETCH) log_fn(LOG_DEBUG,"initiating directory fetch"); else log_fn(LOG_DEBUG,"initiating directory upload"); + if (!router) { /* i guess they didn't have one in mind for me to use */ + log_fn(LOG_WARN,"No running dirservers known. Not trying."); + return; + } + conn = connection_new(CONN_TYPE_DIR); /* set up conn so it's got all the data we need to remember */ @@ -47,13 +38,8 @@ void directory_initiate_command(routerinfo_t *router, int command) { conn->port = router->dir_port; conn->address = tor_strdup(router->address); conn->nickname = tor_strdup(router->nickname); - if (router->identity_pkey) - conn->identity_pkey = crypto_pk_dup_key(router->identity_pkey); - else { - log_fn(LOG_WARN, "No signing key known for dirserver %s; signature won't be checked", conn->address); - conn->identity_pkey = NULL; - /* XXX is there really any situation where router doesn't have an identity_pkey? */ - } + assert(router->identity_pkey); + conn->identity_pkey = crypto_pk_dup_key(router->identity_pkey); if(connection_add(conn) < 0) { /* no space, forget it */ connection_free(conn); diff --git a/src/or/or.h b/src/or/or.h index 27c9740c0..eaadbfd88 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -560,7 +560,6 @@ int connection_find_on_inbuf(char *string, int len, connection_t *conn); int connection_wants_to_flush(connection_t *conn); int connection_outbuf_too_full(connection_t *conn); -int connection_flush_buf(connection_t *conn); int connection_handle_write(connection_t *conn); void connection_write_to_buf(const char *string, int len, connection_t *conn); diff --git a/src/or/routers.c b/src/or/routers.c index daf70b5b7..c0e93017f 100644 --- a/src/or/routers.c +++ b/src/or/routers.c @@ -55,7 +55,7 @@ void router_retry_connections(void) { routerinfo_t *router_pick_directory_server(void) { /* pick the first running router with a positive dir_port */ int i; - routerinfo_t *router; + routerinfo_t *router, *dirserver=NULL; if(!directory) return NULL; @@ -66,7 +66,18 @@ routerinfo_t *router_pick_directory_server(void) { return router; } - return NULL; + log_fn(LOG_WARN,"No dirservers are up. Giving them all another chance."); + /* no running dir servers found? go through and mark them all as up, + * and we'll cycle through the list again. */ + for(i=0;i<directory->n_routers;i++) { + router = directory->routers[i]; + if(router->dir_port > 0) { + router->is_running = 1; + dirserver = router; + } + } + + return dirserver; } void router_upload_desc_to_dirservers(void) { diff --git a/src/or/test.c b/src/or/test.c index bdc6f43fb..a653c179b 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -449,7 +449,7 @@ test_util() { test_eq(0L, tv_udiff(&start, &end)); /* The test values here are confirmed to be correct on a platform - * with a working timgm. */ + * with a working timegm. */ a_time.tm_year = 2003-1900; a_time.tm_mon = 7; a_time.tm_mday = 30; |