Refactoring: Remove 'addresstype' from connection_ap_handle_onion().

It's all v3 now.

Preparation for fixing CID 1473232.
This commit is contained in:
George Kadianakis 2021-02-22 12:50:56 +02:00
parent c0a2330314
commit 32fc8a116a

View File

@ -1929,13 +1929,12 @@ connection_ap_handshake_rewrite(entry_connection_t *conn,
} }
} }
/** We just received a SOCKS request in <b>conn</b> to an onion address of type /** We just received a SOCKS request in <b>conn</b> to a v3 onion. Start
* <b>addresstype</b>. Start connecting to the onion service. */ * connecting to the onion service. */
static int static int
connection_ap_handle_onion(entry_connection_t *conn, connection_ap_handle_onion(entry_connection_t *conn,
socks_request_t *socks, socks_request_t *socks,
origin_circuit_t *circ, origin_circuit_t *circ)
hostname_type_t addresstype)
{ {
time_t now = approx_time(); time_t now = approx_time();
connection_t *base_conn = ENTRY_TO_CONN(conn); connection_t *base_conn = ENTRY_TO_CONN(conn);
@ -1978,7 +1977,6 @@ connection_ap_handle_onion(entry_connection_t *conn,
int rend_cache_lookup_result = -ENOENT; int rend_cache_lookup_result = -ENOENT;
int descriptor_is_usable = 0; int descriptor_is_usable = 0;
if (addresstype == ONION_V3_HOSTNAME) {
const hs_descriptor_t *cached_desc = NULL; const hs_descriptor_t *cached_desc = NULL;
int retval; int retval;
/* Create HS conn identifier with HS pubkey */ /* Create HS conn identifier with HS pubkey */
@ -2010,7 +2008,6 @@ connection_ap_handle_onion(entry_connection_t *conn,
} else { } else {
rend_cache_lookup_result = -ENOENT; rend_cache_lookup_result = -ENOENT;
} }
}
/* Lookup the given onion address. If invalid, stop right now. /* Lookup the given onion address. If invalid, stop right now.
* Otherwise, we might have it in the cache or not. */ * Otherwise, we might have it in the cache or not. */
@ -2048,7 +2045,6 @@ connection_ap_handle_onion(entry_connection_t *conn,
edge_connection_t *edge_conn = ENTRY_TO_EDGE_CONN(conn); edge_connection_t *edge_conn = ENTRY_TO_EDGE_CONN(conn);
connection_ap_mark_as_non_pending_circuit(conn); connection_ap_mark_as_non_pending_circuit(conn);
base_conn->state = AP_CONN_STATE_RENDDESC_WAIT; base_conn->state = AP_CONN_STATE_RENDDESC_WAIT;
if (addresstype == ONION_V3_HOSTNAME) {
tor_assert(edge_conn->hs_ident); tor_assert(edge_conn->hs_ident);
/* Attempt to fetch the hsv3 descriptor. Check the retval to see how it /* Attempt to fetch the hsv3 descriptor. Check the retval to see how it
* went and act accordingly. */ * went and act accordingly. */
@ -2070,7 +2066,6 @@ connection_ap_handle_onion(entry_connection_t *conn,
return -1; return -1;
} }
} }
}
/* We have the descriptor! So launch a connection to the HS. */ /* We have the descriptor! So launch a connection to the HS. */
log_info(LD_REND, "Descriptor is here. Great."); log_info(LD_REND, "Descriptor is here. Great.");
@ -2515,7 +2510,7 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
/* If we get here, it's a request for a .onion address! */ /* If we get here, it's a request for a .onion address! */
tor_assert(addresstype == ONION_V3_HOSTNAME); tor_assert(addresstype == ONION_V3_HOSTNAME);
tor_assert(!automap); tor_assert(!automap);
return connection_ap_handle_onion(conn, socks, circ, addresstype); return connection_ap_handle_onion(conn, socks, circ);
} }
return 0; /* unreached but keeps the compiler happy */ return 0; /* unreached but keeps the compiler happy */