discv5_cli/server/
command.rs

1use clap::{Args, Subcommand as ClapSubcommand};
2
3/// Server Subcommand
4#[derive(ClapSubcommand, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Default)]
5pub enum ServerSubcommand {
6    /// Queries random node ids.
7    #[default]
8    Query,
9    /// Prints the event stream.
10    Events,
11}
12
13/// Server Command
14#[derive(Args, Default, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
15pub struct Server {
16    /// The service to run once the server is started.
17    #[clap(subcommand)]
18    pub service: ServerSubcommand,
19    /// Specifies the listening address of the server.
20    #[clap(
21        short = 'l',
22        long = "listen-addresses",
23        help = "Specifies the listening address(es) of the server. A comma separated string can specify ipv4 and ipv6 addresses for dual stack.",
24        default_value = "0.0.0.0"
25    )]
26    pub listen_addresses: String,
27    /// Specifies the listening UDP port of the server.
28    #[clap(
29        short = 'p',
30        long = "listen-port",
31        help = "Specifies the listening UDP port of the server.",
32        default_value = "9000"
33    )]
34    pub listen_port: u16,
35    /// Optionally specify the listening ipv6 port.
36    #[clap(
37        short = 'p',
38        long = "listen-port-v6",
39        help = "Specifies the listening UDP port of the server if an ipv6 address is specified as a listening address."
40    )]
41    pub listen_port_v6: Option<u16>,
42    /// Specifies the IP address of the ENR record. Not specifying this results in an ENR with no IP field, unless the -w switch is used.
43    #[clap(
44        short = 'i',
45        long = "enr-addresses",
46        help = "Specifies the IP address(es) of the ENR record. Not specifying this results in an ENR with no IP field, unless the -w switch is used. These can be a comma separated addresses of ipv4,ipv6. Only the last two are used."
47    )]
48    pub enr_addresses: Option<String>,
49    /// Specifies the UDP port of the ENR record. Not specifying this results in an ENR with no UDP field, unless the -w switch is used.
50    #[clap(
51        short = 'u',
52        long = "enr-v4-port",
53        help = "Specifies the UDP port of the ENR record corresponding to ipv4 address. Not specifying this results in an ENR with no UDP field, unless the -w switch is used."
54    )]
55    pub enr_v4_port: Option<u16>,
56    /// The port associated with an ipv6 address.
57    #[clap(
58        short = 'u',
59        long = "enr-v6-port",
60        help = "Specifies the UDP port of the ENR record corresponding to ipv6 address. Not specifying this results in an ENR with no UDP field, unless the -w switch is used."
61    )]
62    pub enr_v6_port: Option<u16>,
63    /// Specifies the ENR sequence number when creating the ENR.
64    #[clap(
65        short = 'q',
66        long = "enr-seq-no",
67        help = "Specifies the ENR sequence number when creating the ENR."
68    )]
69    pub enr_seq_no: Option<String>,
70    /// Specifies the Eth2 field as ssz encoded hex bytes.
71    #[clap(
72        short = 'd',
73        long = "enr-eth2",
74        help = "Specifies the Eth2 field as ssz encoded hex bytes."
75    )]
76    pub enr_eth2: Option<String>,
77    /// The Enr IP address and port will be the same as the specified listening address and port.
78    #[clap(
79        short = 'w',
80        long = "enr-default",
81        help = "The Enr IP address and port will be the same as the specified listening address and port."
82    )]
83    pub enr_default: bool,
84    /// Use a fixed static key (hard-coded). This is primarily for debugging.
85    #[clap(
86        short = 'k',
87        long = "static-key",
88        help = "Use a fixed static key (hard-coded). This is primarily for debugging."
89    )]
90    pub static_key: bool,
91    /// Specify a secp256k1 private key (hex encoded) to use for the nodes identity.
92    #[clap(
93        short = 't',
94        long = "secp256k1-key",
95        help = "Specify a secp256k1 private key (hex encoded) to use for the nodes identity."
96    )]
97    pub secp256k1_key: Option<String>,
98    /// A base64 ENR that this node will initially connect to.
99    #[clap(
100        short = 'e',
101        long = "enr",
102        allow_hyphen_values = true,
103        help = "A base64 ENR that this node will initially connect to."
104    )]
105    pub enr: Option<String>,
106    /// The minimum number of peers required to update the IP address. Cannot be less than 2.
107    #[clap(
108        short = 'n',
109        long = "peer-update-min",
110        help = "The minimum number of peers required to update the IP address. Cannot be less than 2.",
111        default_value = "2"
112    )]
113    pub peer_update_min: u64,
114    /// The time to wait between successive searches. Default is 10 seconds.
115    #[clap(
116        short = 'b',
117        long = "break-time",
118        help = "The time to wait between successive searches. Default is 10 seconds.",
119        default_value = "10"
120    )]
121    pub break_time: u64,
122    /// Displays statistics on the local routing table.
123    #[clap(
124        short = 's',
125        long = "stats",
126        help = "Displays statistics on the local routing table.",
127        default_value = "10"
128    )]
129    pub stats: u64,
130    /// Prevents the server from doing any peer searches.
131    #[clap(
132        short = 'x',
133        long = "no-search",
134        help = "Prevents the server from doing any peer searches."
135    )]
136    pub no_search: bool,
137    /// Bootstraps the server peers
138    #[clap(
139        short = 'o',
140        long = "bootstrap",
141        help = "Bootstraps the server peers from a specified file."
142    )]
143    pub bootstrap: Option<String>,
144}