Tor 0.4.9.0-alpha-dev
transport_config.h
Go to the documentation of this file.
1/* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
5/* See LICENSE for licensing information */
6
7/**
8 * @file transport_config.h
9 * @brief Header for feature/relay/transport_config.c
10 **/
11
12#ifndef TOR_FEATURE_RELAY_TRANSPORT_CONFIG_H
13#define TOR_FEATURE_RELAY_TRANSPORT_CONFIG_H
14
15#ifdef HAVE_MODULE_RELAY
16
18
19struct or_options_t;
20struct smartlist_t;
21
22int options_validate_server_transport(const struct or_options_t *old_options,
23 struct or_options_t *options,
24 char **msg);
25
26char *pt_get_bindaddr_from_config(const char *transport);
27struct smartlist_t *pt_get_options_for_server_transport(const char *transport);
28
29int options_act_server_transport(const struct or_options_t *old_options);
30
31#ifdef RELAY_TRANSPORT_CONFIG_PRIVATE
32
34 const char *line,
35 const char *transport);
36
37#endif /* defined(RELAY_TRANSPORT_CONFIG_PRIVATE) */
38
39#else /* !defined(HAVE_MODULE_RELAY) */
40
41/** When tor is compiled with the relay module disabled, it can't be
42 * configured with server pluggable transports.
43 *
44 * Returns -1 and sets msg to a newly allocated string, if ExtORPort,
45 * ServerTransportPlugin, ServerTransportListenAddr, or
46 * ServerTransportOptions are set in options. Otherwise returns 0. */
47static inline int
49 struct or_options_t *options,
50 char **msg)
51{
52 (void)old_options;
53
54 /* These ExtORPort checks are too strict, and will reject valid configs
55 * that disable ports, like "ExtORPort 0". */
56 if (options->ServerTransportPlugin ||
58 options->ServerTransportOptions ||
59 options->ExtORPort_lines) {
60 /* REJECT() this configuration */
61 *msg = tor_strdup("This tor was built with relay mode disabled. "
62 "It can not be configured with an ExtORPort, "
63 "a ServerTransportPlugin, a ServerTransportListenAddr, "
64 "or ServerTransportOptions.");
65 return -1;
66 }
67
68 return 0;
69}
70
71#define pt_get_bindaddr_from_config(transport) \
72 (((void)(transport)),NULL)
73
74/* 31851: called from client/transports.c, but only from server code */
75#define pt_get_options_for_server_transport(transport) \
76 (((void)(transport)),NULL)
77
78#define options_validate_server_transport(old_options, options, msg) \
79 (((void)(old_options)),((void)(options)),((void)(msg)),0)
80#define options_act_server_transport(old_options) \
81 (((void)(old_options)),0)
82
83#endif /* defined(HAVE_MODULE_RELAY) */
84
85#endif /* !defined(TOR_FEATURE_RELAY_TRANSPORT_CONFIG_H) */
struct config_line_t * ServerTransportOptions
struct config_line_t * ServerTransportListenAddr
struct config_line_t * ExtORPort_lines
struct config_line_t * ServerTransportPlugin
Macros to implement mocking and selective exposure for the test code.
#define STATIC
Definition: testsupport.h:32
smartlist_t * pt_get_options_for_server_transport(const char *transport)
int options_act_server_transport(const or_options_t *old_options)
STATIC smartlist_t * get_options_from_transport_options_line(const char *line, const char *transport)
char * pt_get_bindaddr_from_config(const char *transport)
static int options_validate_server_transport(const struct or_options_t *old_options, struct or_options_t *options, char **msg)