add a new advertised_server_mode() to distinguish ORs that

are willing to become servers from ones that really are servers.


svn:r2071
This commit is contained in:
Roger Dingledine 2004-07-21 00:12:42 +00:00
parent 0da256ef97
commit 73ffcc5cef
4 changed files with 17 additions and 7 deletions

View File

@ -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) {

View File

@ -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 */

View File

@ -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();
}

View File

@ -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);