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:
teor 2019-11-05 11:28:57 +10:00
parent 96334d6f7f
commit cb8ebc0b4c
13 changed files with 187 additions and 187 deletions

View File

@ -1906,7 +1906,7 @@ options_act,(const or_options_t *old_options))
if (!options->DisableNetwork) { if (!options->DisableNetwork) {
if (options->ClientTransportPlugin) { if (options->ClientTransportPlugin) {
for (cl = options->ClientTransportPlugin; cl; cl = cl->next) { 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 // LCOV_EXCL_START
log_warn(LD_BUG, log_warn(LD_BUG,
"Previously validated ClientTransportPlugin line " "Previously validated ClientTransportPlugin line "
@ -2843,7 +2843,7 @@ validate_ports_csv(smartlist_t *sl, const char *name, char **msg)
* Else return 0. * Else return 0.
*/ */
int 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) { if (*value > ROUTER_MAX_DECLARED_BANDWIDTH) {
/* This handles an understandable special case where somebody says "2gb" /* 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) if (options->KeepalivePeriod < 1)
REJECT("KeepalivePeriod option must be positive."); REJECT("KeepalivePeriod option must be positive.");
if (ensure_bandwidth_cap(&options->BandwidthRate, if (config_ensure_bandwidth_cap(&options->BandwidthRate,
"BandwidthRate", msg) < 0) "BandwidthRate", msg) < 0)
return -1; return -1;
if (ensure_bandwidth_cap(&options->BandwidthBurst, if (config_ensure_bandwidth_cap(&options->BandwidthBurst,
"BandwidthBurst", msg) < 0) "BandwidthBurst", msg) < 0)
return -1; 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) { 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."); 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. * - If it's a managed proxy line, launch the managed proxy.
*/ */
int int
parse_transport_line(const or_options_t *options, pt_parse_transport_line(const or_options_t *options,
const char *line, int validate_only, const char *line, int validate_only,
int server) int server)
{ {
@ -5775,7 +5775,7 @@ warn_client_dns_cache(const char *option, int disabling)
* on success, -1 on failure. * on success, -1 on failure.
*/ */
int int
parse_port_config(smartlist_t *out, port_parse_config(smartlist_t *out,
const config_line_t *ports, const config_line_t *ports,
const char *portname, const char *portname,
int listener_type, int listener_type,
@ -6208,7 +6208,7 @@ parse_port_config(smartlist_t *out,
if (is_control) if (is_control)
warn_nonlocal_controller_ports(out, forbid_nonlocal); warn_nonlocal_controller_ports(out, forbid_nonlocal);
else if (is_ext_orport) else if (is_ext_orport)
warn_nonlocal_ext_orports(out, portname); port_warn_nonlocal_ext_orports(out, portname);
else else
warn_nonlocal_client_ports(out, portname, listener_type); 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 * <b>listenertype</b>. Do not count no_listen ports. Only count unix
* sockets if count_sockets is true. */ * sockets if count_sockets is true. */
int int
count_real_listeners(const smartlist_t *ports, int listenertype, port_count_real_listeners(const smartlist_t *ports, int listenertype,
int count_sockets) int count_sockets)
{ {
int n = 0; int n = 0;
@ -6271,7 +6271,7 @@ parse_ports(or_options_t *options, int validate_only,
const unsigned gw_flag = options->UnixSocksGroupWritable ? const unsigned gw_flag = options->UnixSocksGroupWritable ?
CL_PORT_DFLT_GROUP_WRITABLE : 0; CL_PORT_DFLT_GROUP_WRITABLE : 0;
if (parse_port_config(ports, if (port_parse_config(ports,
options->SocksPort_lines, options->SocksPort_lines,
"Socks", CONN_TYPE_AP_LISTENER, "Socks", CONN_TYPE_AP_LISTENER,
"127.0.0.1", 9050, "127.0.0.1", 9050,
@ -6280,7 +6280,7 @@ parse_ports(or_options_t *options, int validate_only,
*msg = tor_strdup("Invalid SocksPort configuration"); *msg = tor_strdup("Invalid SocksPort configuration");
goto err; goto err;
} }
if (parse_port_config(ports, if (port_parse_config(ports,
options->DNSPort_lines, options->DNSPort_lines,
"DNS", CONN_TYPE_AP_DNS_LISTENER, "DNS", CONN_TYPE_AP_DNS_LISTENER,
"127.0.0.1", 0, "127.0.0.1", 0,
@ -6288,7 +6288,7 @@ parse_ports(or_options_t *options, int validate_only,
*msg = tor_strdup("Invalid DNSPort configuration"); *msg = tor_strdup("Invalid DNSPort configuration");
goto err; goto err;
} }
if (parse_port_config(ports, if (port_parse_config(ports,
options->TransPort_lines, options->TransPort_lines,
"Trans", CONN_TYPE_AP_TRANS_LISTENER, "Trans", CONN_TYPE_AP_TRANS_LISTENER,
"127.0.0.1", 0, "127.0.0.1", 0,
@ -6296,7 +6296,7 @@ parse_ports(or_options_t *options, int validate_only,
*msg = tor_strdup("Invalid TransPort configuration"); *msg = tor_strdup("Invalid TransPort configuration");
goto err; goto err;
} }
if (parse_port_config(ports, if (port_parse_config(ports,
options->NATDPort_lines, options->NATDPort_lines,
"NATD", CONN_TYPE_AP_NATD_LISTENER, "NATD", CONN_TYPE_AP_NATD_LISTENER,
"127.0.0.1", 0, "127.0.0.1", 0,
@ -6304,7 +6304,7 @@ parse_ports(or_options_t *options, int validate_only,
*msg = tor_strdup("Invalid NatdPort configuration"); *msg = tor_strdup("Invalid NatdPort configuration");
goto err; goto err;
} }
if (parse_port_config(ports, if (port_parse_config(ports,
options->HTTPTunnelPort_lines, options->HTTPTunnelPort_lines,
"HTTP Tunnel", CONN_TYPE_AP_HTTP_CONNECT_LISTENER, "HTTP Tunnel", CONN_TYPE_AP_HTTP_CONNECT_LISTENER,
"127.0.0.1", 0, "127.0.0.1", 0,
@ -6324,7 +6324,7 @@ parse_ports(or_options_t *options, int validate_only,
if (options->ControlSocketsGroupWritable) if (options->ControlSocketsGroupWritable)
control_port_flags |= CL_PORT_DFLT_GROUP_WRITABLE; control_port_flags |= CL_PORT_DFLT_GROUP_WRITABLE;
if (parse_port_config(ports, if (port_parse_config(ports,
options->ControlPort_lines, options->ControlPort_lines,
"Control", CONN_TYPE_CONTROL_LISTENER, "Control", CONN_TYPE_CONTROL_LISTENER,
"127.0.0.1", 0, "127.0.0.1", 0,
@ -6333,7 +6333,7 @@ parse_ports(or_options_t *options, int validate_only,
goto err; goto err;
} }
if (parse_port_config(ports, options->ControlSocket, if (port_parse_config(ports, options->ControlSocket,
"ControlSocket", "ControlSocket",
CONN_TYPE_CONTROL_LISTENER, NULL, 0, CONN_TYPE_CONTROL_LISTENER, NULL, 0,
control_port_flags | CL_PORT_IS_UNIXSOCKET) < 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; goto err;
*n_ports_out = smartlist_len(ports); *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 /* Update the *Port_set options. The !! here is to force a boolean out of
an integer. */ an integer. */
update_port_set_relay(options, ports); port_update_port_set_relay(options, ports);
options->SocksPort_set = 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 = 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 = 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 = 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 */ /* Use options->ControlSocket to test if a control socket is set */
options->ControlPort_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 = 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) { if (world_writable_control_socket) {
SMARTLIST_FOREACH(ports, port_cfg_t *, p, SMARTLIST_FOREACH(ports, port_cfg_t *, p,

View File

@ -243,7 +243,7 @@ bridge_line_t *parse_bridge_line(const char *line);
/* Port helper functions. */ /* Port helper functions. */
int options_any_client_port_set(const or_options_t *options); 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 struct config_line_t *ports,
const char *portname, const char *portname,
int listener_type, 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)) FREE_AND_NULL(port_cfg_t, port_cfg_free_, (port))
void port_cfg_free_(port_cfg_t *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 listenertype,
int count_sockets); 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, const char *line, int validate_only,
int server); 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 #ifdef CONFIG_PRIVATE

View File

@ -639,7 +639,7 @@ get_stored_bindaddr_for_server_transport(const char *transport)
{ {
/* See if the user explicitly asked for a specific listening /* See if the user explicitly asked for a specific listening
address for this transport. */ 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) if (conf_bindaddr)
return conf_bindaddr; return conf_bindaddr;
} }

View File

@ -1281,7 +1281,7 @@ get_transport_options_for_server_proxy(const managed_proxy_t *mp)
string. */ string. */
SMARTLIST_FOREACH_BEGIN(mp->transports_to_launch, const char *, transport) { SMARTLIST_FOREACH_BEGIN(mp->transports_to_launch, const char *, transport) {
smartlist_t *options_tmp_sl = NULL; 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) if (!options_tmp_sl)
continue; continue;

View File

@ -156,10 +156,10 @@ options_validate_dirauth_bandwidth(const or_options_t *old_options,
if (!authdir_mode(options)) if (!authdir_mode(options))
return 0; return 0;
if (ensure_bandwidth_cap(&options->AuthDirFastGuarantee, if (config_ensure_bandwidth_cap(&options->AuthDirFastGuarantee,
"AuthDirFastGuarantee", msg) < 0) "AuthDirFastGuarantee", msg) < 0)
return -1; return -1;
if (ensure_bandwidth_cap(&options->AuthDirGuardBWGuarantee, if (config_ensure_bandwidth_cap(&options->AuthDirGuardBWGuarantee,
"AuthDirGuardBWGuarantee", msg) < 0) "AuthDirGuardBWGuarantee", msg) < 0)
return -1; return -1;

View File

@ -479,7 +479,7 @@ static int
handle_get_frontpage(dir_connection_t *conn, const get_handler_args_t *args) handle_get_frontpage(dir_connection_t *conn, const get_handler_args_t *args)
{ {
(void) args; /* unused */ (void) args; /* unused */
const char *frontpage = get_dirportfrontpage(); const char *frontpage = relay_get_dirportfrontpage();
if (frontpage) { if (frontpage) {
size_t dlen; size_t dlen;

View File

@ -71,7 +71,7 @@ static char *global_dirfrontpagecontents = NULL;
/** Return the contents of our frontpage string, or NULL if not configured. */ /** Return the contents of our frontpage string, or NULL if not configured. */
MOCK_IMPL(const char*, MOCK_IMPL(const char*,
get_dirportfrontpage, (void)) relay_get_dirportfrontpage, (void))
{ {
return global_dirfrontpagecontents; return global_dirfrontpagecontents;
} }
@ -88,33 +88,33 @@ relay_config_free_all(void)
/** Return the bandwidthrate that we are going to report to the authorities /** Return the bandwidthrate that we are going to report to the authorities
* based on the config options. */ * based on the config options. */
uint32_t uint32_t
get_effective_bwrate(const or_options_t *options) relay_get_effective_bwrate(const or_options_t *options)
{ {
uint64_t bw = options->BandwidthRate; uint64_t bw = options->BandwidthRate;
if (bw > options->MaxAdvertisedBandwidth) if (bw > options->MaxAdvertisedBandwidth)
bw = options->MaxAdvertisedBandwidth; bw = options->MaxAdvertisedBandwidth;
if (options->RelayBandwidthRate > 0 && bw > options->RelayBandwidthRate) if (options->RelayBandwidthRate > 0 && bw > options->RelayBandwidthRate)
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 (uint32_t)bw;
} }
/** Return the bandwidthburst that we are going to report to the authorities /** Return the bandwidthburst that we are going to report to the authorities
* based on the config options. */ * based on the config options. */
uint32_t uint32_t
get_effective_bwburst(const or_options_t *options) relay_get_effective_bwburst(const or_options_t *options)
{ {
uint64_t bw = options->BandwidthBurst; uint64_t bw = options->BandwidthBurst;
if (options->RelayBandwidthBurst > 0 && bw > options->RelayBandwidthBurst) if (options->RelayBandwidthBurst > 0 && bw > options->RelayBandwidthBurst)
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; return (uint32_t)bw;
} }
/** Warn for every Extended ORPort port in <b>ports</b> that is on a /** Warn for every Extended ORPort port in <b>ports</b> that is on a
* publicly routable address. */ * publicly routable address. */
void 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) { SMARTLIST_FOREACH_BEGIN(ports, const port_cfg_t *, port) {
if (port->type != CONN_TYPE_EXT_OR_LISTENER) 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. * of the problem and return -1.
**/ **/
int int
parse_ports_relay(or_options_t *options, port_parse_ports_relay(or_options_t *options,
char **msg, char **msg,
smartlist_t *ports_out, smartlist_t *ports_out,
int *have_low_ports_out) int *have_low_ports_out)
@ -261,7 +261,7 @@ parse_ports_relay(or_options_t *options,
goto err; goto err;
} }
if (parse_port_config(ports, if (port_parse_config(ports,
options->ORPort_lines, options->ORPort_lines,
"OR", CONN_TYPE_OR_LISTENER, "OR", CONN_TYPE_OR_LISTENER,
"0.0.0.0", 0, "0.0.0.0", 0,
@ -269,7 +269,7 @@ parse_ports_relay(or_options_t *options,
*msg = tor_strdup("Invalid ORPort configuration"); *msg = tor_strdup("Invalid ORPort configuration");
goto err; goto err;
} }
if (parse_port_config(ports, if (port_parse_config(ports,
options->ExtORPort_lines, options->ExtORPort_lines,
"ExtOR", CONN_TYPE_EXT_OR_LISTENER, "ExtOR", CONN_TYPE_EXT_OR_LISTENER,
"127.0.0.1", 0, "127.0.0.1", 0,
@ -277,7 +277,7 @@ parse_ports_relay(or_options_t *options,
*msg = tor_strdup("Invalid ExtORPort configuration"); *msg = tor_strdup("Invalid ExtORPort configuration");
goto err; goto err;
} }
if (parse_port_config(ports, if (port_parse_config(ports,
options->DirPort_lines, options->DirPort_lines,
"Dir", CONN_TYPE_DIR_LISTENER, "Dir", CONN_TYPE_DIR_LISTENER,
"0.0.0.0", 0, "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>. */ /** Update the relay *Port_set values in <b>options</b> from <b>ports</b>. */
void void
update_port_set_relay(or_options_t *options, port_update_port_set_relay(or_options_t *options,
const smartlist_t *ports) const smartlist_t *ports)
{ {
if (BUG(!options)) 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 /* Update the relay *Port_set options. The !! here is to force a boolean
* out of an integer. */ * out of an integer. */
options->ORPort_set = 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 = 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 = 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 /* 31851: the tests expect us to validate bandwidths, even when we are not
* in relay mode. */ * in relay mode. */
if (ensure_bandwidth_cap(&options->MaxAdvertisedBandwidth, if (config_ensure_bandwidth_cap(&options->MaxAdvertisedBandwidth,
"MaxAdvertisedBandwidth", msg) < 0) "MaxAdvertisedBandwidth", msg) < 0)
return -1; return -1;
if (ensure_bandwidth_cap(&options->RelayBandwidthRate, if (config_ensure_bandwidth_cap(&options->RelayBandwidthRate,
"RelayBandwidthRate", msg) < 0) "RelayBandwidthRate", msg) < 0)
return -1; return -1;
if (ensure_bandwidth_cap(&options->RelayBandwidthBurst, if (config_ensure_bandwidth_cap(&options->RelayBandwidthBurst,
"RelayBandwidthBurst", msg) < 0) "RelayBandwidthBurst", msg) < 0)
return -1; return -1;
if (ensure_bandwidth_cap(&options->PerConnBWRate, if (config_ensure_bandwidth_cap(&options->PerConnBWRate,
"PerConnBWRate", msg) < 0) "PerConnBWRate", msg) < 0)
return -1; return -1;
if (ensure_bandwidth_cap(&options->PerConnBWBurst, if (config_ensure_bandwidth_cap(&options->PerConnBWBurst,
"PerConnBWBurst", msg) < 0) "PerConnBWBurst", msg) < 0)
return -1; 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(DirCache);
YES_IF_CHANGED_BOOL(AssumeReachable); YES_IF_CHANGED_BOOL(AssumeReachable);
if (get_effective_bwrate(old_options) != get_effective_bwrate(new_options) || if (relay_get_effective_bwrate(old_options) != relay_get_effective_bwrate(new_options) ||
get_effective_bwburst(old_options) != relay_get_effective_bwburst(old_options) !=
get_effective_bwburst(new_options) || relay_get_effective_bwburst(new_options) ||
public_server_mode(old_options) != public_server_mode(new_options)) public_server_mode(old_options) != public_server_mode(new_options))
return 1; return 1;

View File

@ -25,20 +25,20 @@ int options_validate_relay_mode(const or_options_t *old_options,
or_options_t *options, or_options_t *options,
char **msg); char **msg);
MOCK_DECL(const char*, get_dirportfrontpage, (void)); MOCK_DECL(const char*, relay_get_dirportfrontpage, (void));
void relay_config_free_all(void); void relay_config_free_all(void);
uint32_t get_effective_bwrate(const or_options_t *options); uint32_t relay_get_effective_bwrate(const or_options_t *options);
uint32_t get_effective_bwburst(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); const char *portname);
int parse_ports_relay(or_options_t *options, int port_parse_ports_relay(or_options_t *options,
char **msg, char **msg,
smartlist_t *ports_out, smartlist_t *ports_out,
int *have_low_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); const smartlist_t *ports);
int options_validate_relay_os(const or_options_t *old_options, 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; return 0;
} }
#define get_dirportfrontpage() \ #define relay_get_dirportfrontpage() \
(NULL) (NULL)
#define relay_config_free_all() \ #define relay_config_free_all() \
STMT_BEGIN STMT_END STMT_BEGIN STMT_END
#define get_effective_bwrate(options) \ #define relay_get_effective_bwrate(options) \
(((void)(options)),0) (((void)(options)),0)
#define get_effective_bwburst(options) \ #define relay_get_effective_bwburst(options) \
(((void)(options)),0) (((void)(options)),0)
#define warn_nonlocal_ext_orports(ports, portname) \ #define port_warn_nonlocal_ext_orports(ports, portname) \
(((void)(ports)),((void)(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)(options)),((void)(msg)),((void)(ports_out)), \
((void)(have_low_ports_out)),0) ((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))) (((void)(options)),((void)(ports)))
#define options_validate_relay_os(old_options, options, msg) \ #define options_validate_relay_os(old_options, options, msg) \

View File

@ -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 * much larger effect on output than input so there is no reason to turn it
* off if using AccountingRule in. */ * off if using AccountingRule in. */
int interval_length = accounting_get_interval_length(); 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; uint64_t acc_bytes;
if (!interval_length) { if (!interval_length) {
log_warn(LD_BUG, "An accounting interval is not allowed to be zero " 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()); ri->protocol_list = tor_strdup(protover_get_supported_protocols());
/* compute ri->bandwidthrate as the min of various options */ /* 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 */ /* 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 */ /* Report bandwidth, unless we're hibernating or shutting down */
ri->bandwidthcapacity = hibernating ? 0 : rep_hist_bandwidth_assess(); ri->bandwidthcapacity = hibernating ? 0 : rep_hist_bandwidth_assess();

View File

@ -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 * it to listen on a specific port. Return a <address:port> string if
* so, otherwise NULL. */ * so, otherwise NULL. */
char * char *
get_transport_bindaddr_from_config(const char *transport) pt_get_bindaddr_from_config(const char *transport)
{ {
config_line_t *cl; config_line_t *cl;
const or_options_t *options = get_options(); 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 * parameters to the pluggable transport. Return a smartlist
* containing the parameters, otherwise NULL. */ * containing the parameters, otherwise NULL. */
smartlist_t * smartlist_t *
get_options_for_server_transport(const char *transport) pt_get_options_for_server_transport(const char *transport)
{ {
config_line_t *cl; config_line_t *cl;
const or_options_t *options = get_options(); 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) { 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."); 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->DisableNetwork) {
if (options->ServerTransportPlugin) { if (options->ServerTransportPlugin) {
for (cl = options->ServerTransportPlugin; cl; cl = cl->next) { 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 // LCOV_EXCL_START
log_warn(LD_BUG, log_warn(LD_BUG,
"Previously validated ServerTransportPlugin line " "Previously validated ServerTransportPlugin line "

View File

@ -23,8 +23,8 @@ int options_validate_server_transport(const or_options_t *old_options,
or_options_t *options, or_options_t *options,
char **msg); char **msg);
char *get_transport_bindaddr_from_config(const char *transport); char *pt_get_bindaddr_from_config(const char *transport);
smartlist_t *get_options_for_server_transport(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); 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; return 0;
} }
#define get_transport_bindaddr_from_config(transport) \ #define pt_get_bindaddr_from_config(transport) \
(((void)(transport)),NULL) (((void)(transport)),NULL)
/* 31851: called from client/transports.c, but only from server code */ /* 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) (((void)(transport)),NULL)
#define options_validate_server_transport(old_options, options, msg) \ #define options_validate_server_transport(old_options, options, msg) \

View File

@ -693,84 +693,84 @@ test_config_parse_transport_plugin_line(void *arg)
int old_transport_is_needed_mock_call_count; int old_transport_is_needed_mock_call_count;
/* Bad transport lines - too short */ /* 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); 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); 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); 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); tt_int_op(r, OP_LT, 0);
/* Test transport list parsing */ /* Test transport list parsing */
r = parse_transport_line(options, r = pt_parse_transport_line(options,
"transport_1 exec /usr/bin/fake-transport", 1, 0); "transport_1 exec /usr/bin/fake-transport", 1, 0);
tt_int_op(r, OP_EQ, 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); "transport_1 exec /usr/bin/fake-transport", 1, 1);
tt_int_op(r, OP_EQ, 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, 0); "transport_1,transport_2 exec /usr/bin/fake-transport", 1, 0);
tt_int_op(r, OP_EQ, 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); "transport_1,transport_2 exec /usr/bin/fake-transport", 1, 1);
tt_int_op(r, OP_EQ, 0); tt_int_op(r, OP_EQ, 0);
/* Bad transport identifiers */ /* Bad transport identifiers */
r = parse_transport_line(options, r = pt_parse_transport_line(options,
"transport_* exec /usr/bin/fake-transport", 1, 0); "transport_* exec /usr/bin/fake-transport", 1, 0);
tt_int_op(r, OP_LT, 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); "transport_* exec /usr/bin/fake-transport", 1, 1);
tt_int_op(r, OP_LT, 0); tt_int_op(r, OP_LT, 0);
/* Check SOCKS cases for client transport */ /* 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); "transport_1 socks4 1.2.3.4:567", 1, 0);
tt_int_op(r, OP_EQ, 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); "transport_1 socks5 1.2.3.4:567", 1, 0);
tt_int_op(r, OP_EQ, 0); tt_int_op(r, OP_EQ, 0);
/* Proxy case for server transport */ /* 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); "transport_1 proxy 1.2.3.4:567", 1, 1);
tt_int_op(r, OP_EQ, 0); tt_int_op(r, OP_EQ, 0);
/* Multiple-transport error exit */ /* 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); "transport_1,transport_2 socks5 1.2.3.4:567", 1, 0);
tt_int_op(r, OP_LT, 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); "transport_1,transport_2 proxy 1.2.3.4:567", 1, 1);
tt_int_op(r, OP_LT, 0); tt_int_op(r, OP_LT, 0);
/* No port error exit */ /* No port error exit */
r = parse_transport_line(options, r = pt_parse_transport_line(options,
"transport_1 socks5 1.2.3.4", 1, 0); "transport_1 socks5 1.2.3.4", 1, 0);
tt_int_op(r, OP_LT, 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); "transport_1 proxy 1.2.3.4", 1, 1);
tt_int_op(r, OP_LT, 0); tt_int_op(r, OP_LT, 0);
/* Unparsable address error exit */ /* Unparsable address error exit */
r = parse_transport_line(options, r = pt_parse_transport_line(options,
"transport_1 socks5 1.2.3:6x7", 1, 0); "transport_1 socks5 1.2.3:6x7", 1, 0);
tt_int_op(r, OP_LT, 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); "transport_1 proxy 1.2.3:6x7", 1, 1);
tt_int_op(r, OP_LT, 0); tt_int_op(r, OP_LT, 0);
/* "Strange {Client|Server}TransportPlugin field" error exit */ /* "Strange {Client|Server}TransportPlugin field" error exit */
r = parse_transport_line(options, r = pt_parse_transport_line(options,
"transport_1 foo bar", 1, 0); "transport_1 foo bar", 1, 0);
tt_int_op(r, OP_LT, 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); "transport_1 foo bar", 1, 1);
tt_int_op(r, OP_LT, 0); tt_int_op(r, OP_LT, 0);
/* No sandbox mode error exit */ /* No sandbox mode error exit */
tmp = options->Sandbox; tmp = options->Sandbox;
options->Sandbox = 1; options->Sandbox = 1;
r = parse_transport_line(options, r = pt_parse_transport_line(options,
"transport_1 exec /usr/bin/fake-transport", 1, 0); "transport_1 exec /usr/bin/fake-transport", 1, 0);
tt_int_op(r, OP_LT, 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); "transport_1 exec /usr/bin/fake-transport", 1, 1);
tt_int_op(r, OP_LT, 0); tt_int_op(r, OP_LT, 0);
options->Sandbox = tmp; options->Sandbox = tmp;
@ -782,7 +782,7 @@ test_config_parse_transport_plugin_line(void *arg)
MOCK(pt_kickstart_proxy, pt_kickstart_proxy_mock); MOCK(pt_kickstart_proxy, pt_kickstart_proxy_mock);
old_pt_kickstart_proxy_mock_call_count = old_pt_kickstart_proxy_mock_call_count =
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); "transport_1 exec /usr/bin/fake-transport", 0, 1);
tt_int_op(r, OP_EQ, 0); tt_int_op(r, OP_EQ, 0);
tt_assert(pt_kickstart_proxy_mock_call_count == tt_assert(pt_kickstart_proxy_mock_call_count ==
@ -790,7 +790,7 @@ test_config_parse_transport_plugin_line(void *arg)
UNMOCK(pt_kickstart_proxy); UNMOCK(pt_kickstart_proxy);
/* This one hits a log line in the !validate_only case only */ /* 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); "transport_1 proxy 1.2.3.4:567", 0, 1);
tt_int_op(r, OP_EQ, 0); 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; transport_add_from_config_mock_call_count;
old_transport_is_needed_mock_call_count = old_transport_is_needed_mock_call_count =
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); "transport_1 exec /usr/bin/fake-transport", 0, 0);
/* Should have succeeded */ /* Should have succeeded */
tt_int_op(r, OP_EQ, 0); 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; transport_add_from_config_mock_call_count;
old_transport_is_needed_mock_call_count = old_transport_is_needed_mock_call_count =
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); "transport_1 exec /usr/bin/fake-transport", 0, 0);
/* Should have succeeded */ /* Should have succeeded */
tt_int_op(r, OP_EQ, 0); 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; transport_add_from_config_mock_call_count;
old_transport_is_needed_mock_call_count = old_transport_is_needed_mock_call_count =
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); "transport_1 socks5 1.2.3.4:567", 0, 0);
/* Should have succeeded */ /* Should have succeeded */
tt_int_op(r, OP_EQ, 0); 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(); slout = smartlist_new();
// Test no defaultport, no defaultaddress and no out // 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); tt_int_op(ret, OP_EQ, 0);
// Test with defaultport, no defaultaddress and no out // 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); tt_int_op(ret, OP_EQ, 0);
// Test no defaultport, with defaultaddress and no out // 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); tt_int_op(ret, OP_EQ, 0);
// Test with defaultport, with defaultaddress and no out // 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); tt_int_op(ret, OP_EQ, 0);
// Test no defaultport, no defaultaddress and with out // 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(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 0); tt_int_op(smartlist_len(slout), OP_EQ, 0);
// Test with defaultport, no defaultaddress and with out // 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(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 0); tt_int_op(smartlist_len(slout), OP_EQ, 0);
// Test no defaultport, with defaultaddress and with out // 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(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 0); tt_int_op(smartlist_len(slout), OP_EQ, 0);
// Test with defaultport, with defaultaddress and out, adds a new port cfg // Test with defaultport, with defaultaddress and out, adds a new port cfg
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf)); SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); 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(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); tt_int_op(smartlist_len(slout), OP_EQ, 1);
port_cfg = (port_cfg_t *)smartlist_get(slout, 0); 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 // for a unix address
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf)); SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); 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); 42, CL_PORT_IS_UNIXSOCKET);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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 // Test error when encounters an invalid Port specification
config_port_invalid = mock_config_line("DNSPort", ""); 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); 0, 0);
tt_int_op(ret, OP_EQ, -1); tt_int_op(ret, OP_EQ, -1);
// Test error when encounters an empty unix domain specification // Test error when encounters an empty unix domain specification
config_free_lines(config_port_invalid); config_port_invalid = NULL; config_free_lines(config_port_invalid); config_port_invalid = NULL;
config_port_invalid = mock_config_line("DNSPort", "unix:"); 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); 0, 0);
tt_int_op(ret, OP_EQ, -1); tt_int_op(ret, OP_EQ, -1);
// Test error when encounters a unix domain specification but the listener // Test error when encounters a unix domain specification but the listener
// doesn't support domain sockets // doesn't support domain sockets
config_port_valid = mock_config_line("DNSPort", "unix:/tmp/foo/bar"); 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); CONN_TYPE_AP_DNS_LISTENER, NULL, 0, 0);
tt_int_op(ret, OP_EQ, -1); tt_int_op(ret, OP_EQ, -1);
// Test valid unix domain // Test valid unix domain
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf)); SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); 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); CONN_TYPE_AP_LISTENER, NULL, 0, 0);
#ifdef _WIN32 #ifdef _WIN32
tt_int_op(ret, OP_EQ, -1); 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->port, OP_EQ, 0);
tt_int_op(port_cfg->is_unix_addr, OP_EQ, 1); tt_int_op(port_cfg->is_unix_addr, OP_EQ, 1);
tt_str_op(port_cfg->unix_addr, OP_EQ, "/tmp/foo/bar"); 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.dns_request, OP_EQ, 1);
tt_int_op(port_cfg->entry_cfg.ipv4_traffic, 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); 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 " "unix:/tmp/foo/bar NoIPv4Traffic "
"NoIPv6Traffic " "NoIPv6Traffic "
"NoOnionTraffic"); "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, CONN_TYPE_AP_LISTENER, NULL, 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
tt_int_op(ret, OP_EQ, -1); 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_free_lines(config_port_invalid); config_port_invalid = NULL;
config_port_invalid = mock_config_line("DNSPort", config_port_invalid = mock_config_line("DNSPort",
"127.0.0.1:80 NoDNSRequest"); "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, CONN_TYPE_AP_DNS_LISTENER, NULL, 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
tt_int_op(ret, OP_EQ, -1); 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 " config_port_valid = mock_config_line("DNSPort", "127.0.0.1:80 "
"NoIPv6Traffic " "NoIPv6Traffic "
"NoIPv4Traffic NoOnionTraffic"); "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, CONN_TYPE_AP_DNS_LISTENER, NULL, 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
tt_int_op(ret, OP_EQ, 0); 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", config_port_invalid = mock_config_line("SOCKSPort",
"NoIPv6Traffic " "NoIPv6Traffic "
"unix:/tmp/foo/bar NoIPv4Traffic"); "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, CONN_TYPE_AP_LISTENER, NULL, 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
tt_int_op(ret, OP_EQ, -1); 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 " config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/foo/bar "
"NoIPv6Traffic " "NoIPv6Traffic "
"NoDNSRequest NoIPv4Traffic"); "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, CONN_TYPE_AP_LISTENER, NULL, 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
#ifdef _WIN32 #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\" " config_port_valid = mock_config_line("SOCKSPort", "unix:\"/tmp/foo/ bar\" "
"NoIPv6Traffic " "NoIPv6Traffic "
"NoDNSRequest NoIPv4Traffic"); "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, CONN_TYPE_AP_LISTENER, NULL, 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
#ifdef _WIN32 #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 " config_port_valid = mock_config_line("SOCKSPort", "unix:\"/tmp/foo/ bar "
"NoIPv6Traffic " "NoIPv6Traffic "
"NoDNSRequest NoIPv4Traffic"); "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, CONN_TYPE_AP_LISTENER, NULL, 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
tt_int_op(ret, OP_EQ, -1); 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:\"\" " config_port_valid = mock_config_line("SOCKSPort", "unix:\"\" "
"NoIPv6Traffic " "NoIPv6Traffic "
"NoDNSRequest NoIPv4Traffic"); "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, CONN_TYPE_AP_LISTENER, NULL, 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
tt_int_op(ret, OP_EQ, -1); tt_int_op(ret, OP_EQ, -1);
@ -4240,7 +4240,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/foo/bar " config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/foo/bar "
"OnionTrafficOnly"); "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, CONN_TYPE_AP_LISTENER, NULL, 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
#ifdef _WIN32 #ifdef _WIN32
@ -4261,7 +4261,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/foo/bar " config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/foo/bar "
"NoIPv4Traffic IPv6Traffic"); "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, CONN_TYPE_AP_LISTENER, NULL, 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
#ifdef _WIN32 #ifdef _WIN32
@ -4280,7 +4280,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/foo/bar " config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/foo/bar "
"IPv4Traffic IPv6Traffic"); "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, CONN_TYPE_AP_LISTENER, NULL, 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
#ifdef _WIN32 #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 // Test failure if we specify world writable for an IP Port
config_free_lines(config_port_invalid); config_port_invalid = NULL; config_free_lines(config_port_invalid); config_port_invalid = NULL;
config_port_invalid = mock_config_line("DNSPort", "42 WorldWritable"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, -1); tt_int_op(ret, OP_EQ, -1);
// Test failure if we specify group writable for an IP Port // Test failure if we specify group writable for an IP Port
config_free_lines(config_port_invalid); config_port_invalid = NULL; config_free_lines(config_port_invalid); config_port_invalid = NULL;
config_port_invalid = mock_config_line("DNSPort", "42 GroupWritable"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, -1); tt_int_op(ret, OP_EQ, -1);
// Test failure if we specify group writable for an IP Port // Test failure if we specify group writable for an IP Port
config_free_lines(config_port_invalid); config_port_invalid = NULL; config_free_lines(config_port_invalid); config_port_invalid = NULL;
config_port_invalid = mock_config_line("DNSPort", "42 RelaxDirModeCheck"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, -1); tt_int_op(ret, OP_EQ, -1);
// Test success with only a port (this will fail without a default address) // Test success with only a port (this will fail without a default address)
config_free_lines(config_port_valid); config_port_valid = NULL; config_free_lines(config_port_valid); config_port_valid = NULL;
config_port_valid = mock_config_line("DNSPort", "42"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 IsolateDestPort"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 NoIsolateDestPorts"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 IsolateDestAddr"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 IsolateSOCKSAuth"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 IsolateClientProtocol"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 IsolateClientAddr"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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 // Test success with ignored unknown options
config_free_lines(config_port_valid); config_port_valid = NULL; config_free_lines(config_port_valid); config_port_valid = NULL;
config_port_valid = mock_config_line("DNSPort", "42 ThisOptionDoesntExist"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 NoIsolateSOCKSAuth"); 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); "127.0.0.3", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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); smartlist_clear(slout);
config_port_valid = mock_config_line("SOCKSPort", config_port_valid = mock_config_line("SOCKSPort",
"42 IPv6Traffic PreferIPv6"); "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, CONN_TYPE_AP_LISTENER, "127.0.0.42", 0,
CL_PORT_TAKES_HOSTNAMES); CL_PORT_TAKES_HOSTNAMES);
tt_int_op(ret, OP_EQ, 0); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 CacheIPv4DNS"); 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); "127.0.0.42", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 CacheIPv6DNS"); 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); "127.0.0.42", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 NoCacheIPv4DNS"); 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); "127.0.0.42", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 CacheDNS"); 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); "127.0.0.42", 0, CL_PORT_TAKES_HOSTNAMES);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 UseIPv4Cache"); 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); "127.0.0.42", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 UseIPv6Cache"); 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); "127.0.0.42", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 UseDNSCache"); 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); "127.0.0.42", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 NoPreferIPv6Automap"); 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); "127.0.0.42", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 PreferSOCKSNoAuth"); 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); "127.0.0.42", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_invalid = mock_config_line("DNSPort", "0");
config_port_valid = mock_config_line("DNSPort", "42"); config_port_valid = mock_config_line("DNSPort", "42");
config_port_invalid->next = config_port_valid; 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); "127.0.0.42", 0, 0);
tt_int_op(ret, OP_EQ, -1); tt_int_op(ret, OP_EQ, -1);
// Test success with warn non-local control // Test success with warn non-local control
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf)); SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); 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, CONN_TYPE_CONTROL_LISTENER, "127.0.0.42", 0,
CL_PORT_WARN_NONLOCAL); CL_PORT_WARN_NONLOCAL);
tt_int_op(ret, OP_EQ, 0); 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 // Test success with warn non-local listener
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf)); SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); 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, CONN_TYPE_EXT_OR_LISTENER, "127.0.0.42", 0,
CL_PORT_WARN_NONLOCAL); CL_PORT_WARN_NONLOCAL);
tt_int_op(ret, OP_EQ, 0); 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 // Test success with warn non-local other
SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf)); SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); 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); "127.0.0.42", 0, CL_PORT_WARN_NONLOCAL);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
// Test success with warn non-local other without out // 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); "127.0.0.42", 0, CL_PORT_WARN_NONLOCAL);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
@ -4594,7 +4594,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 IPv4Traffic " config_port_valid = mock_config_line("DNSPort", "42 IPv4Traffic "
"IPv6Traffic"); "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, "127.0.0.44", 0,
CL_PORT_TAKES_HOSTNAMES | CL_PORT_TAKES_HOSTNAMES |
CL_PORT_NO_STREAM_OPTIONS); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "42 SessionGroup=invalid"); 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); "127.0.0.44", 0, CL_PORT_NO_STREAM_OPTIONS);
tt_int_op(ret, OP_EQ, -1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "42 SessionGroup=123"); 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); "127.0.0.44", 0, CL_PORT_NO_STREAM_OPTIONS);
tt_int_op(ret, OP_EQ, -1); tt_int_op(ret, OP_EQ, -1);
@ -4629,7 +4629,7 @@ test_config_parse_port_config__ports__ports_given(void *data)
smartlist_clear(slout); smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "42 SessionGroup=123 " config_port_invalid = mock_config_line("DNSPort", "42 SessionGroup=123 "
"SessionGroup=321"); "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); "127.0.0.44", 0, 0);
tt_int_op(ret, OP_EQ, -1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 SessionGroup=1111122"); 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); "127.0.0.44", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "0"); 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); "127.0.0.45", 0, CL_PORT_IS_UNIXSOCKET);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "something"); 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); "127.0.0.45", 0, CL_PORT_IS_UNIXSOCKET);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "auto"); 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); "127.0.0.46", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "AuTo"); 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); "127.0.0.46", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "127.0.0.122:auto"); 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); "127.0.0.46", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_free_lines(config_port_invalid); config_port_invalid = NULL;
config_port_invalid = mock_config_line("DNSPort", "invalidstuff!!:auto"); config_port_invalid = mock_config_line("DNSPort", "invalidstuff!!:auto");
MOCK(tor_addr_lookup, mock_tor_addr_lookup__fail_on_bad_addrs); 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); "127.0.0.46", 0, 0);
UNMOCK(tor_addr_lookup); UNMOCK(tor_addr_lookup);
tt_int_op(ret, OP_EQ, -1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "127.0.0.123:656"); 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); "127.0.0.46", 0, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "something wrong"); 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); "127.0.0.46", 0, 0);
tt_int_op(ret, OP_EQ, -1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "127.0.1.0:123:auto"); 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); "127.0.0.46", 0, 0);
tt_int_op(ret, OP_EQ, -1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("SOCKSPort", "unix:/tmp/somewhere"); 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, CONN_TYPE_AP_LISTENER, "127.0.0.46", 0,
CL_PORT_DFLT_GROUP_WRITABLE); CL_PORT_DFLT_GROUP_WRITABLE);
#ifdef _WIN32 #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_free_lines(config_port_valid); config_port_valid = NULL;
config_port_valid = mock_config_line("DNSPort", config_port_valid = mock_config_line("DNSPort",
"127.0.0.124:656 NoAdvertise"); "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); CL_PORT_SERVER_OPTIONS);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "127.0.0.124:656 NoListen"); 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); CL_PORT_SERVER_OPTIONS);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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); smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "127.0.0.124:656 NoListen " config_port_invalid = mock_config_line("DNSPort", "127.0.0.124:656 NoListen "
"NoAdvertise"); "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); 0, CL_PORT_SERVER_OPTIONS);
tt_int_op(ret, OP_EQ, -1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "127.0.0.124:656 IPv4Only"); 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); CL_PORT_SERVER_OPTIONS);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "[::1]:656 IPv6Only"); 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); CL_PORT_SERVER_OPTIONS);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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); smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "127.0.0.124:656 IPv6Only " config_port_invalid = mock_config_line("DNSPort", "127.0.0.124:656 IPv6Only "
"IPv4Only"); "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); 0, CL_PORT_SERVER_OPTIONS);
tt_int_op(ret, OP_EQ, -1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "127.0.0.124:656 unknown"); 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); CL_PORT_SERVER_OPTIONS);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
tt_int_op(smartlist_len(slout), OP_EQ, 1); 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); smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", config_port_invalid = mock_config_line("DNSPort",
"127.0.0.124:656 IPv6Only"); "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); 0, CL_PORT_SERVER_OPTIONS);
tt_int_op(ret, OP_EQ, -1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "[::1]:656 IPv4Only"); 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); 0, CL_PORT_SERVER_OPTIONS);
tt_int_op(ret, OP_EQ, -1); 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_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout); smartlist_clear(slout);
config_port_invalid = mock_config_line("ORPort", "unix:\"\""); 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); 0, CL_PORT_SERVER_OPTIONS);
tt_int_op(ret, OP_EQ, -1); tt_int_op(ret, OP_EQ, -1);

View File

@ -119,7 +119,7 @@ test_dir_handle_get_v1_command_not_found(void *data)
conn = new_dir_conn(); conn = new_dir_conn();
// no frontpage configured // no frontpage configured
tt_ptr_op(get_dirportfrontpage(), OP_EQ, NULL); tt_ptr_op(relay_get_dirportfrontpage(), OP_EQ, NULL);
/* V1 path */ /* V1 path */
tt_int_op(directory_handle_command_get(conn, GET("/tor/"), NULL, 0), 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; (void) data;
MOCK(connection_write_to_buf_impl_, connection_write_to_buf_mock); 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); body_len = strlen(exp_body);
conn = new_dir_conn(); conn = new_dir_conn();
@ -178,7 +178,7 @@ test_dir_handle_get_v1_command(void *data)
done: done:
UNMOCK(connection_write_to_buf_impl_); UNMOCK(connection_write_to_buf_impl_);
UNMOCK(get_dirportfrontpage); UNMOCK(relay_get_dirportfrontpage);
connection_free_minimal(TO_CONN(conn)); connection_free_minimal(TO_CONN(conn));
tor_free(header); tor_free(header);
tor_free(body); tor_free(body);