nodeinfo/lnd: add onion_rest_address
This commit is contained in:
parent
5b6cd9fd49
commit
52810e6c88
@ -162,7 +162,10 @@ in {
|
|||||||
port = lnd.restPort;
|
port = lnd.restPort;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
nix-bitcoin.onionAddresses.access.${lnd.user} = [ "lnd-rest" ];
|
nix-bitcoin.onionAddresses.access = {
|
||||||
|
${lnd.user} = [ "lnd-rest" ];
|
||||||
|
${operatorName} = [ "lnd-rest" ];
|
||||||
|
};
|
||||||
})
|
})
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ let
|
|||||||
infos = OrderedDict()
|
infos = OrderedDict()
|
||||||
operator = "${config.nix-bitcoin.operator.name}"
|
operator = "${config.nix-bitcoin.operator.name}"
|
||||||
|
|
||||||
def set_onion_address(info, name, port):
|
def get_onion_address(name, port):
|
||||||
path = f"/var/lib/onion-addresses/{operator}/{name}"
|
path = f"/var/lib/onion-addresses/{operator}/{name}"
|
||||||
try:
|
try:
|
||||||
with open(path, "r") as f:
|
with open(path, "r") as f:
|
||||||
@ -71,7 +71,7 @@ let
|
|||||||
except OSError:
|
except OSError:
|
||||||
print(f"error reading file {path}", file=sys.stderr)
|
print(f"error reading file {path}", file=sys.stderr)
|
||||||
return
|
return
|
||||||
info["onion_address"] = f"{onion_address}:{port}"
|
return f"{onion_address}:{port}"
|
||||||
|
|
||||||
def add_service(service, make_info, systemd_service = None):
|
def add_service(service, make_info, systemd_service = None):
|
||||||
systemd_service = systemd_service or service
|
systemd_service = systemd_service or service
|
||||||
@ -106,7 +106,7 @@ let
|
|||||||
add_service("${name}", """
|
add_service("${name}", """
|
||||||
info["local_address"] = "${nbLib.addressWithPort cfg.address cfg.port}"
|
info["local_address"] = "${nbLib.addressWithPort cfg.address cfg.port}"
|
||||||
'' + mkIfOnionPort name (onionPort: ''
|
'' + mkIfOnionPort name (onionPort: ''
|
||||||
set_onion_address(info, "${name}", ${onionPort})
|
info["onion_address"] = get_onion_address("${name}", ${onionPort})
|
||||||
'') + extraCode + ''
|
'') + extraCode + ''
|
||||||
|
|
||||||
""", "${systemdServiceName}")
|
""", "${systemdServiceName}")
|
||||||
@ -133,10 +133,13 @@ in {
|
|||||||
if 'onion_address' in info:
|
if 'onion_address' in info:
|
||||||
info["id"] = f"{info['nodeid']}@{info['onion_address']}"
|
info["id"] = f"{info['nodeid']}@{info['onion_address']}"
|
||||||
'';
|
'';
|
||||||
lnd = name: cfg: mkInfo ''
|
lnd = name: cfg: mkInfo (''
|
||||||
info["rest_address"] = "${nbLib.addressWithPort cfg.restAddress cfg.restPort}"
|
info["rest_address"] = "${nbLib.addressWithPort cfg.restAddress cfg.restPort}"
|
||||||
|
'' + mkIfOnionPort "lnd-rest" (onionPort: ''
|
||||||
|
info["onion_rest_address"] = get_onion_address("lnd-rest", ${onionPort})
|
||||||
|
'') + ''
|
||||||
info["nodeid"] = shell("lncli getinfo | jq -r '.identity_pubkey'")
|
info["nodeid"] = shell("lncli getinfo | jq -r '.identity_pubkey'")
|
||||||
'' name cfg;
|
'') name cfg;
|
||||||
clightning-rest = mkInfo "";
|
clightning-rest = mkInfo "";
|
||||||
electrs = mkInfo "";
|
electrs = mkInfo "";
|
||||||
fulcrum = mkInfo "";
|
fulcrum = mkInfo "";
|
||||||
@ -147,7 +150,7 @@ in {
|
|||||||
rtl = mkInfo "";
|
rtl = mkInfo "";
|
||||||
# Only add sshd when it has an onion service
|
# Only add sshd when it has an onion service
|
||||||
sshd = name: cfg: mkIfOnionPort "sshd" (onionPort: ''
|
sshd = name: cfg: mkIfOnionPort "sshd" (onionPort: ''
|
||||||
add_service("sshd", """set_onion_address(info, "sshd", ${onionPort})""")
|
add_service("sshd", """info["onion_address"] = get_onion_address("sshd", ${onionPort})""")
|
||||||
'');
|
'');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user