Skip to content

Commit 8cd3547

Browse files
committed
lightningd: add alt-addr config parameter
- Aswell as parameters alt-bind-addr and alt-announce-addr Changelog-Added: Introduced the 'alt-addr' config parameter for specifying alternative addresses. Signed-off-by: Max Rantil <rantil@pm.me>
1 parent 873e8b4 commit 8cd3547

File tree

10 files changed

+361
-4
lines changed

10 files changed

+361
-4
lines changed

.msggen.json

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,9 @@
16051605
"ListConfigs.configs.addr": 47,
16061606
"ListConfigs.configs.alias": 30,
16071607
"ListConfigs.configs.allow-deprecated-apis": 14,
1608+
"ListConfigs.configs.alt-addr": 71,
1609+
"ListConfigs.configs.alt-announce-addr": 73,
1610+
"ListConfigs.configs.alt-bind-addr": 72,
16081611
"ListConfigs.configs.always-use-proxy": 17,
16091612
"ListConfigs.configs.announce-addr": 48,
16101613
"ListConfigs.configs.announce-addr-discovered": 54,
@@ -1688,6 +1691,22 @@
16881691
"ListConfigs.configs.allow-deprecated-apis.source": 2,
16891692
"ListConfigs.configs.allow-deprecated-apis.value_bool": 1
16901693
},
1694+
"ListconfigsConfigsAlt-addr": {
1695+
"ListConfigs.configs.alt-addr.sources[]": 2,
1696+
"ListConfigs.configs.alt-addr.values_str[]": 1
1697+
},
1698+
"ListconfigsConfigsAlt-announce-addr": {
1699+
"ListConfigs.configs.alt-addr.sources[]": 2,
1700+
"ListConfigs.configs.alt-addr.values_str[]": 1,
1701+
"ListConfigs.configs.alt-announce-addr.sources[]": 2,
1702+
"ListConfigs.configs.alt-announce-addr.values_str[]": 1
1703+
},
1704+
"ListconfigsConfigsAlt-bind-addr": {
1705+
"ListConfigs.configs.alt-addr.sources[]": 2,
1706+
"ListConfigs.configs.alt-addr.values_str[]": 1,
1707+
"ListConfigs.configs.alt-bind-addr.sources[]": 2,
1708+
"ListConfigs.configs.alt-bind-addr.values_str[]": 1
1709+
},
16911710
"ListconfigsConfigsAlways-use-proxy": {
16921711
"ListConfigs.configs.always-use-proxy.source": 2,
16931712
"ListConfigs.configs.always-use-proxy.value_bool": 1
@@ -6746,6 +6765,42 @@
67466765
"added": "pre-v0.10.1",
67476766
"deprecated": null
67486767
},
6768+
"ListConfigs.configs.alt-addr": {
6769+
"added": "v24.11",
6770+
"deprecated": false
6771+
},
6772+
"ListConfigs.configs.alt-addr.sources[]": {
6773+
"added": "v24.11",
6774+
"deprecated": false
6775+
},
6776+
"ListConfigs.configs.alt-addr.values_str[]": {
6777+
"added": "v24.11",
6778+
"deprecated": false
6779+
},
6780+
"ListConfigs.configs.alt-announce-addr": {
6781+
"added": "v24.11",
6782+
"deprecated": false
6783+
},
6784+
"ListConfigs.configs.alt-announce-addr.sources[]": {
6785+
"added": "v24.11",
6786+
"deprecated": false
6787+
},
6788+
"ListConfigs.configs.alt-announce-addr.values_str[]": {
6789+
"added": "v24.11",
6790+
"deprecated": false
6791+
},
6792+
"ListConfigs.configs.alt-bind-addr": {
6793+
"added": "v24.11",
6794+
"deprecated": false
6795+
},
6796+
"ListConfigs.configs.alt-bind-addr.sources[]": {
6797+
"added": "v24.11",
6798+
"deprecated": false
6799+
},
6800+
"ListConfigs.configs.alt-bind-addr.values_str[]": {
6801+
"added": "v24.11",
6802+
"deprecated": false
6803+
},
67496804
"ListConfigs.configs.always-use-proxy": {
67506805
"added": "pre-v0.10.1",
67516806
"deprecated": null
@@ -11687,4 +11742,4 @@
1168711742
"deprecated": null
1168811743
}
1168911744
}
11690-
}
11745+
}

