diff --git a/common/test/run-ip_port_parsing.c b/common/test/run-ip_port_parsing.c index b0f1aad45205..50c275b4dae5 100644 --- a/common/test/run-ip_port_parsing.c +++ b/common/test/run-ip_port_parsing.c @@ -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)); @@ -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; diff --git a/common/wireaddr.c b/common/wireaddr.c index 8fd06af28c0f..8e759c9bc95c 100644 --- a/common/wireaddr.c +++ b/common/wireaddr.c @@ -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; @@ -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; diff --git a/gossipd/Makefile b/gossipd/Makefile index b863d81f0ab2..593b045329b1 100644 --- a/gossipd/Makefile +++ b/gossipd/Makefile @@ -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 \ diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 15056cd4225d..e90a8377e5ca 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -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; diff --git a/lightningd/options.c b/lightningd/options.c index c0f750fb7fcc..4c999e7a2d2e 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -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, @@ -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(); */ } } diff --git a/lightningd/tor.c b/lightningd/tor.c index ee172857c1e2..d37ef477e9dc 100644 --- a/lightningd/tor.c +++ b/lightningd/tor.c @@ -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; @@ -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))); @@ -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");