[tor-commits] [tor/master] Move relay_handshake.[ch] into src/feature/relay, and make it optional

nickm at torproject.org nickm at torproject.org
Thu Feb 20 15:41:21 UTC 2020


commit 1d068625ddcc5ea9d629d0265eb6bbab7877d6ed
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Feb 19 19:52:04 2020 -0500

    Move relay_handshake.[ch] into src/feature/relay, and make it optional
---
 scripts/maint/practracker/exceptions.txt         |  2 +-
 src/core/or/channeltls.c                         |  2 +-
 src/core/or/connection_or.c                      |  2 +-
 src/core/or/include.am                           |  2 -
 src/core/or/relay_handshake.h                    | 38 ----------
 src/feature/relay/include.am                     |  2 +
 src/{core/or => feature/relay}/relay_handshake.c |  2 +-
 src/feature/relay/relay_handshake.h              | 90 ++++++++++++++++++++++++
 src/test/test_link_handshake.c                   |  2 +-
 9 files changed, 97 insertions(+), 45 deletions(-)

diff --git a/scripts/maint/practracker/exceptions.txt b/scripts/maint/practracker/exceptions.txt
index ac81c79b4..9c962bb04 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 71e0c6aa0..2a35237d3 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 9302dc864..6dd646637 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 89445e698..4dd251d2e 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 987038cc7..000000000
--- 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 f4b504a34..813ddb8fb 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
similarity index 99%
rename from src/core/or/relay_handshake.c
rename to src/feature/relay/relay_handshake.c
index 78b7da737..030dc9495 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 000000000..99a658cbc
--- /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 98e8447d8..1566b349e 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"





More information about the tor-commits mailing list