[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] client now survives going offline better
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
config.c connection.c connection_edge.c directory.c or.h
routers.c test.c
Log Message:
client now survives going offline better
fix badness in usage()
if neither socksport nor orrport is defined, quit
obsolete connection_flush_buf()
Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- config.c 25 Oct 2003 12:01:09 -0000 1.64
+++ config.c 10 Nov 2003 08:06:53 -0000 1.65
@@ -213,7 +213,7 @@
"-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"
@@ -352,6 +352,11 @@
log(LOG_WARN,"SocksPort option can't be negative.");
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.");
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -d -r1.126 -r1.127
--- connection.c 25 Oct 2003 12:01:09 -0000 1.126
+++ connection.c 10 Nov 2003 08:06:53 -0000 1.127
@@ -429,10 +429,6 @@
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) {
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- connection_edge.c 22 Oct 2003 09:08:10 -0000 1.44
+++ connection_edge.c 10 Nov 2003 08:06:53 -0000 1.45
@@ -578,7 +578,7 @@
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 @@
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 @@
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 */
}
Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- directory.c 13 Oct 2003 19:58:21 -0000 1.46
+++ directory.c 10 Nov 2003 08:06:53 -0000 1.47
@@ -21,25 +21,16 @@
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 @@
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);
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -d -r1.174 -r1.175
--- or.h 25 Oct 2003 12:01:09 -0000 1.174
+++ or.h 10 Nov 2003 08:06:53 -0000 1.175
@@ -560,7 +560,6 @@
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);
Index: routers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routers.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- routers.c 21 Oct 2003 09:48:17 -0000 1.85
+++ routers.c 10 Nov 2003 08:06:54 -0000 1.86
@@ -55,7 +55,7 @@
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 @@
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) {
Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- test.c 10 Nov 2003 06:28:53 -0000 1.46
+++ test.c 10 Nov 2003 08:06:55 -0000 1.47
@@ -449,7 +449,7 @@
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;