aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-02-19 19:52:04 -0500
committerNick Mathewson <nickm@torproject.org>2020-02-20 10:41:06 -0500
commit1d068625ddcc5ea9d629d0265eb6bbab7877d6ed (patch)
treefd7af2951dee42629ebdc58a98560e4e8d1fddbc
parente425ffc6375f28554ad3491f3bfc57b69964a394 (diff)
downloadtor-1d068625ddcc5ea9d629d0265eb6bbab7877d6ed.tar.gz
tor-1d068625ddcc5ea9d629d0265eb6bbab7877d6ed.zip
Move relay_handshake.[ch] into src/feature/relay, and make it optional
-rw-r--r--scripts/maint/practracker/exceptions.txt2
-rw-r--r--src/core/or/channeltls.c2
-rw-r--r--src/core/or/connection_or.c2
-rw-r--r--src/core/or/include.am2
-rw-r--r--src/core/or/relay_handshake.h38
-rw-r--r--src/feature/relay/include.am2
-rw-r--r--src/feature/relay/relay_handshake.c (renamed from src/core/or/relay_handshake.c)2
-rw-r--r--src/feature/relay/relay_handshake.h90
-rw-r--r--src/test/test_link_handshake.c2
9 files changed, 97 insertions, 45 deletions
diff --git a/scripts/maint/practracker/exceptions.txt b/scripts/maint/practracker/exceptions.txt
index ac81c79b49..9c962bb045 100644
--- a/scripts/maint/practracker/exceptions.txt
+++ b/scripts/maint/practracker/exceptions.txt
@@ -145,7 +145,6 @@ problem dependency-violation /src/core/or/connection_edge.h 1
problem file-size /src/core/or/connection_or.c 3122
problem function-size /src/core/or/connection_or.c:connection_or_group_set_badness_() 105
problem function-size /src/core/or/connection_or.c:connection_or_client_learned_peer_id() 142
-problem function-size /src/core/or/relay_handshake.c:connection_or_compute_authenticate_cell_body() 231
problem dependency-violation /src/core/or/connection_or.c 20
problem dependency-violation /src/core/or/dos.c 6
problem dependency-violation /src/core/or/onion.c 2
@@ -275,6 +274,7 @@ problem function-size /src/feature/nodelist/routerlist.c:update_extrainfo_downlo
problem function-size /src/feature/relay/dns.c:dns_resolve_impl() 131
problem function-size /src/feature/relay/dns.c:configure_nameservers() 161
problem function-size /src/feature/relay/dns.c:evdns_callback() 108
+problem function-size /src/feature/relay/relay_handshake.c:connection_or_compute_authenticate_cell_body() 231
problem file-size /src/feature/relay/router.c 3520
problem include-count /src/feature/relay/router.c 57
problem function-size /src/feature/relay/router.c:init_keys() 252
diff --git a/src/core/or/channeltls.c b/src/core/or/channeltls.c
index 71e0c6aa07..2a35237d30 100644
--- a/src/core/or/channeltls.c
+++ b/src/core/or/channeltls.c
@@ -47,7 +47,7 @@
#include "app/config/config.h"
#include "core/mainloop/connection.h"
#include "core/or/connection_or.h"
-#include "core/or/relay_handshake.h"
+#include "feature/relay/relay_handshake.h"
#include "feature/control/control.h"
#include "feature/client/entrynodes.h"
#include "trunnel/link_handshake.h"
diff --git a/src/core/or/connection_or.c b/src/core/or/connection_or.c
index 9302dc8647..6dd646637b 100644
--- a/src/core/or/connection_or.c
+++ b/src/core/or/connection_or.c
@@ -39,7 +39,7 @@
#include "app/config/config.h"
#include "core/mainloop/connection.h"
#include "core/or/connection_or.h"
-#include "core/or/relay_handshake.h"
+#include "feature/relay/relay_handshake.h"
#include "feature/control/control_events.h"
#include "lib/crypt_ops/crypto_util.h"
#include "feature/dirauth/reachability.h"
diff --git a/src/core/or/include.am b/src/core/or/include.am
index 89445e6981..4dd251d2e4 100644
--- a/src/core/or/include.am
+++ b/src/core/or/include.am
@@ -28,7 +28,6 @@ LIBTOR_APP_A_SOURCES += \
src/core/or/protover_rust.c \
src/core/or/reasons.c \
src/core/or/relay.c \
- src/core/or/relay_handshake.c \
src/core/or/scheduler.c \
src/core/or/scheduler_kist.c \
src/core/or/scheduler_vanilla.c \
@@ -89,7 +88,6 @@ noinst_HEADERS += \
src/core/or/reasons.h \
src/core/or/relay.h \
src/core/or/relay_crypto_st.h \
- src/core/or/relay_handshake.h \
src/core/or/scheduler.h \
src/core/or/sendme.h \
src/core/or/server_port_cfg_st.h \
diff --git a/src/core/or/relay_handshake.h b/src/core/or/relay_handshake.h
deleted file mode 100644
index 987038cc7c..0000000000
--- a/src/core/or/relay_handshake.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (c) 2001 Matej Pfajfar.
- * Copyright (c) 2001-2004, Roger Dingledine.
- * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2020, The Tor Project, Inc. */
-/* See LICENSE for licensing information */
-
-/**
- * @file relay_handshake.h
- * @brief Header for core/or/relay_handshake.c
- **/
-
-#ifndef TOR_CORE_OR_RELAY_HANDSHAKE_H
-#define TOR_CORE_OR_RELAY_HANDSHAKE_H
-
-struct ed25519_keypair_t;
-
-int connection_or_send_certs_cell(or_connection_t *conn);
-int connection_or_send_auth_challenge_cell(or_connection_t *conn);
-
-var_cell_t *connection_or_compute_authenticate_cell_body(
- or_connection_t *conn,
- const int authtype,
- crypto_pk_t *signing_key,
- const struct ed25519_keypair_t *ed_signing_key,
- int server);
-
-int authchallenge_type_is_supported(uint16_t challenge_type);
-int authchallenge_type_is_better(uint16_t challenge_type_a,
- uint16_t challenge_type_b);
-
-MOCK_DECL(int,connection_or_send_authenticate_cell,
- (or_connection_t *conn, int type));
-
-#ifdef TOR_UNIT_TESTS
-extern int certs_cell_ed25519_disabled_for_testing;
-#endif
-
-#endif /* !defined(TOR_CORE_OR_RELAY_HANDSHAKE_H) */
diff --git a/src/feature/relay/include.am b/src/feature/relay/include.am
index f4b504a346..813ddb8fb1 100644
--- a/src/feature/relay/include.am
+++ b/src/feature/relay/include.am
@@ -12,6 +12,7 @@ MODULE_RELAY_SOURCES = \
src/feature/relay/ext_orport.c \
src/feature/relay/routermode.c \
src/feature/relay/relay_config.c \
+ src/feature/relay/relay_handshake.c \
src/feature/relay/relay_periodic.c \
src/feature/relay/relay_sys.c \
src/feature/relay/routerkeys.c \
@@ -25,6 +26,7 @@ noinst_HEADERS += \
src/feature/relay/ext_orport.h \
src/feature/relay/onion_queue.h \
src/feature/relay/relay_config.h \
+ src/feature/relay/relay_handshake.h \
src/feature/relay/relay_periodic.h \
src/feature/relay/relay_sys.h \
src/feature/relay/router.h \
diff --git a/src/core/or/relay_handshake.c b/src/feature/relay/relay_handshake.c
index 78b7da7371..030dc94956 100644
--- a/src/core/or/relay_handshake.c
+++ b/src/feature/relay/relay_handshake.c
@@ -17,7 +17,7 @@
#include "orconfig.h"
#include "core/or/or.h"
-#include "core/or/relay_handshake.h"
+#include "feature/relay/relay_handshake.h"
#include "app/config/config.h"
#include "core/or/connection_or.h"
diff --git a/src/feature/relay/relay_handshake.h b/src/feature/relay/relay_handshake.h
new file mode 100644
index 0000000000..99a658cbcc
--- /dev/null
+++ b/src/feature/relay/relay_handshake.h
@@ -0,0 +1,90 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2020, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * @file relay_handshake.h
+ * @brief Header for feature/relay/relay_handshake.c
+ **/
+
+#ifndef TOR_CORE_OR_RELAY_HANDSHAKE_H
+#define TOR_CORE_OR_RELAY_HANDSHAKE_H
+
+#ifdef HAVE_MODULE_RELAY
+struct ed25519_keypair_t;
+
+int connection_or_send_certs_cell(or_connection_t *conn);
+int connection_or_send_auth_challenge_cell(or_connection_t *conn);
+
+var_cell_t *connection_or_compute_authenticate_cell_body(
+ or_connection_t *conn,
+ const int authtype,
+ crypto_pk_t *signing_key,
+ const struct ed25519_keypair_t *ed_signing_key,
+ int server);
+
+int authchallenge_type_is_supported(uint16_t challenge_type);
+int authchallenge_type_is_better(uint16_t challenge_type_a,
+ uint16_t challenge_type_b);
+
+MOCK_DECL(int,connection_or_send_authenticate_cell,
+ (or_connection_t *conn, int type));
+
+#ifdef TOR_UNIT_TESTS
+extern int certs_cell_ed25519_disabled_for_testing;
+#endif
+#else /* !defined(HAVE_MODULE_RELAY) */
+
+static inline int
+connection_or_send_certs_cell(or_connection_t *conn)
+{
+ (void)conn;
+ tor_assert_nonfatal_unreached();
+ return -1;
+}
+static inline int
+connection_or_send_auth_challenge_cell(or_connection_t *conn)
+{
+ (void)conn;
+ tor_assert_nonfatal_unreached();
+ return -1;
+}
+
+static inline var_cell_t *
+connection_or_compute_authenticate_cell_body(
+ or_connection_t *conn,
+ const int authtype,
+ crypto_pk_t *signing_key,
+ const struct ed25519_keypair_t *ed_signing_key,
+ int server)
+{
+ (void)conn;
+ (void)authtype;
+ (void)signing_key;
+ (void)ed_signing_key;
+ (void)server;
+ tor_assert_nonfatal_unreached();
+ return NULL;
+}
+
+#define authchallenge_type_is_supported(t) (0)
+#define authchallenge_type_is_better(a, b) (0)
+
+static inline int
+connection_or_send_authenticate_cell(or_connection_t *conn, int type)
+{
+ (void)conn;
+ (void)type;
+ tor_assert_nonfatal_unreached();
+ return -1;
+}
+
+#ifdef TOR_UNIT_TESTS
+extern int certs_cell_ed25519_disabled_for_testing;
+#endif
+
+#endif /* defined(HAVE_MODULE_RELAY) */
+
+#endif /* !defined(TOR_CORE_OR_RELAY_HANDSHAKE_H) */
diff --git a/src/test/test_link_handshake.c b/src/test/test_link_handshake.c
index 98e8447d86..1566b349ed 100644
--- a/src/test/test_link_handshake.c
+++ b/src/test/test_link_handshake.c
@@ -18,7 +18,7 @@
#include "feature/relay/routerkeys.h"
#include "core/or/scheduler.h"
#include "feature/nodelist/torcert.h"
-#include "core/or/relay_handshake.h"
+#include "feature/relay/relay_handshake.h"
#include "core/or/or_connection_st.h"
#include "core/or/or_handshake_certs_st.h"