Skip to content

Commit f844eb0

Browse files
committed
lightningd: add dev-uniform-padding flag to lightningd
1 parent 9761c3b commit f844eb0

File tree

6 files changed

+16
-2
lines changed

6 files changed

+16
-2
lines changed

connectd/connectd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,8 @@ static void connect_init(struct daemon *daemon, const u8 *msg)
16921692
&daemon->dev_no_reconnect,
16931693
&daemon->dev_fast_reconnect,
16941694
&dev_limit_connections_inflight,
1695-
&daemon->dev_keep_nagle)) {
1695+
&daemon->dev_keep_nagle,
1696+
&daemon->dev_uniform_padding)) {
16961697
/* This is a helper which prints the type expected and the actual
16971698
* message, then exits (it should never be called!). */
16981699
master_badmsg(WIRE_CONNECTD_INIT, msg);
@@ -2569,6 +2570,7 @@ int main(int argc, char *argv[])
25692570
daemon->dev_exhausted_fds = false;
25702571
daemon->dev_lightningd_is_slow = false;
25712572
daemon->dev_keep_nagle = false;
2573+
daemon->dev_uniform_padding = false;
25722574
/* We generally allow 1MB per second per peer, except for dev testing */
25732575
daemon->gossip_stream_limit = 1000000;
25742576
daemon->incoming_stream_limit = 1000000;

connectd/connectd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ struct daemon {
318318
/* Allow localhost to be considered "public", only with --developer */
319319
bool dev_allow_localhost;
320320

321+
/* Pad outgoing messages to uniform 1460-byte segments (traffic analysis defence) */
322+
bool dev_uniform_padding;
323+
321324
/* How much to gossip allow a peer every second (bytes) */
322325
size_t gossip_stream_limit;
323326

lightningd/connect_control.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,8 @@ int connectd_init(struct lightningd *ld)
727727
!ld->reconnect,
728728
ld->dev_fast_reconnect,
729729
ld->dev_limit_connections_inflight,
730-
ld->dev_keep_nagle);
730+
ld->dev_keep_nagle,
731+
ld->dev_uniform_padding);
731732

732733
subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,
733734
connect_init_done, NULL);

lightningd/lightningd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
150150
ld->dev_strict_forwarding = false;
151151
ld->dev_limit_connections_inflight = false;
152152
ld->dev_keep_nagle = false;
153+
ld->dev_uniform_padding = false;
153154

154155
/*~ We try to ensure enough fds for twice the number of channels
155156
* we start with. We have a developer option to change that factor

lightningd/lightningd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ struct lightningd {
369369
/* Tell connectd we don't want TCP_NODELAY */
370370
bool dev_keep_nagle;
371371

372+
/* Pad outgoing messages to uniform 1460-byte segments (traffic analysis defence) */
373+
bool dev_uniform_padding;
374+
372375
/* tor support */
373376
struct wireaddr *proxyaddr;
374377
bool always_use_proxy;

lightningd/options.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,10 @@ static void dev_register_opts(struct lightningd *ld)
952952
opt_set_bool,
953953
&ld->dev_keep_nagle,
954954
"Tell connectd not to set TCP_NODELAY.");
955+
clnopt_noarg("--dev-uniform-padding", OPT_DEV,
956+
opt_set_bool,
957+
&ld->dev_uniform_padding,
958+
"Pad all outgoing peer messages to uniform 1460-byte segments");
955959
/* This is handled directly in daemon_developer_mode(), so we ignore it here */
956960
clnopt_noarg("--dev-debug-self", OPT_DEV,
957961
opt_ignore,

0 commit comments

Comments
 (0)