// Port lines for the same portname
ret = parse_port_config(NULL, config_port1, config_listen_address, "DNS", 0,
NULL, 0, 0);
+
tt_int_op(ret, OP_EQ, -1);
// Test case when we have a listen address, no default port and allow
tt_int_op(ret, OP_EQ, 0);
done:
- tor_free(config_listen_address);
- tor_free(config_listen_address2);
- tor_free(config_listen_address3);
- tor_free(config_port1);
- tor_free(config_port2);
- tor_free(config_port3);
- tor_free(config_port4);
- tor_free(config_port5);
+ config_free_lines(config_listen_address);
+ config_free_lines(config_listen_address2);
+ config_free_lines(config_listen_address3);
+ config_free_lines(config_port1);
+ /* 2 was linked from 1. */
+ config_free_lines(config_port3);
+ config_free_lines(config_port4);
+ config_free_lines(config_port5);
+ if (slout)
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_free(slout);
}
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, NULL, "DNS", 0, "127.0.0.2", 42, 0);
tt_int_op(ret, OP_EQ, 0);
// Test with defaultport, with defaultaddress and out, adds a new port cfg
// for a unix address
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
ret = parse_port_config(slout, NULL, NULL, "DNS", 0, "/foo/bar/unixdomain",
42, CL_PORT_IS_UNIXSOCKET);
tt_str_op(port_cfg->unix_addr, OP_EQ, "/foo/bar/unixdomain");
done:
+ if (slout)
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_free(slout);
}
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, NULL, "DNS",
CONN_TYPE_AP_LISTENER, NULL, 0, 0);
// Test success with no ipv4 but take ipv6 (for unix domain sockets, this
// makes no sense - it should be fixed)
config_free_lines(config_port_valid); config_port_valid = NULL;
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "unix:/tmp/foo/bar "
"NoIPv4Traffic IPv6Traffic");
// Test success with both ipv4 and ipv6 (for unix domain sockets,
// this makes no sense - it should be fixed)
config_free_lines(config_port_valid); config_port_valid = NULL;
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "unix:/tmp/foo/bar "
"IPv4Traffic IPv6Traffic");
// Test success with only a port and isolate destination port
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with a negative isolate destination port, and plural
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with isolate destination address
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with isolate socks AUTH
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with isolate client protocol
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with isolate client address
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with no isolate socks AUTH
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with prefer ipv6
config_free_lines(config_port_valid); config_port_valid = NULL;
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 IPv6Traffic PreferIPv6");
ret = parse_port_config(slout, config_port_valid, NULL, "DNS",
// Test success with cache ipv4 DNS
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with cache ipv6 DNS
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with no cache ipv4 DNS
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with cache DNS
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with use cached ipv4 DNS
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with use cached ipv6 DNS
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with use cached DNS
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with not preferring ipv6 automap
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with prefer SOCKS no auth
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test failure with both a zero port and a non-zero port
config_free_lines(config_port_invalid); config_port_invalid = NULL;
config_free_lines(config_port_valid); config_port_valid = NULL;
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "0");
config_port_valid = mock_config_line("DNSPort", "42");
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, NULL, "DNS",
CONN_TYPE_CONTROL_LISTENER, "127.0.0.42", 0,
tt_int_op(ret, OP_EQ, 0);
// 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, NULL, "DNS",
CONN_TYPE_EXT_OR_LISTENER, "127.0.0.42", 0,
tt_int_op(ret, OP_EQ, 0);
// 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, NULL, "DNS", 0,
"127.0.0.42", 0, CL_PORT_WARN_NONLOCAL);
tt_int_op(ret, OP_EQ, 0);
// Test success with both ipv4 and ipv6 but without stream options
- config_free_lines(config_port_valid); config_port_valid = NULL;
+ config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ config_port_valid = NULL;
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "42 IPv4Traffic "
"IPv6Traffic");
tt_int_op(port_cfg->entry_cfg.ipv6_traffic, OP_EQ, 0);
// Test failure for a SessionGroup argument with invalid value
- config_free_lines(config_port_valid); config_port_valid = NULL;
+ config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ 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, NULL, "DNS", 0,
// Test failure for a SessionGroup argument with valid value but with stream
// options allowed
config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ 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, NULL, "DNS", 0,
// Test failure for more than one SessionGroup argument
config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "42 SessionGroup=123 "
"SessionGroup=321");
tt_int_op(ret, OP_EQ, -1);
// Test success with a sessiongroup options
- config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with a zero unix domain socket, and doesnt add it to out
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with a one unix domain socket, and doesnt add it to out
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with a port of auto - it uses the default address
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with parsing both an address and an auto port
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
// Test success with parsing both an address and a real port
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0,
tt_assert(tor_addr_eq(&port_cfg->addr, &addr))
// Test failure if we can't parse anything at all
- config_free_lines(config_port_valid); config_port_valid = NULL;
+ config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ 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, NULL, "DNS", 0,
// Test failure if we find both an address, a port and an auto
config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ 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, NULL, "DNS", 0,
// Test that default to group writeable default sets group writeable for
// domain socket
- config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ config_free_lines(config_port_valid); config_port_valid = NULL;
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
config_port_valid = mock_config_line("DNSPort", "unix:/tmp/somewhere");
ret = parse_port_config(slout, config_port_valid, NULL, "DNS",
#endif
done:
+ if (slout)
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_free(slout);
config_free_lines(config_port_invalid); config_port_invalid = NULL;
config_free_lines(config_port_valid); config_port_valid = NULL;
// Test success with NoListen option
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0, NULL, 0,
// Test failure with both NoAdvertise and NoListen option
config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "127.0.0.124:656 NoListen "
"NoAdvertise");
// Test success with IPv4Only
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0, NULL, 0,
// Test success with IPv6Only
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0, NULL, 0,
// Test failure with both IPv4Only and IPv6Only
config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort", "127.0.0.124:656 IPv6Only "
"IPv4Only");
// Test success with invalid parameter
config_free_lines(config_port_valid); config_port_valid = NULL;
+ 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, NULL, "DNS", 0, NULL, 0,
// Test failure when asked to bind only to ipv6 but gets an ipv4 address
config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_clear(slout);
config_port_invalid = mock_config_line("DNSPort",
"127.0.0.124:656 IPv6Only");
// Test failure when asked to bind only to ipv4 but gets an ipv6 address
config_free_lines(config_port_invalid); config_port_invalid = NULL;
+ 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, NULL, "DNS", 0, NULL,
tt_int_op(ret, OP_EQ, -1);
done:
+ if (slout)
+ SMARTLIST_FOREACH(slout,port_cfg_t *,pf,port_cfg_free(pf));
smartlist_free(slout);
config_free_lines(config_port_invalid); config_port_invalid = NULL;
config_free_lines(config_port_valid); config_port_valid = NULL;