Introduced cli arguments for verloc and http ports

This commit is contained in:
Jędrzej Stuczyński
2021-06-23 15:33:57 +01:00
parent 0a5f6f2ca7
commit 35cddab3bd
3 changed files with 50 additions and 2 deletions
+13 -1
View File
@@ -37,7 +37,19 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
.arg(
Arg::with_name(MIX_PORT_ARG_NAME)
.long(MIX_PORT_ARG_NAME)
.help("The port on which the mixnode will be listening")
.help("The port on which the mixnode will be listening for mix packets")
.takes_value(true),
)
.arg(
Arg::with_name(VERLOC_PORT_ARG_NAME)
.long(VERLOC_PORT_ARG_NAME)
.help("The port on which the mixnode will be listening for verloc packets")
.takes_value(true),
)
.arg(
Arg::with_name(HTTP_API_PORT_ARG_NAME)
.long(HTTP_API_PORT_ARG_NAME)
.help("The port on which the mixnode will be listening for http requests")
.takes_value(true),
)
.arg(
+24
View File
@@ -15,6 +15,8 @@ pub(crate) const ID_ARG_NAME: &str = "id";
pub(crate) const HOST_ARG_NAME: &str = "host";
pub(crate) const LAYER_ARG_NAME: &str = "layer";
pub(crate) const MIX_PORT_ARG_NAME: &str = "mix-port";
pub(crate) const VERLOC_PORT_ARG_NAME: &str = "verloc-port";
pub(crate) const HTTP_API_PORT_ARG_NAME: &str = "http-api-port";
pub(crate) const VALIDATORS_ARG_NAME: &str = "validators";
pub(crate) const CONTRACT_ARG_NAME: &str = "mixnet-contract";
pub(crate) const ANNOUNCE_HOST_ARG_NAME: &str = "announce-host";
@@ -58,6 +60,28 @@ pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Confi
config = config.with_mix_port(port.unwrap());
}
if let Some(port) = matches
.value_of(VERLOC_PORT_ARG_NAME)
.map(|port| port.parse::<u16>())
{
if let Err(err) = port {
// if port was overridden, it must be parsable
panic!("Invalid verloc port value provided - {:?}", err);
}
config = config.with_verloc_port(port.unwrap());
}
if let Some(port) = matches
.value_of(HTTP_API_PORT_ARG_NAME)
.map(|port| port.parse::<u16>())
{
if let Err(err) = port {
// if port was overridden, it must be parsable
panic!("Invalid http api port value provided - {:?}", err);
}
config = config.with_http_api_port(port.unwrap());
}
if let Some(raw_validators) = matches.value_of(VALIDATORS_ARG_NAME) {
config = config.with_custom_validators(parse_validators(raw_validators));
}
+13 -1
View File
@@ -37,7 +37,19 @@ pub fn command_args<'a, 'b>() -> App<'a, 'b> {
.arg(
Arg::with_name(MIX_PORT_ARG_NAME)
.long(MIX_PORT_ARG_NAME)
.help("The port on which the mixnode will be listening")
.help("The port on which the mixnode will be listening for mix packets")
.takes_value(true),
)
.arg(
Arg::with_name(VERLOC_PORT_ARG_NAME)
.long(VERLOC_PORT_ARG_NAME)
.help("The port on which the mixnode will be listening for verloc packets")
.takes_value(true),
)
.arg(
Arg::with_name(HTTP_API_PORT_ARG_NAME)
.long(HTTP_API_PORT_ARG_NAME)
.help("The port on which the mixnode will be listening for http requests")
.takes_value(true),
)
.arg(