aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/connection_edge.h
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-10-17 15:15:14 -0400
committerGeorge Kadianakis <desnacked@riseup.net>2019-11-18 19:06:43 +0200
commit80f241907c1b3d69784de98e9ff3f96d5c37f51b (patch)
treee165da05d409107a983beabc188395417092897b /src/core/or/connection_edge.h
parent542402cd60bc6b26f43c399b238602a1f3c18d85 (diff)
downloadtor-80f241907c1b3d69784de98e9ff3f96d5c37f51b.tar.gz
tor-80f241907c1b3d69784de98e9ff3f96d5c37f51b.zip
hs-v3: Set extended error if .onion is invalid
In order to achieve this, the parse_extended_hostname() had to be refactored to return either success or failure and setting the hostname type in the given parameter. The reason for that is so it can detect invalid onion addresses that is having a ".onion", the right length but just not passing validation. That way, we can send back the prop304 ExtendedError "X'F1' Onion Service Descriptor Is Invalid" to notify the SOCKS connection of the invalid onion address. Part of #30382 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/core/or/connection_edge.h')
-rw-r--r--src/core/or/connection_edge.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/core/or/connection_edge.h b/src/core/or/connection_edge.h
index e82b6bd765..cda087b163 100644
--- a/src/core/or/connection_edge.h
+++ b/src/core/or/connection_edge.h
@@ -71,6 +71,15 @@ entry_connection_t *EDGE_TO_ENTRY_CONN(edge_connection_t *);
#define connection_mark_unattached_ap(conn, endreason) \
connection_mark_unattached_ap_((conn), (endreason), __LINE__, SHORT_FILE__)
+/** Possible return values for parse_extended_hostname. */
+typedef enum hostname_type_t {
+ BAD_HOSTNAME,
+ EXIT_HOSTNAME,
+ NORMAL_HOSTNAME,
+ ONION_V2_HOSTNAME,
+ ONION_V3_HOSTNAME,
+} hostname_type_t;
+
MOCK_DECL(void,connection_mark_unattached_ap_,
(entry_connection_t *conn, int endreason,
int line, const char *file));
@@ -155,13 +164,6 @@ int connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
origin_circuit_t *circ,
crypt_path_t *cpath);
-/** Possible return values for parse_extended_hostname. */
-typedef enum hostname_type_t {
- NORMAL_HOSTNAME, ONION_V2_HOSTNAME, ONION_V3_HOSTNAME,
- EXIT_HOSTNAME, BAD_HOSTNAME
-} hostname_type_t;
-hostname_type_t parse_extended_hostname(char *address);
-
#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
int get_pf_socket(void);
#endif
@@ -219,6 +221,8 @@ void half_edge_free_(struct half_edge_t *he);
#ifdef CONNECTION_EDGE_PRIVATE
+STATIC bool parse_extended_hostname(char *address, hostname_type_t *type_out);
+
/** A parsed BEGIN or BEGIN_DIR cell */
typedef struct begin_cell_t {
/** The address the client has asked us to connect to, or NULL if this is