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

This commit is contained in:
Nick Mathewson
2020-02-19 19:52:04 -05:00
parent e425ffc637
commit 1d068625dd
9 changed files with 97 additions and 45 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
-2
View File
@@ -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 \
-38
View File
@@ -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) */
+2
View File
@@ -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 \
@@ -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"
+90
View File
@@ -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) */
+1 -1
View File
@@ -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"