Packet filter cli option (#2523)
## Issue Addressed N/A ## Proposed Changes Adds a cli option to disable packet filter in `lighthouse bootnode`. This is useful in running local testnets as the bootnode bans requests from the same ip(localhost) if the packet filter is enabled.
This commit is contained in:
parent
aca49fc45e
commit
d3b4cbed53
@ -45,6 +45,12 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
|||||||
--subscribe-all-subnets to ensure all attestations are received for import.")
|
--subscribe-all-subnets to ensure all attestations are received for import.")
|
||||||
.takes_value(false),
|
.takes_value(false),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("disable-packet-filter")
|
||||||
|
.long("disable-packet-filter")
|
||||||
|
.help("Disables the discovery packet filter. Useful for testing in smaller networks")
|
||||||
|
.takes_value(false),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("zero-ports")
|
Arg::with_name("zero-ports")
|
||||||
.long("zero-ports")
|
.long("zero-ports")
|
||||||
|
@ -612,6 +612,11 @@ pub fn set_network_config(
|
|||||||
config.discv5_config.enr_update = false;
|
config.discv5_config.enr_update = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cli_args.is_present("disable-packet-filter") {
|
||||||
|
warn!(log, "Discv5 packet filter is disabled");
|
||||||
|
config.discv5_config.enable_packet_filter = false;
|
||||||
|
}
|
||||||
|
|
||||||
if cli_args.is_present("disable-discovery") {
|
if cli_args.is_present("disable-discovery") {
|
||||||
config.disable_discovery = true;
|
config.disable_discovery = true;
|
||||||
warn!(log, "Discovery is disabled. New peers will not be found");
|
warn!(log, "Discovery is disabled. New peers will not be found");
|
||||||
|
@ -60,6 +60,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
|||||||
.help("Discovery can automatically update the node's local ENR with an external IP address and port as seen by other peers on the network. \
|
.help("Discovery can automatically update the node's local ENR with an external IP address and port as seen by other peers on the network. \
|
||||||
This enables this feature.")
|
This enables this feature.")
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("disable-packet-filter")
|
||||||
|
.long("disable-packet-filter")
|
||||||
|
.help("Disables discv5 packet filter. Useful for testing in smaller networks")
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("network-dir")
|
Arg::with_name("network-dir")
|
||||||
.value_name("NETWORK_DIR")
|
.value_name("NETWORK_DIR")
|
||||||
|
@ -19,6 +19,7 @@ pub struct BootNodeConfig<T: EthSpec> {
|
|||||||
pub local_enr: Enr,
|
pub local_enr: Enr,
|
||||||
pub local_key: CombinedKey,
|
pub local_key: CombinedKey,
|
||||||
pub auto_update: bool,
|
pub auto_update: bool,
|
||||||
|
pub disable_packet_filter: bool,
|
||||||
phantom: PhantomData<T>,
|
phantom: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ impl<T: EthSpec> TryFrom<&ArgMatches<'_>> for BootNodeConfig<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let auto_update = matches.is_present("enable-enr_auto_update");
|
let auto_update = matches.is_present("enable-enr_auto_update");
|
||||||
|
let disable_packet_filter = matches.is_present("disable-packet-filter");
|
||||||
|
|
||||||
// the address to listen on
|
// the address to listen on
|
||||||
let listen_socket =
|
let listen_socket =
|
||||||
@ -128,6 +130,7 @@ impl<T: EthSpec> TryFrom<&ArgMatches<'_>> for BootNodeConfig<T> {
|
|||||||
local_enr,
|
local_enr,
|
||||||
local_key,
|
local_key,
|
||||||
auto_update,
|
auto_update,
|
||||||
|
disable_packet_filter,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,9 @@ pub async fn run<T: EthSpec>(config: BootNodeConfig<T>, log: slog::Logger) {
|
|||||||
|
|
||||||
let discv5_config = {
|
let discv5_config = {
|
||||||
let mut builder = Discv5ConfigBuilder::new();
|
let mut builder = Discv5ConfigBuilder::new();
|
||||||
builder.enable_packet_filter();
|
if !config.disable_packet_filter {
|
||||||
|
builder.enable_packet_filter();
|
||||||
|
}
|
||||||
if !config.auto_update {
|
if !config.auto_update {
|
||||||
builder.disable_enr_update();
|
builder.disable_enr_update();
|
||||||
}
|
}
|
||||||
|
@ -21,4 +21,5 @@ exec lighthouse \
|
|||||||
--enr-tcp-port $2 \
|
--enr-tcp-port $2 \
|
||||||
--port $2 \
|
--port $2 \
|
||||||
--http-port $3 \
|
--http-port $3 \
|
||||||
|
--disable-packet-filter \
|
||||||
--target-peers $((NODE_COUNT - 1))
|
--target-peers $((NODE_COUNT - 1))
|
||||||
|
@ -30,4 +30,5 @@ exec lighthouse boot_node \
|
|||||||
--testnet-dir $TESTNET_DIR \
|
--testnet-dir $TESTNET_DIR \
|
||||||
--port $BOOTNODE_PORT \
|
--port $BOOTNODE_PORT \
|
||||||
--listen-address 127.0.0.1 \
|
--listen-address 127.0.0.1 \
|
||||||
|
--disable-packet-filter \
|
||||||
--network-dir $DATADIR/bootnode \
|
--network-dir $DATADIR/bootnode \
|
||||||
|
Loading…
Reference in New Issue
Block a user