summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-07-21 00:12:42 +0000
committerRoger Dingledine <arma@torproject.org>2004-07-21 00:12:42 +0000
commit73ffcc5cefce466d029709e8729b5f123981f0fb (patch)
treec24bfd70243d79068fa1e767d2709ef2006aab25
parent0da256ef976076709f7bbf503e6b6bc50a403380 (diff)
downloadtor-73ffcc5cefce466d029709e8729b5f123981f0fb.tar.gz
tor-73ffcc5cefce466d029709e8729b5f123981f0fb.zip
add a new advertised_server_mode() to distinguish ORs that
are willing to become servers from ones that really are servers. svn:r2071
-rw-r--r--src/or/connection_or.c10
-rw-r--r--src/or/directory.c4
-rw-r--r--src/or/main.c9
-rw-r--r--src/or/or.h1
4 files changed, 17 insertions, 7 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 6cfc0e0df6..d60a7f53fb 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -142,9 +142,9 @@ connection_or_init_conn_from_address(connection_t *conn,
* handshake with an OR with identity digest <b>id_digest</b>.
*
* If <b>id_digest</b> is me, do nothing. If we're already connected to it,
- * return that connection. If the connect() is in progress, set conn's
- * state to 'connecting' and return. If connect() succeeds, call
- * connection_tls_start_handshake() on it.
+ * return that connection. If the connect() is in progress, set the
+ * new conn's state to 'connecting' and return it. If connect() succeeds,
+ * call * connection_tls_start_handshake() on it.
*
* This function is called from router_retry_connections(), for
* ORs connecting to ORs, and circuit_establish_circuit(), for
@@ -158,7 +158,7 @@ connection_t *connection_or_connect(uint32_t addr, uint16_t port,
tor_assert(id_digest);
- if(0) { /* XXX008 if I'm an OR and id_digest is my digest */
+ if(server_mode() && 0) { /* XXX008 if I'm an OR and id_digest is my digest */
log_fn(LOG_WARN,"Request to connect to myself! Failing.");
return NULL;
}
@@ -260,7 +260,7 @@ int connection_tls_continue_handshake(connection_t *conn) {
* If all is successful and he's an OR, then call circuit_n_conn_done()
* to handle events that have been pending on the tls handshake
* completion, and set the directory to be dirty (only matters if I'm
- * a dirserver).
+ * an authdirserver).
*/
static int
connection_tls_finish_handshake(connection_t *conn) {
diff --git a/src/or/directory.c b/src/or/directory.c
index d6c9da3b1b..41c1e8ed91 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -83,8 +83,8 @@ directory_get_from_dirserver(uint8_t purpose, const char *payload,
routerinfo_t *ds;
if (purpose == DIR_PURPOSE_FETCH_DIR) {
- if (server_mode()) {
- /* only ask authdirservers, don't ask myself */
+ if (advertised_server_mode()) {
+ /* only ask authdirservers, and don't ask myself */
ds = router_pick_directory_server(1, 1);
} else {
/* anybody with a non-zero dirport will do */
diff --git a/src/or/main.c b/src/or/main.c
index 6b9e34d1b7..618d4a59a1 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -467,9 +467,17 @@ int server_mode(void) {
return (options.ORPort != 0);
}
+/** Return true iff we have published our descriptor lately.
+ */
+int advertised_server_mode(void) {
+ return (options.ORPort != 0);
+}
+
/** Return true iff we are trying to be an exit server.
*/
int exit_server_mode(void) {
+ /* XXX008 NM: non-exit servers still answer resolve requests, right? How
+ * is this to be used? */
return (options.ORPort != 0);
}
@@ -506,6 +514,7 @@ static void run_scheduled_events(time_t now) {
if (router_rebuild_descriptor()<0) {
log_fn(LOG_WARN, "Couldn't rebuild router descriptor");
}
+ /* XXX008 only if advertised_server_mode */
router_upload_dir_desc_to_dirservers();
}
diff --git a/src/or/or.h b/src/or/or.h
index a4fdecfb0f..67c4de373b 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1197,6 +1197,7 @@ void directory_has_arrived(void);
int authdir_mode(void);
int clique_mode(void);
int server_mode(void);
+advertised_server_mode(void);
int exit_server_mode(void);
int proxy_mode(void);