channeld/channeld.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ struct peer {
6666
bool channel_ready[NUM_SIDES];
6767
u64 next_index[NUM_SIDES];
6868

69+
/* ID of peer */
70+
struct node_id id;
71+
6972
/* --developer? */
7073
bool developer;
7174

@@ -169,6 +172,9 @@ struct peer {
169172
u64 revocations_received;
170173
u8 channel_flags;
171174

175+
/* Alt address for peer connections not publicly announced */
176+
u8 *my_alt_addr;
177+
172178
/* Make sure timestamps move forward. */
173179
u32 last_update_timestamp;
174180

@@ -5847,7 +5853,9 @@ static void init_channel(struct peer *peer)
58475853
&reestablish_only,
58485854
&peer->experimental_upgrade,
58495855
&peer->splice_state->inflights,
5850-
&peer->local_alias)) {
5856+
&peer->local_alias,
5857+
&peer->my_alt_addr,
5858+
&peer->id)) {
58515859
master_badmsg(WIRE_CHANNELD_INIT, msg);
58525860
}
58535861

channeld/channeld_wire.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ msgdata,channeld_init,experimental_upgrade,bool,
7777
msgdata,channeld_init,num_inflights,u16,
7878
msgdata,channeld_init,inflights,inflight,num_inflights
7979
msgdata,channeld_init,scid_alias,short_channel_id,
80+
msgdata,channeld_init,alt_addr_len,u16,
81+
msgdata,channeld_init,alt_addr,u8,alt_addr_len,
82+
msgdata,channeld_init,id,node_id,
8083

8184
# channeld->lightningd: successfully negotated reestablishment.
8285
msgtype,channeld_reestablished,1101

contrib/msggen/msggen/schema.json

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17179,6 +17179,93 @@
1717917179
}
1718017180
}
1718117181
},
17182+
"alt-addr": {
17183+
"type": "object",
17184+
"additionalProperties": false,
17185+
"required": [
17186+
"values_str",
17187+
"sources"
17188+
],
17189+
"properties": {
17190+
"values_str": {
17191+
"added": "v24.11",
17192+
"type": "array",
17193+
"items": {
17194+
"type": "string",
17195+
"description": [
17196+
"Field from config or cmdline."
17197+
]
17198+
}
17199+
},
17200+
"sources": {
17201+
"type": "array",
17202+
"items": {
17203+
"type": "string",
17204+
"description": [
17205+
"Source of configuration setting."
17206+
]
17207+
}
17208+
}
17209+
}
17210+
},
17211+
"alt-announce-addr": {
17212+
"type": "object",
17213+
"additionalProperties": false,
17214+
"required": [
17215+
"values_str",
17216+
"sources"
17217+
],
17218+
"properties": {
17219+
"values_str": {
17220+
"added": "v24.11",
17221+
"type": "array",
17222+
"items": {
17223+
"type": "string",
17224+
"description": [
17225+
"Field from config or cmdline."
17226+
]
17227+
}
17228+
},
17229+
"sources": {
17230+
"type": "array",
17231+
"items": {
17232+
"type": "string",
17233+
"description": [
17234+
"Source of configuration setting."
17235+
]
17236+
}
17237+
}
17238+
}
17239+
},
17240+
"alt-bind-addr": {
17241+
"type": "object",
17242+
"additionalProperties": false,
17243+
"required": [
17244+
"values_str",
17245+
"sources"
17246+
],
17247+
"properties": {
17248+
"values_str": {
17249+
"added": "v24.11",
17250+
"type": "array",
17251+
"items": {
17252+
"type": "string",
17253+
"description": [
17254+
"Field from config or cmdline."
17255+
]
17256+
}
17257+
},
17258+
"sources": {
17259+
"type": "array",
17260+
"items": {
17261+
"type": "string",
17262+
"description": [
17263+
"Source of configuration setting."
17264+
]
17265+
}
17266+
}
17267+
}
17268+
},
1718217269
"autolisten": {
1718317270
"type": "object",
1718417271
"additionalProperties": false,
@@ -34924,4 +35011,4 @@
3492435011
}
3492535012
}
3492635013
}
34927-
}
35014+
}

doc/lightningd-config.5.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,37 @@ its use disables autolisten.
635635
can be useful for maintenance and forensics, so is usually specified on
636636
the command line. Overrides all *addr* and *bind-addr* options.
637637

