mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
opts: adds --announce-addr-discovered-port config option
This will give the user an option to set a custom port when using discovered IPs for node_announcents. Without this, only the selected networks default port can used. Changelog-Added: Adds --announce-addr-discovered-port config option to set custom port for IP discovery.
This commit is contained in:
@@ -62,6 +62,9 @@ struct config {
|
|||||||
/* Excplicitly turns 'on' or 'off' IP discovery feature. */
|
/* Excplicitly turns 'on' or 'off' IP discovery feature. */
|
||||||
enum opt_autobool ip_discovery;
|
enum opt_autobool ip_discovery;
|
||||||
|
|
||||||
|
/* Public TCP port assumed for IP discovery. Defaults to chainparams. */
|
||||||
|
u32 ip_discovery_port;
|
||||||
|
|
||||||
/* Minimal amount of effective funding_satoshis for accepting channels */
|
/* Minimal amount of effective funding_satoshis for accepting channels */
|
||||||
u64 min_capacity_sat;
|
u64 min_capacity_sat;
|
||||||
|
|
||||||
|
|||||||
@@ -846,6 +846,9 @@ static const struct config testnet_config = {
|
|||||||
/* Excplicitly turns 'on' or 'off' IP discovery feature. */
|
/* Excplicitly turns 'on' or 'off' IP discovery feature. */
|
||||||
.ip_discovery = OPT_AUTOBOOL_AUTO,
|
.ip_discovery = OPT_AUTOBOOL_AUTO,
|
||||||
|
|
||||||
|
/* Public TCP port assumed for IP discovery. Defaults to chainparams. */
|
||||||
|
.ip_discovery_port = 0,
|
||||||
|
|
||||||
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */
|
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */
|
||||||
.min_capacity_sat = 10000,
|
.min_capacity_sat = 10000,
|
||||||
|
|
||||||
@@ -912,6 +915,9 @@ static const struct config mainnet_config = {
|
|||||||
/* Excplicitly turns 'on' or 'off' IP discovery feature. */
|
/* Excplicitly turns 'on' or 'off' IP discovery feature. */
|
||||||
.ip_discovery = OPT_AUTOBOOL_AUTO,
|
.ip_discovery = OPT_AUTOBOOL_AUTO,
|
||||||
|
|
||||||
|
/* Public TCP port assumed for IP discovery. Defaults to chainparams. */
|
||||||
|
.ip_discovery_port = 0,
|
||||||
|
|
||||||
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */
|
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */
|
||||||
.min_capacity_sat = 10000,
|
.min_capacity_sat = 10000,
|
||||||
|
|
||||||
@@ -1223,6 +1229,9 @@ static void register_opts(struct lightningd *ld)
|
|||||||
opt_register_arg("--announce-addr-discovered", opt_set_autobool_arg, opt_show_autobool,
|
opt_register_arg("--announce-addr-discovered", opt_set_autobool_arg, opt_show_autobool,
|
||||||
&ld->config.ip_discovery,
|
&ld->config.ip_discovery,
|
||||||
"Explicitly turns IP discovery 'on' or 'off'.");
|
"Explicitly turns IP discovery 'on' or 'off'.");
|
||||||
|
opt_register_arg("--announce-addr-discovered-port", opt_set_uintval,
|
||||||
|
opt_show_uintval, &ld->config.ip_discovery_port,
|
||||||
|
"Sets the public TCP port to use for announcing discovered IPs.");
|
||||||
|
|
||||||
opt_register_noarg("--offline", opt_set_offline, ld,
|
opt_register_noarg("--offline", opt_set_offline, ld,
|
||||||
"Start in offline-mode (do not automatically reconnect and do not accept incoming connections)");
|
"Start in offline-mode (do not automatically reconnect and do not accept incoming connections)");
|
||||||
@@ -1427,6 +1436,9 @@ void handle_early_opts(struct lightningd *ld, int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
ld->config = mainnet_config;
|
ld->config = mainnet_config;
|
||||||
|
|
||||||
|
/* Set the ln_port given from chainparams */
|
||||||
|
ld->config.ip_discovery_port = chainparams->ln_port;
|
||||||
|
|
||||||
/* Now we can initialize wallet_dsn */
|
/* Now we can initialize wallet_dsn */
|
||||||
ld->wallet_dsn = tal_fmt(ld, "sqlite3://%s/lightningd.sqlite3",
|
ld->wallet_dsn = tal_fmt(ld, "sqlite3://%s/lightningd.sqlite3",
|
||||||
ld->config_netdir);
|
ld->config_netdir);
|
||||||
|
|||||||
@@ -1305,18 +1305,11 @@ static void update_remote_addr(struct lightningd *ld,
|
|||||||
const struct wireaddr *remote_addr,
|
const struct wireaddr *remote_addr,
|
||||||
const struct node_id peer_id)
|
const struct node_id peer_id)
|
||||||
{
|
{
|
||||||
u16 public_port;
|
|
||||||
|
|
||||||
/* failsafe to prevent privacy leakage. */
|
/* failsafe to prevent privacy leakage. */
|
||||||
if (ld->always_use_proxy ||
|
if (ld->always_use_proxy ||
|
||||||
ld->config.ip_discovery == OPT_AUTOBOOL_FALSE)
|
ld->config.ip_discovery == OPT_AUTOBOOL_FALSE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Peers will have likey reported our dynamic outbound TCP port.
|
|
||||||
* Best guess is that we use default port for the selected network,
|
|
||||||
* until we add a commandline switch to override this. */
|
|
||||||
public_port = chainparams_get_ln_port(chainparams);
|
|
||||||
|
|
||||||
switch (remote_addr->type) {
|
switch (remote_addr->type) {
|
||||||
case ADDR_TYPE_IPV4:
|
case ADDR_TYPE_IPV4:
|
||||||
/* init pointers first time */
|
/* init pointers first time */
|
||||||
@@ -1334,7 +1327,7 @@ static void update_remote_addr(struct lightningd *ld,
|
|||||||
if (wireaddr_eq_without_port(ld->remote_addr_v4, remote_addr)) {
|
if (wireaddr_eq_without_port(ld->remote_addr_v4, remote_addr)) {
|
||||||
ld->discovered_ip_v4 = tal_dup(ld, struct wireaddr,
|
ld->discovered_ip_v4 = tal_dup(ld, struct wireaddr,
|
||||||
ld->remote_addr_v4);
|
ld->remote_addr_v4);
|
||||||
ld->discovered_ip_v4->port = public_port;
|
ld->discovered_ip_v4->port = ld->config.ip_discovery_port;
|
||||||
subd_send_msg(ld->gossip, towire_gossipd_discovered_ip(
|
subd_send_msg(ld->gossip, towire_gossipd_discovered_ip(
|
||||||
tmpctx,
|
tmpctx,
|
||||||
ld->discovered_ip_v4));
|
ld->discovered_ip_v4));
|
||||||
@@ -1357,7 +1350,7 @@ static void update_remote_addr(struct lightningd *ld,
|
|||||||
if (wireaddr_eq_without_port(ld->remote_addr_v6, remote_addr)) {
|
if (wireaddr_eq_without_port(ld->remote_addr_v6, remote_addr)) {
|
||||||
ld->discovered_ip_v6 = tal_dup(ld, struct wireaddr,
|
ld->discovered_ip_v6 = tal_dup(ld, struct wireaddr,
|
||||||
ld->remote_addr_v6);
|
ld->remote_addr_v6);
|
||||||
ld->discovered_ip_v6->port = public_port;
|
ld->discovered_ip_v6->port = ld->config.ip_discovery_port;
|
||||||
subd_send_msg(ld->gossip, towire_gossipd_discovered_ip(
|
subd_send_msg(ld->gossip, towire_gossipd_discovered_ip(
|
||||||
tmpctx,
|
tmpctx,
|
||||||
ld->discovered_ip_v6));
|
ld->discovered_ip_v6));
|
||||||
|
|||||||
Reference in New Issue
Block a user