From e78a6096871ad88421f7673f24139d0c3f51d867 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Thu, 14 Jan 2021 13:24:04 +0100 Subject: [PATCH] clightning: add consistent address options Also remove option 'autolisten'. This option has no effect because option 'bind-addr' is always set. --- examples/configuration.nix | 2 +- modules/clightning.nix | 28 ++++++++++------------------ modules/modules.nix | 2 +- modules/netns-isolation.nix | 2 +- modules/presets/secure-node.nix | 4 ++-- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/examples/configuration.nix b/examples/configuration.nix index 4d56fe2..c16e31e 100644 --- a/examples/configuration.nix +++ b/examples/configuration.nix @@ -49,7 +49,7 @@ ### LND # Uncomment the following line in order to enable lnd, a lightning # implementation written in Go. In order to avoid collisions with clightning - # you must disable clightning or change the services.clightning.bindport or + # you must disable clightning or change the services.clightning.port or # services.lnd.port to a port other than 9735. # services.lnd.enable = true; # Enable this option to announce our Tor Hidden Service. By default lnd diff --git a/modules/clightning.nix b/modules/clightning.nix index b5b030b..23f2307 100644 --- a/modules/clightning.nix +++ b/modules/clightning.nix @@ -13,7 +13,7 @@ let bitcoin-datadir=${config.services.bitcoind.dataDir} ${optionalString (cfg.proxy != null) "proxy=${cfg.proxy}"} always-use-proxy=${if cfg.always-use-proxy then "true" else "false"} - bind-addr=${cfg.bind-addr}:${toString cfg.bindport} + bind-addr=${cfg.address}:${toString cfg.port} bitcoin-rpcconnect=${config.services.bitcoind.rpc.address} bitcoin-rpcport=${toString config.services.bitcoind.rpc.port} bitcoin-rpcuser=${config.services.bitcoind.rpc.users.public.name} @@ -29,13 +29,15 @@ in { If enabled, the clightning service will be installed. ''; }; - autolisten = mkOption { - type = types.bool; - default = false; - description = '' - Bind (and maybe announce) on IPv4 and IPv6 interfaces if no addr, - bind-addr or announce-addr options are specified. - ''; + address = mkOption { + type = types.str; + default = "127.0.0.1"; + description = "IP address or UNIX domain socket to listen for peer connections."; + }; + port = mkOption { + type = types.port; + default = 9735; + description = "Port to listen for peer connections."; }; proxy = mkOption { type = types.nullOr types.str; @@ -49,16 +51,6 @@ in { Always use the *proxy*, even to connect to normal IP addresses (you can still connect to Unix domain sockets manually). This also disables all DNS lookups, to avoid leaking information. ''; }; - bind-addr = mkOption { - type = nbPkgs.lib.ipv4Address; - default = "127.0.0.1"; - description = "Set an IP address or UNIX domain socket to listen to"; - }; - bindport = mkOption { - type = types.port; - default = 9735; - description = "Set a Port to listen to locally"; - }; announce-tor = mkOption { type = types.bool; default = false; diff --git a/modules/modules.nix b/modules/modules.nix index fb366dd..9c2b18d 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -58,7 +58,7 @@ with lib; config = { assertions = [ - { assertion = (config.services.lnd.enable -> ( !config.services.clightning.enable || config.services.clightning.bindport != config.services.lnd.port)); + { assertion = (config.services.lnd.enable -> ( !config.services.clightning.enable || config.services.clightning.port != config.services.lnd.port)); message = '' LND and clightning can't both bind to lightning port 9735. Either disable LND/clightning or change services.clightning.bindPort or diff --git a/modules/netns-isolation.nix b/modules/netns-isolation.nix index 47bf3f1..03501c6 100644 --- a/modules/netns-isolation.nix +++ b/modules/netns-isolation.nix @@ -254,7 +254,7 @@ in { }; systemd.services.bitcoind-import-banlist.serviceConfig.NetworkNamespacePath = "/var/run/netns/nb-bitcoind"; - services.clightning.bind-addr = netns.clightning.address; + services.clightning.address = netns.clightning.address; services.lnd = { address = netns.lnd.address; diff --git a/modules/presets/secure-node.nix b/modules/presets/secure-node.nix index 87b59be..9417bcc 100644 --- a/modules/presets/secure-node.nix +++ b/modules/presets/secure-node.nix @@ -68,8 +68,8 @@ in { services.clightning.enforceTor = true; services.tor.hiddenServices.clightning = mkIf cfg.clightning.enable (mkHiddenService { port = cfg.clightning.onionport; - toHost = cfg.clightning.bind-addr; - toPort = cfg.clightning.bindport; + toHost = cfg.clightning.address; + toPort = cfg.clightning.port; }); # lnd