638+
* **alt-addr**=*\[IPADDRESS\[:PORT\]]\*
639+
640+
Specify an alternative IP address (v4 or v6) and optionally a port,
641+
to be used for selective private communications with established peers.
642+
This address is used selectively, primarily for reconnections with known peers,
643+
enhancing privacy. This address is not publicly announced.
644+
645+
An empty 'IPADDRESS' is a special value that clears any previously saved
646+
alternate addresses, effectively resetting this setting. (Added in v24.11).
647+
648+
* **alt-bind-addr**=*\[IPADDRESS\[:PORT\]]\*
649+
650+
Bind an alternative IP address (v4 or v6) and optionally a port,
651+
but hold it in reserve and do not automatically use it for peer connections.
652+
This address can be used in specific scenarios where a non-public address is
653+
preferred for incoming connections, offering more control over the connection process.
654+
655+
An empty 'IPADDRESS' is a special value that clears any previously saved
656+
alternate bind addresses, effectively resetting this setting. (Added in v24.11).
657+
658+
* **alt-announce-addr**=*\[IPADDRESS\[:PORT\]]\*
659+
660+
Provide an alternative IP address (v4 or v6) and optionally a port,
661+
which is bound by `alt-bind-addr`, to any established channel peers.
662+
This address is given to peers with whom a channel is already established,
663+
allowing for enhanced privacy. This address is not used for initial connections
664+
but can be shared with trusted peers for future communications.
665+
666+
An empty 'IPADDRESS' is a special value that clears any previously saved
667+
alternate announce addresses, effectively resetting this setting. (Added in v24.11).
668+
638669
* **autolisten**=*BOOL*
639670

640671
By default, we bind (and maybe announce) on IPv4 and IPv6 interfaces if

doc/schemas/lightning-listconfigs.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,93 @@
12011201
}
12021202
}
12031203
},
1204+
"alt-addr": {
1205+
"type": "object",
1206+
"additionalProperties": false,
1207+
"required": [
1208+
"values_str",
1209+
"sources"
1210+
],
1211+
"properties": {
1212+
"values_str": {
1213+
"added": "v24.11",
1214+
"type": "array",
1215+
"items": {
1216+
"type": "string",
1217+
"description": [
1218+
"Field from config or cmdline."
1219+
]
1220+
}
1221+
},
1222+
"sources": {
1223+
"type": "array",
1224+
"items": {
1225+
"type": "string",
1226+
"description": [
1227+
"Source of configuration setting."
1228+
]
1229+
}
1230+
}
1231+
}
1232+
},
1233+
"alt-announce-addr": {
1234+
"type": "object",
1235+
"additionalProperties": false,
1236+
"required": [
1237+
"values_str",
1238+
"sources"
1239+
],
1240+
"properties": {
1241+
"values_str": {
1242+
"added": "v24.11",
1243+
"type": "array",
1244+
"items": {
1245+
"type": "string",
1246+
"description": [
1247+
"Field from config or cmdline."
1248+
]
1249+
}
1250+
},
1251+
"sources": {
1252+
"type": "array",
1253+
"items": {
1254+
"type": "string",
1255+
"description": [
1256+
"Source of configuration setting."
1257+
]
1258+
}
1259+
}
1260+
}
1261+
},
1262+
"alt-bind-addr": {
1263+
"type": "object",
1264+
"additionalProperties": false,
1265+
"required": [
1266+
"values_str",
1267+
"sources"
1268+
],
1269+
"properties": {
1270+
"values_str": {
1271+
"added": "v24.11",
1272+
"type": "array",
1273+
"items": {
1274+
"type": "string",
1275+
"description": [
1276+
"Field from config or cmdline."
1277+
]
1278+
}
1279+
},
1280+
"sources": {
1281+
"type": "array",
1282+
"items": {
1283+
"type": "string",
1284+
"description": [
1285+
"Source of configuration setting."
1286+
]
1287+
}
1288+
}
1289+
}
1290+
},
12041291
"autolisten": {
12051292
"type": "object",
12061293
"additionalProperties": false,

lightningd/channel_control.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,9 @@ bool peer_start_channeld(struct channel *channel,
17621762
ld->experimental_upgrade_protocol,
17631763
cast_const2(const struct inflight **,
17641764
inflights),
1765-
*channel->alias[LOCAL]);
1765+
*channel->alias[LOCAL],
1766+
ld->alt_addr,
1767+
&ld->our_nodeid);
17661768

17671769
/* We don't expect a response: we are triggered by funding_depth_cb. */
17681770
subd_send_msg(channel->owner, take(initmsg));

lightningd/lightningd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
258258
ld->recover_secret = NULL;
259259
ld->db_upgrade_ok = NULL;
260260
ld->num_startup_connects = 0;
261+
ld->alt_addr = NULL;
262+
ld->alt_bind_addr = NULL;
261263

262264
/* --experimental-upgrade-protocol */
263265
ld->experimental_upgrade_protocol = false;

lightningd/lightningd.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ struct lightningd {
194194
struct wireaddr_internal *binding;
195195
struct wireaddr *announceable;
196196

197+
/* Alternative address for peer connections not publicly announced */
198+
u8 *alt_addr;
199+
/* Alternative binding address for peer connections not publicly announced */
200+
u8 *alt_bind_addr;
201+
197202
/* Current node announcement (if any) */
198203
const u8 *node_announcement;
199204

0 commit comments

Comments
 (0)