mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-23 20:03:31 +01:00
config: Rename new global functions with a prefix
This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ get_dirportfrontpage relay_get_dirportfrontpage \ parse_port_config port_parse_config \ count_real_listeners port_count_real_listeners \ parse_transport_line pt_parse_transport_line \ ensure_bandwidth_cap config_ensure_bandwidth_cap \ get_effective_bwrate relay_get_effective_bwrate \ get_effective_bwburst relay_get_effective_bwburst \ warn_nonlocal_ext_orports port_warn_nonlocal_ext_orports \ parse_ports_relay port_parse_ports_relay \ update_port_set_relay port_update_port_set_relay \ get_transport_bindaddr_from_config pt_get_bindaddr_from_config \ get_options_for_server_transport pt_get_options_for_server_transport It was generated with --no-verify, because it has some long lines. Part of 32213.
This commit is contained in:
parent
96334d6f7f
commit
cb8ebc0b4c
@ -1906,7 +1906,7 @@ options_act,(const or_options_t *old_options))
|
||||
if (!options->DisableNetwork) {
|
||||
if (options->ClientTransportPlugin) {
|
||||
for (cl = options->ClientTransportPlugin; cl; cl = cl->next) {
|
||||
if (parse_transport_line(options, cl->value, 0, 0) < 0) {
|
||||
if (pt_parse_transport_line(options, cl->value, 0, 0) < 0) {
|
||||
// LCOV_EXCL_START
|
||||
log_warn(LD_BUG,
|
||||
"Previously validated ClientTransportPlugin line "
|
||||
@ -2843,7 +2843,7 @@ validate_ports_csv(smartlist_t *sl, const char *name, char **msg)
|
||||
* Else return 0.
|
||||
*/
|
||||
int
|
||||
ensure_bandwidth_cap(uint64_t *value, const char *desc, char **msg)
|
||||
config_ensure_bandwidth_cap(uint64_t *value, const char *desc, char **msg)
|
||||
{
|
||||
if (*value > ROUTER_MAX_DECLARED_BANDWIDTH) {
|
||||
/* This handles an understandable special case where somebody says "2gb"
|
||||
@ -3590,10 +3590,10 @@ options_validate_cb(const void *old_options_, void *options_, char **msg)
|
||||
if (options->KeepalivePeriod < 1)
|
||||
REJECT("KeepalivePeriod option must be positive.");
|
||||
|
||||
if (ensure_bandwidth_cap(&options->BandwidthRate,
|
||||
if (config_ensure_bandwidth_cap(&options->BandwidthRate,
|
||||
"BandwidthRate", msg) < 0)
|
||||
return -1;
|
||||
if (ensure_bandwidth_cap(&options->BandwidthBurst,
|
||||
if (config_ensure_bandwidth_cap(&options->BandwidthBurst,
|
||||
"BandwidthBurst", msg) < 0)
|
||||
return -1;
|
||||
|
||||
@ -3773,7 +3773,7 @@ options_validate_cb(const void *old_options_, void *options_, char **msg)
|
||||
}
|
||||
|
||||
for (cl = options->ClientTransportPlugin; cl; cl = cl->next) {
|
||||
if (parse_transport_line(options, cl->value, 1, 0) < 0)
|
||||
if (pt_parse_transport_line(options, cl->value, 1, 0) < 0)
|
||||
REJECT("Invalid client transport line. See logs for details.");
|
||||
}
|
||||
|
||||
@ -5120,7 +5120,7 @@ parse_bridge_line(const char *line)
|
||||
* - If it's a managed proxy line, launch the managed proxy.
|
||||
*/
|
||||
int
|
||||
parse_transport_line(const or_options_t *options,
|
||||
pt_parse_transport_line(const or_options_t *options,
|
||||
const char *line, int validate_only,
|
||||
int server)
|
||||
{
|
||||
@ -5775,7 +5775,7 @@ warn_client_dns_cache(const char *option, int disabling)
|
||||
* on success, -1 on failure.
|
||||
*/
|
||||
int
|
||||
parse_port_config(smartlist_t *out,
|
||||
port_parse_config(smartlist_t *out,
|
||||
const config_line_t *ports,
|
||||
const char *portname,
|
||||
int listener_type,
|
||||
@ -6208,7 +6208,7 @@ parse_port_config(smartlist_t *out,
|
||||
if (is_control)
|
||||
warn_nonlocal_controller_ports(out, forbid_nonlocal);
|
||||
else if (is_ext_orport)
|
||||
warn_nonlocal_ext_orports(out, portname);
|
||||
port_warn_nonlocal_ext_orports(out, portname);
|
||||
else
|
||||
warn_nonlocal_client_ports(out, portname, listener_type);
|
||||
}
|
||||
@ -6233,7 +6233,7 @@ parse_port_config(smartlist_t *out,
|
||||
* <b>listenertype</b>. Do not count no_listen ports. Only count unix
|
||||
* sockets if count_sockets is true. */
|
||||
int
|
||||
count_real_listeners(const smartlist_t *ports, int listenertype,
|
||||
port_count_real_listeners(const smartlist_t *ports, int listenertype,
|
||||
int count_sockets)
|
||||
{
|
||||
int n = 0;
|
||||
@ -6271,7 +6271,7 @@ parse_ports(or_options_t *options, int validate_only,
|
||||
|
||||
const unsigned gw_flag = options->UnixSocksGroupWritable ?
|
||||
CL_PORT_DFLT_GROUP_WRITABLE : 0;
|
||||
if (parse_port_config(ports,
|
||||
if (port_parse_config(ports,
|
||||
options->SocksPort_lines,
|
||||
"Socks", CONN_TYPE_AP_LISTENER,
|
||||
"127.0.0.1", 9050,
|
||||
@ -6280,7 +6280,7 @@ parse_ports(or_options_t *options, int validate_only,
|
||||
*msg = tor_strdup("Invalid SocksPort configuration");
|
||||
goto err;
|
||||
}
|
||||
if (parse_port_config(ports,
|
||||
if (port_parse_config(ports,
|
||||
options->DNSPort_lines,
|
||||
"DNS", CONN_TYPE_AP_DNS_LISTENER,
|
||||
"127.0.0.1", 0,
|
||||
@ -6288,7 +6288,7 @@ parse_ports(or_options_t *options, int validate_only,
|
||||
*msg = tor_strdup("Invalid DNSPort configuration");
|
||||
goto err;
|
||||
}
|
||||
if (parse_port_config(ports,
|
||||
if (port_parse_config(ports,
|
||||
options->TransPort_lines,
|
||||
"Trans", CONN_TYPE_AP_TRANS_LISTENER,
|
||||
"127.0.0.1", 0,
|
||||
@ -6296,7 +6296,7 @@ parse_ports(or_options_t *options, int validate_only,
|
||||
*msg = tor_strdup("Invalid TransPort configuration");
|
||||
goto err;
|
||||
}
|
||||
if (parse_port_config(ports,
|
||||
if (port_parse_config(ports,
|
||||
options->NATDPort_lines,
|
||||
"NATD", CONN_TYPE_AP_NATD_LISTENER,
|
||||
"127.0.0.1", 0,
|
||||
@ -6304,7 +6304,7 @@ parse_ports(or_options_t *options, int validate_only,
|
||||
*msg = tor_strdup("Invalid NatdPort configuration");
|
||||
goto err;
|
||||
}
|
||||
if (parse_port_config(ports,
|
||||
if (port_parse_config(ports,
|
||||
options->HTTPTunnelPort_lines,
|
||||
"HTTP Tunnel", CONN_TYPE_AP_HTTP_CONNECT_LISTENER,
|
||||
"127.0.0.1", 0,
|
||||
@ -6324,7 +6324,7 @@ parse_ports(or_options_t *options, int validate_only,
|
||||
if (options->ControlSocketsGroupWritable)
|
||||
control_port_flags |= CL_PORT_DFLT_GROUP_WRITABLE;
|
||||
|
||||
if (parse_port_config(ports,
|
||||
if (port_parse_config(ports,
|
||||
options->ControlPort_lines,
|
||||
"Control", CONN_TYPE_CONTROL_LISTENER,
|
||||
"127.0.0.1", 0,
|
||||
@ -6333,7 +6333,7 @@ parse_ports(or_options_t *options, int validate_only,
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (parse_port_config(ports, options->ControlSocket,
|
||||
if (port_parse_config(ports, options->ControlSocket,
|
||||
"ControlSocket",
|
||||
CONN_TYPE_CONTROL_LISTENER, NULL, 0,
|
||||
control_port_flags | CL_PORT_IS_UNIXSOCKET) < 0) {
|
||||
@ -6342,7 +6342,7 @@ parse_ports(or_options_t *options, int validate_only,
|
||||
}
|
||||
}
|
||||
|
||||
if (parse_ports_relay(options, msg, ports, &have_low_ports) < 0)
|
||||
if (port_parse_ports_relay(options, msg, ports, &have_low_ports) < 0)
|
||||
goto err;
|
||||
|
||||
*n_ports_out = smartlist_len(ports);
|
||||
@ -6351,20 +6351,20 @@ parse_ports(or_options_t *options, int validate_only,
|
||||
|
||||
/* Update the *Port_set options. The !! here is to force a boolean out of
|
||||
an integer. */
|
||||
update_port_set_relay(options, ports);
|
||||
port_update_port_set_relay(options, ports);
|
||||
options->SocksPort_set =
|
||||
!! count_real_listeners(ports, CONN_TYPE_AP_LISTENER, 1);
|
||||
!! port_count_real_listeners(ports, CONN_TYPE_AP_LISTENER, 1);
|
||||
options->TransPort_set =
|
||||
!! count_real_listeners(ports, CONN_TYPE_AP_TRANS_LISTENER, 1);
|
||||
!! port_count_real_listeners(ports, CONN_TYPE_AP_TRANS_LISTENER, 1);
|
||||
options->NATDPort_set =
|
||||
!! count_real_listeners(ports, CONN_TYPE_AP_NATD_LISTENER, 1);
|
||||
!! port_count_real_listeners(ports, CONN_TYPE_AP_NATD_LISTENER, 1);
|
||||
options->HTTPTunnelPort_set =
|
||||
!! count_real_listeners(ports, CONN_TYPE_AP_HTTP_CONNECT_LISTENER, 1);
|
||||
!! port_count_real_listeners(ports, CONN_TYPE_AP_HTTP_CONNECT_LISTENER, 1);
|
||||
/* Use options->ControlSocket to test if a control socket is set */
|
||||
options->ControlPort_set =
|
||||
!! count_real_listeners(ports, CONN_TYPE_CONTROL_LISTENER, 0);
|
||||
!! port_count_real_listeners(ports, CONN_TYPE_CONTROL_LISTENER, 0);
|
||||
options->DNSPort_set =
|
||||
!! count_real_listeners(ports, CONN_TYPE_AP_DNS_LISTENER, 1);
|
||||
!! port_count_real_listeners(ports, CONN_TYPE_AP_DNS_LISTENER, 1);
|
||||
|
||||
if (world_writable_control_socket) {
|
||||
SMARTLIST_FOREACH(ports, port_cfg_t *, p,
|
||||
|
@ -243,7 +243,7 @@ bridge_line_t *parse_bridge_line(const char *line);
|
||||
|
||||
/* Port helper functions. */
|
||||
int options_any_client_port_set(const or_options_t *options);
|
||||
int parse_port_config(smartlist_t *out,
|
||||
int port_parse_config(smartlist_t *out,
|
||||
const struct config_line_t *ports,
|
||||
const char *portname,
|
||||
int listener_type,
|
||||
@ -265,13 +265,13 @@ port_cfg_t *port_cfg_new(size_t namelen);
|
||||
FREE_AND_NULL(port_cfg_t, port_cfg_free_, (port))
|
||||
void port_cfg_free_(port_cfg_t *port);
|
||||
|
||||
int count_real_listeners(const smartlist_t *ports,
|
||||
int port_count_real_listeners(const smartlist_t *ports,
|
||||
int listenertype,
|
||||
int count_sockets);
|
||||
int parse_transport_line(const or_options_t *options,
|
||||
int pt_parse_transport_line(const or_options_t *options,
|
||||
const char *line, int validate_only,
|
||||
int server);
|
||||
int ensure_bandwidth_cap(uint64_t *value, const char *desc, char **msg);
|
||||
int config_ensure_bandwidth_cap(uint64_t *value, const char *desc, char **msg);
|
||||
|
||||
#ifdef CONFIG_PRIVATE
|
||||
|
||||
|
@ -639,7 +639,7 @@ get_stored_bindaddr_for_server_transport(const char *transport)
|
||||
{
|
||||
/* See if the user explicitly asked for a specific listening
|
||||
address for this transport. */
|
||||
char *conf_bindaddr = get_transport_bindaddr_from_config(transport);
|
||||
char *conf_bindaddr = pt_get_bindaddr_from_config(transport);
|
||||
if (conf_bindaddr)
|
||||
return conf_bindaddr;
|
||||
}
|
||||
|
@ -1281,7 +1281,7 @@ get_transport_options_for_server_proxy(const managed_proxy_t *mp)
|
||||
string. */
|
||||
SMARTLIST_FOREACH_BEGIN(mp->transports_to_launch, const char *, transport) {
|
||||
smartlist_t *options_tmp_sl = NULL;
|
||||
options_tmp_sl = get_options_for_server_transport(transport);
|
||||
options_tmp_sl = pt_get_options_for_server_transport(transport);
|
||||
if (!options_tmp_sl)
|
||||
continue;
|
||||
|
||||
|
@ -156,10 +156,10 @@ options_validate_dirauth_bandwidth(const or_options_t *old_options,
|
||||
if (!authdir_mode(options))
|
||||
return 0;
|
||||
|
||||
if (ensure_bandwidth_cap(&options->AuthDirFastGuarantee,
|
||||
if (config_ensure_bandwidth_cap(&options->AuthDirFastGuarantee,
|
||||
"AuthDirFastGuarantee", msg) < 0)
|
||||
return -1;
|
||||
if (ensure_bandwidth_cap(&options->AuthDirGuardBWGuarantee,
|
||||
if (config_ensure_bandwidth_cap(&options->AuthDirGuardBWGuarantee,
|
||||
"AuthDirGuardBWGuarantee", msg) < 0)
|
||||
return -1;
|
||||
|
||||
|
@ -479,7 +479,7 @@ static int
|
||||
handle_get_frontpage(dir_connection_t *conn, const get_handler_args_t *args)
|
||||
{
|
||||
(void) args; /* unused */
|
||||
const char *frontpage = get_dirportfrontpage();
|
||||
const char *frontpage = relay_get_dirportfrontpage();
|
||||
|
||||
if (frontpage) {
|
||||
size_t dlen;
|
||||
|
@ -71,7 +71,7 @@ static char *global_dirfrontpagecontents = NULL;
|
||||
|
||||
/** Return the contents of our frontpage string, or NULL if not configured. */
|
||||
MOCK_IMPL(const char*,
|
||||
get_dirportfrontpage, (void))
|
||||
relay_get_dirportfrontpage, (void))
|
||||
{
|
||||
return global_dirfrontpagecontents;
|
||||
}
|
||||
@ -88,33 +88,33 @@ relay_config_free_all(void)
|
||||
/** Return the bandwidthrate that we are going to report to the authorities
|
||||
* based on the config options. */
|
||||
uint32_t
|
||||
get_effective_bwrate(const or_options_t *options)
|
||||
relay_get_effective_bwrate(const or_options_t *options)
|
||||
{
|
||||
uint64_t bw = options->BandwidthRate;
|
||||
if (bw > options->MaxAdvertisedBandwidth)
|
||||
bw = options->MaxAdvertisedBandwidth;
|
||||
if (options->RelayBandwidthRate > 0 && bw > options->RelayBandwidthRate)
|
||||
bw = options->RelayBandwidthRate;
|
||||
/* ensure_bandwidth_cap() makes sure that this cast can't overflow. */
|
||||
/* config_ensure_bandwidth_cap() makes sure that this cast can't overflow. */
|
||||
return (uint32_t)bw;
|
||||
}
|
||||
|
||||
/** Return the bandwidthburst that we are going to report to the authorities
|
||||
* based on the config options. */
|
||||
uint32_t
|
||||
get_effective_bwburst(const or_options_t *options)
|
||||
relay_get_effective_bwburst(const or_options_t *options)
|
||||
{
|
||||
uint64_t bw = options->BandwidthBurst;
|
||||
if (options->RelayBandwidthBurst > 0 && bw > options->RelayBandwidthBurst)
|
||||
bw = options->RelayBandwidthBurst;
|
||||
/* ensure_bandwidth_cap() makes sure that this cast can't overflow. */
|
||||
/* config_ensure_bandwidth_cap() makes sure that this cast can't overflow. */
|
||||
return (uint32_t)bw;
|
||||
}
|
||||
|
||||
/** Warn for every Extended ORPort port in <b>ports</b> that is on a
|
||||
* publicly routable address. */
|
||||
void
|
||||
warn_nonlocal_ext_orports(const smartlist_t *ports, const char *portname)
|
||||
port_warn_nonlocal_ext_orports(const smartlist_t *ports, const char *portname)
|
||||
{
|
||||
SMARTLIST_FOREACH_BEGIN(ports, const port_cfg_t *, port) {
|
||||
if (port->type != CONN_TYPE_EXT_OR_LISTENER)
|
||||
@ -235,7 +235,7 @@ check_server_ports(const smartlist_t *ports,
|
||||
* of the problem and return -1.
|
||||
**/
|
||||
int
|
||||
parse_ports_relay(or_options_t *options,
|
||||
port_parse_ports_relay(or_options_t *options,
|
||||
char **msg,
|
||||
smartlist_t *ports_out,
|
||||
int *have_low_ports_out)
|
||||
@ -261,7 +261,7 @@ parse_ports_relay(or_options_t *options,
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (parse_port_config(ports,
|
||||
if (port_parse_config(ports,
|
||||
options->ORPort_lines,
|
||||
"OR", CONN_TYPE_OR_LISTENER,
|
||||
"0.0.0.0", 0,
|
||||
@ -269,7 +269,7 @@ parse_ports_relay(or_options_t *options,
|
||||
*msg = tor_strdup("Invalid ORPort configuration");
|
||||
goto err;
|
||||
}
|
||||
if (parse_port_config(ports,
|
||||
if (port_parse_config(ports,
|
||||
options->ExtORPort_lines,
|
||||
"ExtOR", CONN_TYPE_EXT_OR_LISTENER,
|
||||
"127.0.0.1", 0,
|
||||
@ -277,7 +277,7 @@ parse_ports_relay(or_options_t *options,
|
||||
*msg = tor_strdup("Invalid ExtORPort configuration");
|
||||
goto err;
|
||||
}
|
||||
if (parse_port_config(ports,
|
||||
if (port_parse_config(ports,
|
||||
options->DirPort_lines,
|
||||
"Dir", CONN_TYPE_DIR_LISTENER,
|
||||
"0.0.0.0", 0,
|
||||
@ -308,7 +308,7 @@ parse_ports_relay(or_options_t *options,
|
||||
|
||||
/** Update the relay *Port_set values in <b>options</b> from <b>ports</b>. */
|
||||
void
|
||||
update_port_set_relay(or_options_t *options,
|
||||
port_update_port_set_relay(or_options_t *options,
|
||||
const smartlist_t *ports)
|
||||
{
|
||||
if (BUG(!options))
|
||||
@ -323,11 +323,11 @@ update_port_set_relay(or_options_t *options,
|
||||
/* Update the relay *Port_set options. The !! here is to force a boolean
|
||||
* out of an integer. */
|
||||
options->ORPort_set =
|
||||
!! count_real_listeners(ports, CONN_TYPE_OR_LISTENER, 0);
|
||||
!! port_count_real_listeners(ports, CONN_TYPE_OR_LISTENER, 0);
|
||||
options->DirPort_set =
|
||||
!! count_real_listeners(ports, CONN_TYPE_DIR_LISTENER, 0);
|
||||
!! port_count_real_listeners(ports, CONN_TYPE_DIR_LISTENER, 0);
|
||||
options->ExtORPort_set =
|
||||
!! count_real_listeners(ports, CONN_TYPE_EXT_OR_LISTENER, 0);
|
||||
!! port_count_real_listeners(ports, CONN_TYPE_EXT_OR_LISTENER, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -624,19 +624,19 @@ options_validate_relay_bandwidth(const or_options_t *old_options,
|
||||
|
||||
/* 31851: the tests expect us to validate bandwidths, even when we are not
|
||||
* in relay mode. */
|
||||
if (ensure_bandwidth_cap(&options->MaxAdvertisedBandwidth,
|
||||
if (config_ensure_bandwidth_cap(&options->MaxAdvertisedBandwidth,
|
||||
"MaxAdvertisedBandwidth", msg) < 0)
|
||||
return -1;
|
||||
if (ensure_bandwidth_cap(&options->RelayBandwidthRate,
|
||||
if (config_ensure_bandwidth_cap(&options->RelayBandwidthRate,
|
||||
"RelayBandwidthRate", msg) < 0)
|
||||
return -1;
|
||||
if (ensure_bandwidth_cap(&options->RelayBandwidthBurst,
|
||||
if (config_ensure_bandwidth_cap(&options->RelayBandwidthBurst,
|
||||
"RelayBandwidthBurst", msg) < 0)
|
||||
return -1;
|
||||
if (ensure_bandwidth_cap(&options->PerConnBWRate,
|
||||
if (config_ensure_bandwidth_cap(&options->PerConnBWRate,
|
||||
"PerConnBWRate", msg) < 0)
|
||||
return -1;
|
||||
if (ensure_bandwidth_cap(&options->PerConnBWBurst,
|
||||
if (config_ensure_bandwidth_cap(&options->PerConnBWBurst,
|
||||
"PerConnBWBurst", msg) < 0)
|
||||
return -1;
|
||||
|
||||
@ -1046,9 +1046,9 @@ options_transition_affects_descriptor(const or_options_t *old_options,
|
||||
YES_IF_CHANGED_BOOL(DirCache);
|
||||
YES_IF_CHANGED_BOOL(AssumeReachable);
|
||||
|
||||
if (get_effective_bwrate(old_options) != get_effective_bwrate(new_options) ||
|
||||
get_effective_bwburst(old_options) !=
|
||||
get_effective_bwburst(new_options) ||
|
||||
if (relay_get_effective_bwrate(old_options) != relay_get_effective_bwrate(new_options) ||
|
||||
relay_get_effective_bwburst(old_options) !=
|
||||
relay_get_effective_bwburst(new_options) ||
|
||||
public_server_mode(old_options) != public_server_mode(new_options))
|
||||
return 1;
|
||||
|
||||
|
@ -25,20 +25,20 @@ int options_validate_relay_mode(const or_options_t *old_options,
|
||||
or_options_t *options,
|
||||
char **msg);
|
||||
|
||||
MOCK_DECL(const char*, get_dirportfrontpage, (void));
|
||||
MOCK_DECL(const char*, relay_get_dirportfrontpage, (void));
|
||||
void relay_config_free_all(void);
|
||||
|
||||
uint32_t get_effective_bwrate(const or_options_t *options);
|
||||
uint32_t get_effective_bwburst(const or_options_t *options);
|
||||
uint32_t relay_get_effective_bwrate(const or_options_t *options);
|
||||
uint32_t relay_get_effective_bwburst(const or_options_t *options);
|
||||
|
||||
void warn_nonlocal_ext_orports(const smartlist_t *ports,
|
||||
void port_warn_nonlocal_ext_orports(const smartlist_t *ports,
|
||||
const char *portname);
|
||||
|
||||
int parse_ports_relay(or_options_t *options,
|
||||
int port_parse_ports_relay(or_options_t *options,
|
||||
char **msg,
|
||||
smartlist_t *ports_out,
|
||||
int *have_low_ports_out);
|
||||
void update_port_set_relay(or_options_t *options,
|
||||
void port_update_port_set_relay(or_options_t *options,
|
||||
const smartlist_t *ports);
|
||||
|
||||
int options_validate_relay_os(const or_options_t *old_options,
|
||||
@ -128,23 +128,23 @@ options_validate_relay_mode(const or_options_t *old_options,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define get_dirportfrontpage() \
|
||||
#define relay_get_dirportfrontpage() \
|
||||
(NULL)
|
||||
#define relay_config_free_all() \
|
||||
STMT_BEGIN STMT_END
|
||||
|
||||
#define get_effective_bwrate(options) \
|
||||
#define relay_get_effective_bwrate(options) \
|
||||
(((void)(options)),0)
|
||||
#define get_effective_bwburst(options) \
|
||||
#define relay_get_effective_bwburst(options) \
|
||||
(((void)(options)),0)
|
||||
|
||||
#define warn_nonlocal_ext_orports(ports, portname) \
|
||||
#define port_warn_nonlocal_ext_orports(ports, portname) \
|
||||
(((void)(ports)),((void)(portname)))
|
||||
|
||||
#define parse_ports_relay(options, msg, ports_out, have_low_ports_out) \
|
||||
#define port_parse_ports_relay(options, msg, ports_out, have_low_ports_out) \
|
||||
(((void)(options)),((void)(msg)),((void)(ports_out)), \
|
||||
((void)(have_low_ports_out)),0)
|
||||
#define update_port_set_relay(options, ports) \
|
||||
#define port_update_port_set_relay(options, ports) \
|
||||
(((void)(options)),((void)(ports)))
|
||||
|
||||
#define options_validate_relay_os(old_options, options, msg) \
|
||||
|
@ -1223,7 +1223,7 @@ router_should_be_dirserver(const or_options_t *options, int dir_port)
|
||||
* much larger effect on output than input so there is no reason to turn it
|
||||
* off if using AccountingRule in. */
|
||||
int interval_length = accounting_get_interval_length();
|
||||
uint32_t effective_bw = get_effective_bwrate(options);
|
||||
uint32_t effective_bw = relay_get_effective_bwrate(options);
|
||||
uint64_t acc_bytes;
|
||||
if (!interval_length) {
|
||||
log_warn(LD_BUG, "An accounting interval is not allowed to be zero "
|
||||
@ -2042,10 +2042,10 @@ router_build_fresh_unsigned_routerinfo,(routerinfo_t **ri_out))
|
||||
ri->protocol_list = tor_strdup(protover_get_supported_protocols());
|
||||
|
||||
/* compute ri->bandwidthrate as the min of various options */
|
||||
ri->bandwidthrate = get_effective_bwrate(options);
|
||||
ri->bandwidthrate = relay_get_effective_bwrate(options);
|
||||
|
||||
/* and compute ri->bandwidthburst similarly */
|
||||
ri->bandwidthburst = get_effective_bwburst(options);
|
||||
ri->bandwidthburst = relay_get_effective_bwburst(options);
|
||||
|
||||
/* Report bandwidth, unless we're hibernating or shutting down */
|
||||
ri->bandwidthcapacity = hibernating ? 0 : rep_hist_bandwidth_assess();
|
||||
|
@ -90,7 +90,7 @@ get_bindaddr_from_transport_listen_line(const char *line,
|
||||
* it to listen on a specific port. Return a <address:port> string if
|
||||
* so, otherwise NULL. */
|
||||
char *
|
||||
get_transport_bindaddr_from_config(const char *transport)
|
||||
pt_get_bindaddr_from_config(const char *transport)
|
||||
{
|
||||
config_line_t *cl;
|
||||
const or_options_t *options = get_options();
|
||||
@ -168,7 +168,7 @@ get_options_from_transport_options_line(const char *line,
|
||||
* parameters to the pluggable transport. Return a smartlist
|
||||
* containing the parameters, otherwise NULL. */
|
||||
smartlist_t *
|
||||
get_options_for_server_transport(const char *transport)
|
||||
pt_get_options_for_server_transport(const char *transport)
|
||||
{
|
||||
config_line_t *cl;
|
||||
const or_options_t *options = get_options();
|
||||
@ -219,7 +219,7 @@ options_validate_server_transport(const or_options_t *old_options,
|
||||
}
|
||||
|
||||
for (cl = options->ServerTransportPlugin; cl; cl = cl->next) {
|
||||
if (parse_transport_line(options, cl->value, 1, 1) < 0)
|
||||
if (pt_parse_transport_line(options, cl->value, 1, 1) < 0)
|
||||
REJECT("Invalid server transport line. See logs for details.");
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ options_act_server_transport(const or_options_t *old_options)
|
||||
if (!options->DisableNetwork) {
|
||||
if (options->ServerTransportPlugin) {
|
||||
for (cl = options->ServerTransportPlugin; cl; cl = cl->next) {
|
||||
if (parse_transport_line(options, cl->value, 0, 1) < 0) {
|
||||
if (pt_parse_transport_line(options, cl->value, 0, 1) < 0) {
|
||||
// LCOV_EXCL_START
|
||||
log_warn(LD_BUG,
|
||||
"Previously validated ServerTransportPlugin line "
|
||||
|
@ -23,8 +23,8 @@ int options_validate_server_transport(const or_options_t *old_options,
|
||||
or_options_t *options,
|
||||
char **msg);
|
||||
|
||||
char *get_transport_bindaddr_from_config(const char *transport);
|
||||
smartlist_t *get_options_for_server_transport(const char *transport);
|
||||
char *pt_get_bindaddr_from_config(const char *transport);
|
||||
smartlist_t *pt_get_options_for_server_transport(const char *transport);
|
||||
|
||||
int options_act_server_transport(const or_options_t *old_options);
|
||||
|
||||
@ -68,11 +68,11 @@ options_validate_server_transport(const or_options_t *old_options,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define get_transport_bindaddr_from_config(transport) \
|
||||
#define pt_get_bindaddr_from_config(transport) \
|
||||
(((void)(transport)),NULL)
|
||||
|
||||
/* 31851: called from client/transports.c, but only from server code */
|
||||
#define get_options_for_server_transport(transport) \
|
||||
#define pt_get_options_for_server_transport(transport) \
|
||||
(((void)(transport)),NULL)
|
||||
|
||||
#define options_validate_server_transport(old_options, options, msg) \
|
||||
|
@ -693,84 +693,84 @@ test_config_parse_transport_plugin_line(void *arg)
|
||||
int old_transport_is_needed_mock_call_count;
|
||||
|
||||
/* Bad transport lines - too short */
|
||||
r = parse_transport_line(options, "bad", 1, 0);
|
||||
r = pt_parse_transport_line(options, "bad", 1, 0);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
r = parse_transport_line(options, "bad", 1, 1);
|
||||
r = pt_parse_transport_line(options, "bad", 1, 1);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
r = parse_transport_line(options, "bad bad", 1, 0);
|
||||
r = pt_parse_transport_line(options, "bad bad", 1, 0);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
r = parse_transport_line(options, "bad bad", 1, 1);
|
||||
r = pt_parse_transport_line(options, "bad bad", 1, 1);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
|
||||
/* Test transport list parsing */
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 exec /usr/bin/fake-transport", 1, 0);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 exec /usr/bin/fake-transport", 1, 1);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1,transport_2 exec /usr/bin/fake-transport", 1, 0);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1,transport_2 exec /usr/bin/fake-transport", 1, 1);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
/* Bad transport identifiers */
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_* exec /usr/bin/fake-transport", 1, 0);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_* exec /usr/bin/fake-transport", 1, 1);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
|
||||
/* Check SOCKS cases for client transport */
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 socks4 1.2.3.4:567", 1, 0);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 socks5 1.2.3.4:567", 1, 0);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
/* Proxy case for server transport */
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 proxy 1.2.3.4:567", 1, 1);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
/* Multiple-transport error exit */
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1,transport_2 socks5 1.2.3.4:567", 1, 0);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1,transport_2 proxy 1.2.3.4:567", 1, 1);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
/* No port error exit */
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 socks5 1.2.3.4", 1, 0);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 proxy 1.2.3.4", 1, 1);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
/* Unparsable address error exit */
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 socks5 1.2.3:6x7", 1, 0);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 proxy 1.2.3:6x7", 1, 1);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
|
||||
/* "Strange {Client|Server}TransportPlugin field" error exit */
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 foo bar", 1, 0);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 foo bar", 1, 1);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
|
||||
/* No sandbox mode error exit */
|
||||
tmp = options->Sandbox;
|
||||
options->Sandbox = 1;
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 exec /usr/bin/fake-transport", 1, 0);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 exec /usr/bin/fake-transport", 1, 1);
|
||||
tt_int_op(r, OP_LT, 0);
|
||||
options->Sandbox = tmp;
|
||||
@ -782,7 +782,7 @@ test_config_parse_transport_plugin_line(void *arg)
|
||||
MOCK(pt_kickstart_proxy, pt_kickstart_proxy_mock);
|
||||
old_pt_kickstart_proxy_mock_call_count =
|
||||
pt_kickstart_proxy_mock_call_count;
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 exec /usr/bin/fake-transport", 0, 1);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
tt_assert(pt_kickstart_proxy_mock_call_count ==
|
||||
@ -790,7 +790,7 @@ test_config_parse_transport_plugin_line(void *arg)
|
||||
UNMOCK(pt_kickstart_proxy);
|
||||
|
||||
/* This one hits a log line in the !validate_only case only */
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 proxy 1.2.3.4:567", 0, 1);
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
|
||||
@ -807,7 +807,7 @@ test_config_parse_transport_plugin_line(void *arg)
|
||||
transport_add_from_config_mock_call_count;
|
||||
old_transport_is_needed_mock_call_count =
|
||||
transport_is_needed_mock_call_count;
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 exec /usr/bin/fake-transport", 0, 0);
|
||||
/* Should have succeeded */
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
@ -831,7 +831,7 @@ test_config_parse_transport_plugin_line(void *arg)
|
||||
transport_add_from_config_mock_call_count;
|
||||
old_transport_is_needed_mock_call_count =
|
||||
transport_is_needed_mock_call_count;
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 exec /usr/bin/fake-transport", 0, 0);
|
||||
/* Should have succeeded */
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
@ -855,7 +855,7 @@ test_config_parse_transport_plugin_line(void *arg)
|
||||
transport_add_from_config_mock_call_count;
|
||||
old_transport_is_needed_mock_call_count =
|
||||
transport_is_needed_mock_call_count;
|
||||
r = parse_transport_line(options,
|
||||
r = pt_parse_transport_line(options,
|
||||
"transport_1 socks5 1.2.3.4:567", 0, 0);
|
||||
/* Should have succeeded */
|
||||
tt_int_op(r, OP_EQ, 0);
|
||||
@ -4001,40 +4001,40 @@ test_config_parse_port_config__ports__no_ports_given(void *data)
|
||||
slout = smartlist_new();
|
||||
|
||||
// Test no defaultport, no defaultaddress and no out
|
||||
ret = parse_port_config(NULL, NULL, "DNS", 0, NULL, 0, 0);
|
||||
ret = port_parse_config(NULL, NULL, "DNS", 0, NULL, 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
|
||||
// Test with defaultport, no defaultaddress and no out
|
||||
ret = parse_port_config(NULL, NULL, "DNS", 0, NULL, 42, 0);
|
||||
ret = port_parse_config(NULL, NULL, "DNS", 0, NULL, 42, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
|
||||
// Test no defaultport, with defaultaddress and no out
|
||||
ret = parse_port_config(NULL, NULL, "DNS", 0, "127.0.0.2", 0, 0);
|
||||
ret = port_parse_config(NULL, NULL, "DNS", 0, "127.0.0.2", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
|
||||
// Test with defaultport, with defaultaddress and no out
|
||||
ret = parse_port_config(NULL, NULL, "DNS", 0, "127.0.0.2", 42, 0);
|
||||
ret = port_parse_config(NULL, NULL, "DNS", 0, "127.0.0.2", 42, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
|
||||
// Test no defaultport, no defaultaddress and with out
|
||||
ret = parse_port_config(slout, NULL, "DNS", 0, NULL, 0, 0);
|
||||
ret = port_parse_config(slout, NULL, "DNS", 0, NULL, 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 0);
|
||||
|
||||
// Test with defaultport, no defaultaddress and with out
|
||||
ret = parse_port_config(slout, NULL, "DNS", 0, NULL, 42, 0);
|
||||
ret = port_parse_config(slout, NULL, "DNS", 0, NULL, 42, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 0);
|
||||
|
||||
// Test no defaultport, with defaultaddress and with out
|
||||
ret = parse_port_config(slout, NULL, "DNS", 0, "127.0.0.2", 0, 0);
|
||||
ret = port_parse_config(slout, NULL, "DNS", 0, "127.0.0.2", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 0);
|
||||
|
||||
// Test with defaultport, with defaultaddress and out, adds a new port cfg
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
ret = parse_port_config(slout, NULL, "DNS", 0, "127.0.0.2", 42, 0);
|
||||
ret = port_parse_config(slout, NULL, "DNS", 0, "127.0.0.2", 42, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
port_cfg = (port_cfg_t *)smartlist_get(slout, 0);
|
||||
@ -4045,7 +4045,7 @@ test_config_parse_port_config__ports__no_ports_given(void *data)
|
||||
// for a unix address
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
ret = parse_port_config(slout, NULL, "DNS", 0, "/foo/bar/unixdomain",
|
||||
ret = port_parse_config(slout, NULL, "DNS", 0, "/foo/bar/unixdomain",
|
||||
42, CL_PORT_IS_UNIXSOCKET);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4076,28 +4076,28 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
|
||||
// Test error when encounters an invalid Port specification
|
||||
config_port_invalid = mock_config_line("DNSPort", "");
|
||||
ret = parse_port_config(NULL, config_port_invalid, "DNS", 0, NULL,
|
||||
ret = port_parse_config(NULL, config_port_invalid, "DNS", 0, NULL,
|
||||
0, 0);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
// Test error when encounters an empty unix domain specification
|
||||
config_free_lines(config_port_invalid); config_port_invalid = NULL;
|
||||
config_port_invalid = mock_config_line("DNSPort", "unix:");
|
||||
ret = parse_port_config(NULL, config_port_invalid, "DNS", 0, NULL,
|
||||
ret = port_parse_config(NULL, config_port_invalid, "DNS", 0, NULL,
|
||||
0, 0);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
// Test error when encounters a unix domain specification but the listener
|
||||
// doesn't support domain sockets
|
||||
config_port_valid = mock_config_line("DNSPort", "unix:/tmp/foo/bar");
|
||||
ret = parse_port_config(NULL, config_port_valid, "DNS",
|
||||
ret = port_parse_config(NULL, config_port_valid, "DNS",
|
||||
CONN_TYPE_AP_DNS_LISTENER, NULL, 0, 0);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
// Test valid unix domain
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
ret = parse_port_config(slout, config_port_valid, "SOCKS",
|
||||
ret = port_parse_config(slout, config_port_valid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, NULL, 0, 0);
|
||||
#ifdef _WIN32
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
@ -4108,7 +4108,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
tt_int_op(port_cfg->port, OP_EQ, 0);
|
||||
tt_int_op(port_cfg->is_unix_addr, OP_EQ, 1);
|
||||
tt_str_op(port_cfg->unix_addr, OP_EQ, "/tmp/foo/bar");
|
||||
/* Test entry port defaults as initialised in parse_port_config */
|
||||
/* Test entry port defaults as initialised in port_parse_config */
|
||||
tt_int_op(port_cfg->entry_cfg.dns_request, OP_EQ, 1);
|
||||
tt_int_op(port_cfg->entry_cfg.ipv4_traffic, OP_EQ, 1);
|
||||
tt_int_op(port_cfg->entry_cfg.onion_traffic, OP_EQ, 1);
|
||||
@ -4122,7 +4122,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
"unix:/tmp/foo/bar NoIPv4Traffic "
|
||||
"NoIPv6Traffic "
|
||||
"NoOnionTraffic");
|
||||
ret = parse_port_config(NULL, config_port_invalid, "SOCKS",
|
||||
ret = port_parse_config(NULL, config_port_invalid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, NULL, 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
@ -4131,7 +4131,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
config_free_lines(config_port_invalid); config_port_invalid = NULL;
|
||||
config_port_invalid = mock_config_line("DNSPort",
|
||||
"127.0.0.1:80 NoDNSRequest");
|
||||
ret = parse_port_config(NULL, config_port_invalid, "DNS",
|
||||
ret = port_parse_config(NULL, config_port_invalid, "DNS",
|
||||
CONN_TYPE_AP_DNS_LISTENER, NULL, 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
@ -4144,7 +4144,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
config_port_valid = mock_config_line("DNSPort", "127.0.0.1:80 "
|
||||
"NoIPv6Traffic "
|
||||
"NoIPv4Traffic NoOnionTraffic");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS",
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS",
|
||||
CONN_TYPE_AP_DNS_LISTENER, NULL, 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
@ -4160,7 +4160,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
config_port_invalid = mock_config_line("SOCKSPort",
|
||||
"NoIPv6Traffic "
|
||||
"unix:/tmp/foo/bar NoIPv4Traffic");
|
||||
ret = parse_port_config(NULL, config_port_invalid, "SOCKS",
|
||||
ret = port_parse_config(NULL, config_port_invalid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, NULL, 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
@ -4173,7 +4173,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/foo/bar "
|
||||
"NoIPv6Traffic "
|
||||
"NoDNSRequest NoIPv4Traffic");
|
||||
ret = parse_port_config(slout, config_port_valid, "SOCKS",
|
||||
ret = port_parse_config(slout, config_port_valid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, NULL, 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
#ifdef _WIN32
|
||||
@ -4195,7 +4195,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
config_port_valid = mock_config_line("SOCKSPort", "unix:\"/tmp/foo/ bar\" "
|
||||
"NoIPv6Traffic "
|
||||
"NoDNSRequest NoIPv4Traffic");
|
||||
ret = parse_port_config(slout, config_port_valid, "SOCKS",
|
||||
ret = port_parse_config(slout, config_port_valid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, NULL, 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
#ifdef _WIN32
|
||||
@ -4217,7 +4217,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
config_port_valid = mock_config_line("SOCKSPort", "unix:\"/tmp/foo/ bar "
|
||||
"NoIPv6Traffic "
|
||||
"NoDNSRequest NoIPv4Traffic");
|
||||
ret = parse_port_config(slout, config_port_valid, "SOCKS",
|
||||
ret = port_parse_config(slout, config_port_valid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, NULL, 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
@ -4229,7 +4229,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
config_port_valid = mock_config_line("SOCKSPort", "unix:\"\" "
|
||||
"NoIPv6Traffic "
|
||||
"NoDNSRequest NoIPv4Traffic");
|
||||
ret = parse_port_config(slout, config_port_valid, "SOCKS",
|
||||
ret = port_parse_config(slout, config_port_valid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, NULL, 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
@ -4240,7 +4240,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/foo/bar "
|
||||
"OnionTrafficOnly");
|
||||
ret = parse_port_config(slout, config_port_valid, "SOCKS",
|
||||
ret = port_parse_config(slout, config_port_valid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, NULL, 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
#ifdef _WIN32
|
||||
@ -4261,7 +4261,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/foo/bar "
|
||||
"NoIPv4Traffic IPv6Traffic");
|
||||
ret = parse_port_config(slout, config_port_valid, "SOCKS",
|
||||
ret = port_parse_config(slout, config_port_valid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, NULL, 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
#ifdef _WIN32
|
||||
@ -4280,7 +4280,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/foo/bar "
|
||||
"IPv4Traffic IPv6Traffic");
|
||||
ret = parse_port_config(slout, config_port_valid, "SOCKS",
|
||||
ret = port_parse_config(slout, config_port_valid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, NULL, 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
#ifdef _WIN32
|
||||
@ -4296,28 +4296,28 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
// Test failure if we specify world writable for an IP Port
|
||||
config_free_lines(config_port_invalid); config_port_invalid = NULL;
|
||||
config_port_invalid = mock_config_line("DNSPort", "42 WorldWritable");
|
||||
ret = parse_port_config(NULL, config_port_invalid, "DNS", 0,
|
||||
ret = port_parse_config(NULL, config_port_invalid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
// Test failure if we specify group writable for an IP Port
|
||||
config_free_lines(config_port_invalid); config_port_invalid = NULL;
|
||||
config_port_invalid = mock_config_line("DNSPort", "42 GroupWritable");
|
||||
ret = parse_port_config(NULL, config_port_invalid, "DNS", 0,
|
||||
ret = port_parse_config(NULL, config_port_invalid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
// Test failure if we specify group writable for an IP Port
|
||||
config_free_lines(config_port_invalid); config_port_invalid = NULL;
|
||||
config_port_invalid = mock_config_line("DNSPort", "42 RelaxDirModeCheck");
|
||||
ret = parse_port_config(NULL, config_port_invalid, "DNS", 0,
|
||||
ret = port_parse_config(NULL, config_port_invalid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
// Test success with only a port (this will fail without a default address)
|
||||
config_free_lines(config_port_valid); config_port_valid = NULL;
|
||||
config_port_valid = mock_config_line("DNSPort", "42");
|
||||
ret = parse_port_config(NULL, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(NULL, config_port_valid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
|
||||
@ -4326,7 +4326,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 IsolateDestPort");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4339,7 +4339,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 NoIsolateDestPorts");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4352,7 +4352,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 IsolateDestAddr");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4365,7 +4365,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 IsolateSOCKSAuth");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4378,7 +4378,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 IsolateClientProtocol");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4391,7 +4391,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 IsolateClientAddr");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4402,7 +4402,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
// Test success with ignored unknown options
|
||||
config_free_lines(config_port_valid); config_port_valid = NULL;
|
||||
config_port_valid = mock_config_line("DNSPort", "42 ThisOptionDoesntExist");
|
||||
ret = parse_port_config(NULL, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(NULL, config_port_valid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
|
||||
@ -4411,7 +4411,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 NoIsolateSOCKSAuth");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.3", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4424,7 +4424,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("SOCKSPort",
|
||||
"42 IPv6Traffic PreferIPv6");
|
||||
ret = parse_port_config(slout, config_port_valid, "SOCKS",
|
||||
ret = port_parse_config(slout, config_port_valid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, "127.0.0.42", 0,
|
||||
CL_PORT_TAKES_HOSTNAMES);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
@ -4437,7 +4437,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 CacheIPv4DNS");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.42", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4450,7 +4450,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 CacheIPv6DNS");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.42", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4463,7 +4463,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 NoCacheIPv4DNS");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.42", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4476,7 +4476,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 CacheDNS");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.42", 0, CL_PORT_TAKES_HOSTNAMES);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4489,7 +4489,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 UseIPv4Cache");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.42", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4502,7 +4502,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 UseIPv6Cache");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.42", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4515,7 +4515,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 UseDNSCache");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.42", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4528,7 +4528,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 NoPreferIPv6Automap");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.42", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4540,7 +4540,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 PreferSOCKSNoAuth");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.42", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4555,14 +4555,14 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
config_port_invalid = mock_config_line("DNSPort", "0");
|
||||
config_port_valid = mock_config_line("DNSPort", "42");
|
||||
config_port_invalid->next = config_port_valid;
|
||||
ret = parse_port_config(slout, config_port_invalid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_invalid, "DNS", 0,
|
||||
"127.0.0.42", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
// Test success with warn non-local control
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
ret = parse_port_config(slout, config_port_valid, "Control",
|
||||
ret = port_parse_config(slout, config_port_valid, "Control",
|
||||
CONN_TYPE_CONTROL_LISTENER, "127.0.0.42", 0,
|
||||
CL_PORT_WARN_NONLOCAL);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
@ -4570,7 +4570,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
// Test success with warn non-local listener
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
ret = parse_port_config(slout, config_port_valid, "ExtOR",
|
||||
ret = port_parse_config(slout, config_port_valid, "ExtOR",
|
||||
CONN_TYPE_EXT_OR_LISTENER, "127.0.0.42", 0,
|
||||
CL_PORT_WARN_NONLOCAL);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
@ -4578,12 +4578,12 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
// Test success with warn non-local other
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.42", 0, CL_PORT_WARN_NONLOCAL);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
|
||||
// Test success with warn non-local other without out
|
||||
ret = parse_port_config(NULL, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(NULL, config_port_valid, "DNS", 0,
|
||||
"127.0.0.42", 0, CL_PORT_WARN_NONLOCAL);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
|
||||
@ -4594,7 +4594,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 IPv4Traffic "
|
||||
"IPv6Traffic");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.44", 0,
|
||||
CL_PORT_TAKES_HOSTNAMES |
|
||||
CL_PORT_NO_STREAM_OPTIONS);
|
||||
@ -4609,7 +4609,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_invalid = mock_config_line("DNSPort", "42 SessionGroup=invalid");
|
||||
ret = parse_port_config(slout, config_port_invalid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_invalid, "DNS", 0,
|
||||
"127.0.0.44", 0, CL_PORT_NO_STREAM_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
@ -4619,7 +4619,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_invalid = mock_config_line("DNSPort", "42 SessionGroup=123");
|
||||
ret = parse_port_config(slout, config_port_invalid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_invalid, "DNS", 0,
|
||||
"127.0.0.44", 0, CL_PORT_NO_STREAM_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
@ -4629,7 +4629,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
smartlist_clear(slout);
|
||||
config_port_invalid = mock_config_line("DNSPort", "42 SessionGroup=123 "
|
||||
"SessionGroup=321");
|
||||
ret = parse_port_config(slout, config_port_invalid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_invalid, "DNS", 0,
|
||||
"127.0.0.44", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
@ -4638,7 +4638,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "42 SessionGroup=1111122");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.44", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4650,7 +4650,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "0");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.45", 0, CL_PORT_IS_UNIXSOCKET);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 0);
|
||||
@ -4660,7 +4660,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "something");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.45", 0, CL_PORT_IS_UNIXSOCKET);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4673,7 +4673,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "auto");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.46", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4687,7 +4687,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "AuTo");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.46", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4701,7 +4701,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "127.0.0.122:auto");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.46", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4714,7 +4714,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
config_free_lines(config_port_invalid); config_port_invalid = NULL;
|
||||
config_port_invalid = mock_config_line("DNSPort", "invalidstuff!!:auto");
|
||||
MOCK(tor_addr_lookup, mock_tor_addr_lookup__fail_on_bad_addrs);
|
||||
ret = parse_port_config(NULL, config_port_invalid, "DNS", 0,
|
||||
ret = port_parse_config(NULL, config_port_invalid, "DNS", 0,
|
||||
"127.0.0.46", 0, 0);
|
||||
UNMOCK(tor_addr_lookup);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
@ -4724,7 +4724,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "127.0.0.123:656");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0,
|
||||
"127.0.0.46", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4738,7 +4738,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_invalid = mock_config_line("DNSPort", "something wrong");
|
||||
ret = parse_port_config(slout, config_port_invalid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_invalid, "DNS", 0,
|
||||
"127.0.0.46", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
@ -4747,7 +4747,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_invalid = mock_config_line("DNSPort", "127.0.1.0:123:auto");
|
||||
ret = parse_port_config(slout, config_port_invalid, "DNS", 0,
|
||||
ret = port_parse_config(slout, config_port_invalid, "DNS", 0,
|
||||
"127.0.0.46", 0, 0);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
@ -4757,7 +4757,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/somewhere");
|
||||
ret = parse_port_config(slout, config_port_valid, "SOCKS",
|
||||
ret = port_parse_config(slout, config_port_valid, "SOCKS",
|
||||
CONN_TYPE_AP_LISTENER, "127.0.0.46", 0,
|
||||
CL_PORT_DFLT_GROUP_WRITABLE);
|
||||
#ifdef _WIN32
|
||||
@ -4793,7 +4793,7 @@ test_config_parse_port_config__ports__server_options(void *data)
|
||||
config_free_lines(config_port_valid); config_port_valid = NULL;
|
||||
config_port_valid = mock_config_line("DNSPort",
|
||||
"127.0.0.124:656 NoAdvertise");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0, NULL, 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0, NULL, 0,
|
||||
CL_PORT_SERVER_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4806,7 +4806,7 @@ test_config_parse_port_config__ports__server_options(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "127.0.0.124:656 NoListen");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0, NULL, 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0, NULL, 0,
|
||||
CL_PORT_SERVER_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4820,7 +4820,7 @@ test_config_parse_port_config__ports__server_options(void *data)
|
||||
smartlist_clear(slout);
|
||||
config_port_invalid = mock_config_line("DNSPort", "127.0.0.124:656 NoListen "
|
||||
"NoAdvertise");
|
||||
ret = parse_port_config(slout, config_port_invalid, "DNS", 0, NULL,
|
||||
ret = port_parse_config(slout, config_port_invalid, "DNS", 0, NULL,
|
||||
0, CL_PORT_SERVER_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
@ -4829,7 +4829,7 @@ test_config_parse_port_config__ports__server_options(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "127.0.0.124:656 IPv4Only");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0, NULL, 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0, NULL, 0,
|
||||
CL_PORT_SERVER_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4842,7 +4842,7 @@ test_config_parse_port_config__ports__server_options(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "[::1]:656 IPv6Only");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0, NULL, 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0, NULL, 0,
|
||||
CL_PORT_SERVER_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4856,7 +4856,7 @@ test_config_parse_port_config__ports__server_options(void *data)
|
||||
smartlist_clear(slout);
|
||||
config_port_invalid = mock_config_line("DNSPort", "127.0.0.124:656 IPv6Only "
|
||||
"IPv4Only");
|
||||
ret = parse_port_config(slout, config_port_invalid, "DNS", 0, NULL,
|
||||
ret = port_parse_config(slout, config_port_invalid, "DNS", 0, NULL,
|
||||
0, CL_PORT_SERVER_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
@ -4865,7 +4865,7 @@ test_config_parse_port_config__ports__server_options(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_valid = mock_config_line("DNSPort", "127.0.0.124:656 unknown");
|
||||
ret = parse_port_config(slout, config_port_valid, "DNS", 0, NULL, 0,
|
||||
ret = port_parse_config(slout, config_port_valid, "DNS", 0, NULL, 0,
|
||||
CL_PORT_SERVER_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tt_int_op(smartlist_len(slout), OP_EQ, 1);
|
||||
@ -4876,7 +4876,7 @@ test_config_parse_port_config__ports__server_options(void *data)
|
||||
smartlist_clear(slout);
|
||||
config_port_invalid = mock_config_line("DNSPort",
|
||||
"127.0.0.124:656 IPv6Only");
|
||||
ret = parse_port_config(slout, config_port_invalid, "DNS", 0, NULL,
|
||||
ret = port_parse_config(slout, config_port_invalid, "DNS", 0, NULL,
|
||||
0, CL_PORT_SERVER_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
@ -4885,7 +4885,7 @@ test_config_parse_port_config__ports__server_options(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_invalid = mock_config_line("DNSPort", "[::1]:656 IPv4Only");
|
||||
ret = parse_port_config(slout, config_port_invalid, "DNS", 0, NULL,
|
||||
ret = port_parse_config(slout, config_port_invalid, "DNS", 0, NULL,
|
||||
0, CL_PORT_SERVER_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
@ -4894,7 +4894,7 @@ test_config_parse_port_config__ports__server_options(void *data)
|
||||
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
|
||||
smartlist_clear(slout);
|
||||
config_port_invalid = mock_config_line("ORPort", "unix:\"\"");
|
||||
ret = parse_port_config(slout, config_port_invalid, "ORPort", 0, NULL,
|
||||
ret = port_parse_config(slout, config_port_invalid, "ORPort", 0, NULL,
|
||||
0, CL_PORT_SERVER_OPTIONS);
|
||||
tt_int_op(ret, OP_EQ, -1);
|
||||
|
||||
|
@ -119,7 +119,7 @@ test_dir_handle_get_v1_command_not_found(void *data)
|
||||
conn = new_dir_conn();
|
||||
|
||||
// no frontpage configured
|
||||
tt_ptr_op(get_dirportfrontpage(), OP_EQ, NULL);
|
||||
tt_ptr_op(relay_get_dirportfrontpage(), OP_EQ, NULL);
|
||||
|
||||
/* V1 path */
|
||||
tt_int_op(directory_handle_command_get(conn, GET("/tor/"), NULL, 0),
|
||||
@ -153,9 +153,9 @@ test_dir_handle_get_v1_command(void *data)
|
||||
(void) data;
|
||||
|
||||
MOCK(connection_write_to_buf_impl_, connection_write_to_buf_mock);
|
||||
MOCK(get_dirportfrontpage, mock_get_dirportfrontpage);
|
||||
MOCK(relay_get_dirportfrontpage, mock_get_dirportfrontpage);
|
||||
|
||||
exp_body = get_dirportfrontpage();
|
||||
exp_body = relay_get_dirportfrontpage();
|
||||
body_len = strlen(exp_body);
|
||||
|
||||
conn = new_dir_conn();
|
||||
@ -178,7 +178,7 @@ test_dir_handle_get_v1_command(void *data)
|
||||
|
||||
done:
|
||||
UNMOCK(connection_write_to_buf_impl_);
|
||||
UNMOCK(get_dirportfrontpage);
|
||||
UNMOCK(relay_get_dirportfrontpage);
|
||||
connection_free_minimal(TO_CONN(conn));
|
||||
tor_free(header);
|
||||
tor_free(body);
|
||||
|
Loading…
Reference in New Issue
Block a user