Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tor pre0 #1

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions common/test/run-ip_port_parsing.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int main(void)
assert(parse_wireaddr("[::ffff:127.0.0.1]:49150", &addr, 1, NULL));
assert(addr.port == 49150);

assert(parse_wireaddr("4ruvswpqec5i2gogopxl4vm5bruzknbvbylov2awbo4rxiq4cimdldad.onion:49150", &addr, 1, NULL));
assert(parse_wireaddr("4ruvswpqec5i2gogopxl4vm5bruzknbvbylov2awbo4rxiq4cimdldad.onion:49150", &addr, 1, NULL));
assert(addr.port == 49150);

assert(parse_wireaddr("4ruvswpqec5i2gogopxl4vm5bruzknbvbylov2awbo4rxiq4cimdldad.onion", &addr, 1, NULL));
Expand All @@ -102,7 +102,7 @@ int main(void)
assert(parse_wireaddr("odpzvneidqdf5hdq.onion:49150", &addr, 1, NULL));
assert(addr.port == 49150);

assert(parse_wireaddr("odpzvneidqdf5hdq.onion.onion", &addr, 1, NULL));
assert(parse_wireaddr("odpzvneidqdf5hdq.onion", &addr, 1, NULL));
assert(addr.port == 1);
tal_free(tmpctx);
return 0;
Expand Down
6 changes: 4 additions & 2 deletions common/wireaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ char *fmt_wireaddr_without_port(const tal_t * ctx, const struct wireaddr *a)
return "Unprintable-ipv6-address";
return tal_fmt(ctx, "[%s]", addrstr);
case ADDR_TYPE_TOR_V2:
return tal_fmt(ctx, "%.16s.onion",
b32_encode(tmpctx, a->addr, a->addrlen));
case ADDR_TYPE_TOR_V3:
return tal_fmt(ctx, "%s.onion",
return tal_fmt(ctx, "%.56s.onion",
b32_encode(tmpctx, a->addr, a->addrlen));
case ADDR_TYPE_PADDING:
break;
Expand Down Expand Up @@ -192,7 +194,7 @@ bool parse_wireaddr(const char *arg, struct wireaddr *addr, u16 defport,
else
goto bad_onion;

addr->addrlen = tal_len(dec) + 2;
addr->addrlen = tal_len(dec);
addr->port = port;
memcpy(&addr->addr, dec, tal_len(dec));
res = true;
Expand Down
1 change: 0 additions & 1 deletion gossipd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ GOSSIPD_COMMON_OBJS := \
common/status_wire.o \
common/subdaemon.o \
common/timeout.o \
common/tor.o \
common/type_to_string.o \
common/utils.o \
common/utxo.o \
Expand Down
2 changes: 1 addition & 1 deletion lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
ld->pidfile = NULL;
ld->ini_autocleaninvoice_cycle = 0;
ld->ini_autocleaninvoice_expiredby = 86400;
ld->tor_service_password = NULL;
ld->tor_service_password = tal_arr(ld,char,0);
ld->tor_proxyaddr = NULL;
ld->tor_serviceaddr = NULL;
ld->use_tor_proxy_always = false;
Expand Down
5 changes: 3 additions & 2 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ static void add_config(struct lightningd *ld,
topo->override_fee_rate[0],
topo->override_fee_rate[1],
topo->override_fee_rate[2]);
} else if (opt->cb_arg == (void *)opt_add_ipaddr) {
} else if (opt->cb_arg == (void *)opt_add_addr) {
/* This is a bit weird, we can have multiple args */
for (size_t i = 0; i < tal_count(ld->wireaddrs); i++) {
json_add_string(response,
Expand All @@ -938,7 +938,8 @@ static void add_config(struct lightningd *ld,
ld->tor_serviceaddr);
} else {
/* Insert more decodes here! */
abort();
answer = tal_fmt(name0,"Option --%s probably no handler defined or handled!", name);
/* FIXME abort(); */
}
}

Expand Down
9 changes: 4 additions & 5 deletions lightningd/tor.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ static char *tor_response_line(struct lightningd *ld, struct rbuf *rbuf)
errx(1, "Tor returned '%s'", line);

/* Last line */
if (!strstarts(line, "250 "))
if (!strstarts(line, "250-"))
break;

return line + 4;
}
return NULL;
return line;
}

static void make_onion(struct lightningd *ld, struct rbuf *rbuf)
{
char *line;
Expand Down Expand Up @@ -137,7 +136,7 @@ static void negotiate_auth(struct lightningd *ld, struct rbuf *rbuf)
err(1, "Cannot open Tor cookie file '%s'", p);

tor_send_cmd(ld, rbuf,
tal_fmt(tmpctx, "AUTHENTICATE \"%s\"",
tal_fmt(tmpctx, "AUTHENTICATE %s",
tal_hexstr(tmpctx,
contents,
tal_len(contents)-1)));
Expand All @@ -163,7 +162,7 @@ void tor_init(struct lightningd *ld)
&ai_tor) != 0)
errx(1, "getaddrinfo failed for Tor service");

fd = socket(ai_tor->ai_protocol, SOCK_STREAM, 0);
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
err(1, "Creating stream socket for Tor");

Expand Down