2021-02-01 03:58:50 +01:00
|
|
|
#include "config.h"
|
2018-05-10 01:18:19 +02:00
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <ccan/err/err.h>
|
|
|
|
#include <ccan/io/io.h>
|
2018-05-10 01:18:23 +02:00
|
|
|
#include <ccan/rbuf/rbuf.h>
|
|
|
|
#include <ccan/read_write_all/read_write_all.h>
|
2018-05-10 01:18:19 +02:00
|
|
|
#include <ccan/str/hex/hex.h>
|
2018-05-10 01:18:23 +02:00
|
|
|
#include <ccan/tal/grab_file/grab_file.h>
|
2018-05-10 01:18:19 +02:00
|
|
|
#include <ccan/tal/str/str.h>
|
2019-11-15 09:44:22 +01:00
|
|
|
#include <common/base64.h>
|
2018-05-10 01:18:19 +02:00
|
|
|
#include <common/type_to_string.h>
|
|
|
|
#include <common/utils.h>
|
|
|
|
#include <common/wireaddr.h>
|
2018-07-24 08:18:58 +02:00
|
|
|
#include <connectd/tor_autoservice.h>
|
2018-05-10 01:18:19 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
2018-05-10 01:18:23 +02:00
|
|
|
#include <lightningd/log.h>
|
2018-05-10 01:18:19 +02:00
|
|
|
#include <netdb.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <wire/wire.h>
|
|
|
|
|
|
|
|
|
2018-10-18 02:48:36 +02:00
|
|
|
static void *buf_resize(struct membuf *mb, void *buf, size_t len)
|
2018-05-10 01:18:19 +02:00
|
|
|
{
|
2018-05-10 01:18:23 +02:00
|
|
|
tal_resize(&buf, len);
|
|
|
|
return buf;
|
2018-05-10 01:18:19 +02:00
|
|
|
}
|
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
static void tor_send_cmd(struct rbuf *rbuf, const char *cmd)
|
2018-05-10 01:18:19 +02:00
|
|
|
{
|
2019-11-17 12:42:33 +01:00
|
|
|
status_io(LOG_IO_OUT, NULL, "torcontrol", cmd, strlen(cmd));
|
2018-05-10 01:18:23 +02:00
|
|
|
if (!write_all(rbuf->fd, cmd, strlen(cmd)))
|
2018-05-10 01:18:24 +02:00
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"Writing '%s' to Tor socket", cmd);
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2019-11-17 12:42:33 +01:00
|
|
|
status_io(LOG_IO_OUT, NULL, "torcontrol", "\r\n", 2);
|
2018-05-10 01:18:23 +02:00
|
|
|
if (!write_all(rbuf->fd, "\r\n", 2))
|
2018-05-10 01:18:24 +02:00
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"Writing CRLF to Tor socket");
|
2018-05-10 01:18:19 +02:00
|
|
|
}
|
|
|
|
|
2019-11-15 09:44:22 +01:00
|
|
|
static char *tor_response_line_wfail(struct rbuf *rbuf)
|
|
|
|
{
|
|
|
|
char *line = NULL;
|
|
|
|
|
|
|
|
while ((line = rbuf_read_str(rbuf, '\n')) != NULL) {
|
|
|
|
status_io(LOG_IO_IN, NULL, "torcontrol", line, strlen(line));
|
|
|
|
|
|
|
|
/* Weird response */
|
|
|
|
if (!strstarts(line, "250") && !strstarts(line, "550"))
|
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"Tor returned '%s'", line);
|
|
|
|
|
|
|
|
/* Last line */
|
|
|
|
if (strstarts(line, "250 ") || strstarts(line, "550 "))
|
|
|
|
break;
|
|
|
|
|
|
|
|
return line + 4;
|
|
|
|
}
|
|
|
|
if (line)
|
|
|
|
return line + 4;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
static char *tor_response_line(struct rbuf *rbuf)
|
2018-05-10 01:18:19 +02:00
|
|
|
{
|
2018-05-10 01:18:23 +02:00
|
|
|
char *line;
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2018-10-18 02:48:36 +02:00
|
|
|
while ((line = rbuf_read_str(rbuf, '\n')) != NULL) {
|
2019-11-17 12:42:33 +01:00
|
|
|
status_io(LOG_IO_IN, NULL, "torcontrol", line, strlen(line));
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2018-05-10 01:18:23 +02:00
|
|
|
/* Weird response */
|
|
|
|
if (!strstarts(line, "250"))
|
2018-05-10 01:18:24 +02:00
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"Tor returned '%s'", line);
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2018-05-10 01:18:23 +02:00
|
|
|
/* Last line */
|
|
|
|
if (strstarts(line, "250 "))
|
|
|
|
break;
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2018-05-10 01:18:23 +02:00
|
|
|
return line + 4;
|
|
|
|
}
|
|
|
|
return NULL;
|
2018-05-10 01:18:19 +02:00
|
|
|
}
|
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
static void discard_remaining_response(struct rbuf *rbuf)
|
2018-05-10 01:18:19 +02:00
|
|
|
{
|
2018-05-10 01:18:24 +02:00
|
|
|
while (tor_response_line(rbuf));
|
2018-05-10 01:18:19 +02:00
|
|
|
}
|
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
static struct wireaddr *make_onion(const tal_t *ctx,
|
|
|
|
struct rbuf *rbuf,
|
2019-09-24 11:29:02 +02:00
|
|
|
const struct wireaddr *local,
|
2019-11-15 09:44:22 +01:00
|
|
|
bool use_v3_autotor,
|
|
|
|
u16 port)
|
2018-05-10 01:18:19 +02:00
|
|
|
{
|
2018-05-10 01:18:23 +02:00
|
|
|
char *line;
|
2018-05-10 01:18:24 +02:00
|
|
|
struct wireaddr *onion;
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2019-11-15 09:44:22 +01:00
|
|
|
/* Now that V3 is out of Beta default to V3 autoservice onions if version is above 0.4
|
|
|
|
*/
|
2019-09-24 11:29:02 +02:00
|
|
|
tor_send_cmd(rbuf, "PROTOCOLINFO 1");
|
|
|
|
|
|
|
|
while ((line = tor_response_line(rbuf)) != NULL) {
|
|
|
|
|
|
|
|
if (!strstarts(line, "VERSION Tor="))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (use_v3_autotor)
|
2020-01-05 16:52:34 +01:00
|
|
|
if (strstr(line, "\"0.0") ||
|
2019-09-24 11:29:02 +02:00
|
|
|
strstr(line, "\"0.1") ||
|
|
|
|
strstr(line, "\"0.2") ||
|
|
|
|
strstr(line, "\"0.3")) {
|
|
|
|
use_v3_autotor = false;
|
|
|
|
status_unusual("Autotor: fallback to try a V2 onion service, your Tor version is smaller than 0.4.x.x");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!use_v3_autotor) {
|
|
|
|
tor_send_cmd(rbuf,
|
2018-05-10 01:18:24 +02:00
|
|
|
tal_fmt(tmpctx, "ADD_ONION NEW:RSA1024 Port=%d,%s Flags=DiscardPK,Detach",
|
2019-11-15 09:44:22 +01:00
|
|
|
port, fmt_wireaddr(tmpctx, local)));
|
2019-09-24 11:29:02 +02:00
|
|
|
} else {
|
|
|
|
tor_send_cmd(rbuf,
|
|
|
|
tal_fmt(tmpctx, "ADD_ONION NEW:ED25519-V3 Port=%d,%s Flags=DiscardPK,Detach",
|
2019-11-15 09:44:22 +01:00
|
|
|
port, fmt_wireaddr(tmpctx, local)));
|
2019-09-24 11:29:02 +02:00
|
|
|
}
|
2018-05-10 01:18:23 +02:00
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
while ((line = tor_response_line(rbuf)) != NULL) {
|
|
|
|
const char *name;
|
2018-05-10 01:18:23 +02:00
|
|
|
|
|
|
|
if (!strstarts(line, "ServiceID="))
|
|
|
|
continue;
|
|
|
|
line += strlen("ServiceID=");
|
|
|
|
/* Strip the trailing CR */
|
|
|
|
if (strchr(line, '\r'))
|
|
|
|
*strchr(line, '\r') = '\0';
|
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
name = tal_fmt(tmpctx, "%s.onion", line);
|
|
|
|
onion = tal(ctx, struct wireaddr);
|
2019-11-15 09:44:22 +01:00
|
|
|
if (!parse_wireaddr(name, onion, local->port, false, NULL))
|
2018-05-10 01:18:24 +02:00
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"Tor gave bad onion name '%s'", name);
|
2019-11-15 09:44:22 +01:00
|
|
|
status_info("New autotor service onion address: \"%s:%d\" bound from extern port:%d", name, local->port, port);
|
2018-05-10 01:18:24 +02:00
|
|
|
discard_remaining_response(rbuf);
|
|
|
|
return onion;
|
2018-05-10 01:18:23 +02:00
|
|
|
}
|
2018-05-10 01:18:24 +02:00
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"Tor didn't give us a ServiceID");
|
2018-05-10 01:18:19 +02:00
|
|
|
}
|
|
|
|
|
2019-11-15 09:44:22 +01:00
|
|
|
static struct wireaddr *make_fixed_onion(const tal_t *ctx,
|
|
|
|
struct rbuf *rbuf,
|
|
|
|
const struct wireaddr *local, const u8 *blob, u16 port)
|
|
|
|
{
|
|
|
|
char *line;
|
|
|
|
struct wireaddr *onion;
|
|
|
|
char *blob64;
|
|
|
|
|
|
|
|
blob64 = b64_encode(tmpctx, blob, 64);
|
|
|
|
|
|
|
|
tor_send_cmd(rbuf,
|
|
|
|
tal_fmt(tmpctx, "ADD_ONION ED25519-V3:%s Port=%d,%s Flags=DiscardPK",
|
|
|
|
blob64, port, fmt_wireaddr(tmpctx, local)));
|
|
|
|
|
|
|
|
while ((line = tor_response_line_wfail(rbuf))) {
|
|
|
|
const char *name;
|
|
|
|
if (strstarts(line, "Onion address collision"))
|
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"Tor address in use");
|
|
|
|
|
|
|
|
if (!strstarts(line, "ServiceID="))
|
|
|
|
continue;
|
|
|
|
line += strlen("ServiceID=");
|
|
|
|
/* Strip the trailing CR */
|
|
|
|
if (strchr(line, '\r'))
|
|
|
|
*strchr(line, '\r') = '\0';
|
|
|
|
|
|
|
|
name = tal_fmt(tmpctx, "%s.onion", line);
|
|
|
|
onion = tal(ctx, struct wireaddr);
|
|
|
|
if (!parse_wireaddr(name, onion, local->port, false, NULL))
|
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"Tor gave bad onion name '%s'", name);
|
|
|
|
#ifdef SUPERVERBOSE
|
|
|
|
status_info("Static Tor service onion address: \"%s:%d,%s\"from blob %s base64 %s ",
|
|
|
|
name, port ,fmt_wireaddr(tmpctx, local), blob ,blob64);
|
|
|
|
#else
|
|
|
|
status_info("Static Tor service onion address: \"%s:%d,%s\" bound from extern port %d ",
|
|
|
|
name, port ,fmt_wireaddr(tmpctx, local), port);
|
|
|
|
#endif
|
|
|
|
discard_remaining_response(rbuf);
|
|
|
|
return onion;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-05-10 01:18:23 +02:00
|
|
|
/* https://gitweb.torproject.org/torspec.git/tree/control-spec.txt:
|
|
|
|
*
|
|
|
|
* MidReplyLine = StatusCode "-" ReplyLine
|
|
|
|
* DataReplyLine = StatusCode "+" ReplyLine CmdData
|
|
|
|
* EndReplyLine = StatusCode SP ReplyLine
|
|
|
|
* ReplyLine = [ReplyText] CRLF
|
|
|
|
* ReplyText = XXXX
|
|
|
|
* StatusCode = 3DIGIT
|
|
|
|
*/
|
2018-05-10 01:18:24 +02:00
|
|
|
static void negotiate_auth(struct rbuf *rbuf, const char *tor_password)
|
2018-05-10 01:18:19 +02:00
|
|
|
{
|
2018-05-10 01:18:23 +02:00
|
|
|
char *line;
|
2018-05-10 01:18:24 +02:00
|
|
|
char *cookiefile = NULL;
|
2018-06-20 16:06:08 +02:00
|
|
|
int cookiefileerrno = 0;
|
2018-05-10 01:18:23 +02:00
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
tor_send_cmd(rbuf, "PROTOCOLINFO 1");
|
2018-05-10 01:18:23 +02:00
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
while ((line = tor_response_line(rbuf)) != NULL) {
|
2018-05-10 01:18:23 +02:00
|
|
|
const char *p;
|
|
|
|
|
|
|
|
if (!strstarts(line, "AUTH METHODS="))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strstr(line, "NULL")) {
|
2018-05-10 01:18:24 +02:00
|
|
|
discard_remaining_response(rbuf);
|
|
|
|
tor_send_cmd(rbuf, "AUTHENTICATE");
|
|
|
|
discard_remaining_response(rbuf);
|
2018-05-10 01:18:23 +02:00
|
|
|
return;
|
|
|
|
} else if (strstr(line, "HASHEDPASSWORD")
|
2018-05-10 01:18:24 +02:00
|
|
|
&& strlen(tor_password)) {
|
|
|
|
discard_remaining_response(rbuf);
|
|
|
|
tor_send_cmd(rbuf,
|
2018-05-10 01:18:23 +02:00
|
|
|
tal_fmt(tmpctx, "AUTHENTICATE \"%s\"",
|
2018-05-10 01:18:24 +02:00
|
|
|
tor_password));
|
|
|
|
discard_remaining_response(rbuf);
|
2018-05-10 01:18:23 +02:00
|
|
|
return;
|
|
|
|
} else if ((p = strstr(line, "COOKIEFILE=\"")) != NULL) {
|
|
|
|
char *contents, *end;
|
|
|
|
|
|
|
|
p += strlen("COOKIEFILE=\"");
|
|
|
|
end = strstr(p, "\"");
|
|
|
|
if (!end)
|
2018-05-10 01:18:24 +02:00
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"Tor protocolinfo bad line '%s'",
|
|
|
|
line);
|
2018-05-10 01:18:23 +02:00
|
|
|
*end = '\0';
|
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
/* If we can't access this, try other methods */
|
|
|
|
cookiefile = tal_strdup(tmpctx, p);
|
2018-05-10 01:18:23 +02:00
|
|
|
contents = grab_file(tmpctx, p);
|
2018-05-10 01:18:24 +02:00
|
|
|
if (!contents) {
|
|
|
|
cookiefileerrno = errno;
|
|
|
|
continue;
|
|
|
|
}
|
2018-07-28 08:00:16 +02:00
|
|
|
assert(tal_count(contents) != 0);
|
2018-05-10 01:18:24 +02:00
|
|
|
discard_remaining_response(rbuf);
|
|
|
|
tor_send_cmd(rbuf,
|
2018-05-10 01:18:23 +02:00
|
|
|
tal_fmt(tmpctx, "AUTHENTICATE %s",
|
|
|
|
tal_hexstr(tmpctx,
|
|
|
|
contents,
|
2018-07-28 08:00:16 +02:00
|
|
|
tal_count(contents)-1)));
|
2018-05-10 01:18:24 +02:00
|
|
|
discard_remaining_response(rbuf);
|
2018-05-10 01:18:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2018-05-10 01:18:24 +02:00
|
|
|
|
|
|
|
/* Now report if we tried cookie file and it failed */
|
2018-05-10 01:18:24 +02:00
|
|
|
if (cookiefile)
|
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"Could not open Tor cookie file '%s': %s",
|
|
|
|
cookiefile, strerror(cookiefileerrno));
|
2018-05-10 01:18:24 +02:00
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"Tor protocolinfo did not give auth");
|
2018-05-10 01:18:19 +02:00
|
|
|
}
|
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
/* We need to have a bound address we can tell Tor to connect to */
|
2019-11-15 09:44:22 +01:00
|
|
|
const struct wireaddr *
|
2018-05-10 01:18:24 +02:00
|
|
|
find_local_address(const struct wireaddr_internal *bindings)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < tal_count(bindings); i++) {
|
|
|
|
if (bindings[i].itype != ADDR_INTERNAL_WIREADDR)
|
|
|
|
continue;
|
|
|
|
if (bindings[i].u.wireaddr.type != ADDR_TYPE_IPV4
|
|
|
|
&& bindings[i].u.wireaddr.type != ADDR_TYPE_IPV6)
|
|
|
|
continue;
|
|
|
|
return &bindings[i].u.wireaddr;
|
|
|
|
}
|
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
|
|
"No local address found to tell Tor to connect to");
|
|
|
|
}
|
|
|
|
|
|
|
|
struct wireaddr *tor_autoservice(const tal_t *ctx,
|
2019-11-15 09:44:22 +01:00
|
|
|
const struct wireaddr_internal *tor_serviceaddr,
|
2018-05-10 01:18:24 +02:00
|
|
|
const char *tor_password,
|
2019-09-25 13:05:14 +02:00
|
|
|
const struct wireaddr_internal *bindings,
|
|
|
|
const bool use_v3_autotor)
|
2018-05-10 01:18:19 +02:00
|
|
|
{
|
2018-05-10 01:18:23 +02:00
|
|
|
int fd;
|
2018-05-10 01:18:24 +02:00
|
|
|
const struct wireaddr *laddr;
|
|
|
|
struct wireaddr *onion;
|
2018-05-10 01:18:23 +02:00
|
|
|
struct addrinfo *ai_tor;
|
|
|
|
struct rbuf rbuf;
|
|
|
|
char *buffer;
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
laddr = find_local_address(bindings);
|
2019-11-15 09:44:22 +01:00
|
|
|
ai_tor = wireaddr_to_addrinfo(tmpctx, &tor_serviceaddr->u.torservice.address);
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2018-05-10 01:18:23 +02:00
|
|
|
fd = socket(ai_tor->ai_family, SOCK_STREAM, 0);
|
|
|
|
if (fd < 0)
|
|
|
|
err(1, "Creating stream socket for Tor");
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2018-05-10 01:18:23 +02:00
|
|
|
if (connect(fd, ai_tor->ai_addr, ai_tor->ai_addrlen) != 0)
|
|
|
|
err(1, "Connecting stream socket to Tor service");
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2018-05-10 01:18:23 +02:00
|
|
|
buffer = tal_arr(tmpctx, char, rbuf_good_size(fd));
|
2018-10-18 02:48:36 +02:00
|
|
|
rbuf_init(&rbuf, fd, buffer, tal_count(buffer), buf_resize);
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2018-05-10 01:18:24 +02:00
|
|
|
negotiate_auth(&rbuf, tor_password);
|
2019-11-15 09:44:22 +01:00
|
|
|
onion = make_onion(ctx, &rbuf, laddr, use_v3_autotor, tor_serviceaddr->u.torservice.port);
|
2018-05-10 01:18:19 +02:00
|
|
|
|
2018-05-10 01:18:23 +02:00
|
|
|
/*on the other hand we can stay connected until ln finish to keep onion alive and then vanish */
|
|
|
|
//because when we run with Detach flag as we now do every start of LN creates a new addr while the old
|
|
|
|
//stays valid until reboot this might not be desired so we can also drop Detach and use the
|
|
|
|
//read_partial to keep it open until LN drops
|
|
|
|
//FIXME: SAIBATO we might not want to close this conn
|
|
|
|
close(fd);
|
2018-05-10 01:18:24 +02:00
|
|
|
|
|
|
|
return onion;
|
2018-05-10 01:18:19 +02:00
|
|
|
}
|
2019-11-15 09:44:22 +01:00
|
|
|
|
|
|
|
struct wireaddr *tor_fixed_service(const tal_t *ctx,
|
|
|
|
const struct wireaddr_internal *tor_serviceaddr,
|
|
|
|
const char *tor_password,
|
|
|
|
const u8 *blob,
|
|
|
|
const struct wireaddr *bind,
|
|
|
|
const u8 index)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
const struct wireaddr *laddr;
|
|
|
|
struct wireaddr *onion;
|
|
|
|
struct addrinfo *ai_tor;
|
|
|
|
struct rbuf rbuf;
|
|
|
|
char *buffer;
|
|
|
|
|
|
|
|
laddr = bind;
|
|
|
|
ai_tor = wireaddr_to_addrinfo(tmpctx, &tor_serviceaddr->u.torservice.address);
|
|
|
|
|
|
|
|
fd = socket(ai_tor->ai_family, SOCK_STREAM, 0);
|
|
|
|
if (fd < 0)
|
|
|
|
err(1, "Creating stream socket for Tor");
|
|
|
|
|
|
|
|
if (connect(fd, ai_tor->ai_addr, ai_tor->ai_addrlen) != 0)
|
|
|
|
err(1, "Connecting stream socket to Tor service");
|
|
|
|
|
|
|
|
buffer = tal_arr(tmpctx, char, rbuf_good_size(fd));
|
|
|
|
rbuf_init(&rbuf, fd, buffer, tal_count(buffer), buf_resize);
|
|
|
|
|
|
|
|
negotiate_auth(&rbuf, tor_password);
|
|
|
|
|
|
|
|
onion = make_fixed_onion(ctx, &rbuf, laddr, blob, tor_serviceaddr->u.torservice.port);
|
|
|
|
/*on the other hand we can stay connected until ln finish to keep onion alive and then vanish
|
|
|
|
* because when we run with Detach flag as we now do every start of LN creates a new addr while the old
|
|
|
|
* stays valid until reboot this might not be desired so we can also drop Detach and use the
|
|
|
|
* read_partial to keep it open until LN drops
|
|
|
|
* DO NOT CLOSE FD TO KEEP ADDRESS ALIVE AS WE DO NOT DETACH WITH STATIC ADDRESS
|
|
|
|
*/
|
|
|
|
return onion;
|
|
|
|
}
|