Make hidden service use the config unix prefix

Signed-off-by: David Goulet <dgoulet@ev0ke.net>
This commit is contained in:
David Goulet 2015-01-28 18:01:53 -05:00
parent bf3fb55c47
commit ebc59092bc

View File

@ -341,7 +341,6 @@ parse_port_config(const char *string)
tor_addr_t addr; tor_addr_t addr;
const char *addrport; const char *addrport;
rend_service_port_config_t *result = NULL; rend_service_port_config_t *result = NULL;
const char *socket_prefix = "socket:";
unsigned int is_unix_addr = 0; unsigned int is_unix_addr = 0;
char *socket_path = NULL; char *socket_path = NULL;
@ -365,25 +364,19 @@ parse_port_config(const char *string)
realport = virtport; realport = virtport;
tor_addr_from_ipv4h(&addr, 0x7F000001u); /* 127.0.0.1 */ tor_addr_from_ipv4h(&addr, 0x7F000001u); /* 127.0.0.1 */
} else { } else {
int ret;
addrport = smartlist_get(sl,1); addrport = smartlist_get(sl,1);
/* If it starts with socket:, try to parse it as a socket path */ ret = config_parse_unix_port(addrport, &socket_path);
if (!strcmpstart(addrport, socket_prefix)) { if (ret < 0 && ret != ENOENT) {
if (strlen(addrport + strlen(socket_prefix)) > 0) { if (ret == -EINVAL) {
#ifdef HAVE_SYS_UN_H
is_unix_addr = 1;
socket_path = tor_strdup(addrport + strlen(socket_prefix));
#else
log_warn(LD_CONFIG,
"Hidden service port configuration %s is for an AF_UNIX "
"socket, but we have no support available on this platform",
escaped(addrport));
goto err;
#endif /* defined(HAVE_SYS_UN_H) */
} else {
log_warn(LD_CONFIG, log_warn(LD_CONFIG,
"Empty socket path in hidden service port configuration."); "Empty socket path in hidden service port configuration.");
}
goto err; goto err;
} }
if (socket_path) {
is_unix_addr = 1;
} else if (strchr(addrport, ':') || strchr(addrport, '.')) { } else if (strchr(addrport, ':') || strchr(addrport, '.')) {
/* else try it as an IP:port pair if it has a : or . in it */ /* else try it as an IP:port pair if it has a : or . in it */
if (tor_addr_port_lookup(addrport, &addr, &p)<0) { if (tor_addr_port_lookup(addrport, &addr, &p)<0) {