From 0a5f6f2ca7c1b042a6357e5f17c48097ed91e989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Wed, 23 Jun 2021 15:25:23 +0100 Subject: [PATCH] Added verloc and http port fields to config --- mixnode/src/config/mod.rs | 41 ++++++++++++++++++++++++++++++++++ mixnode/src/config/template.rs | 8 +++++++ 2 files changed, 49 insertions(+) diff --git a/mixnode/src/config/mod.rs b/mixnode/src/config/mod.rs index d3240c975c..19447dbdca 100644 --- a/mixnode/src/config/mod.rs +++ b/mixnode/src/config/mod.rs @@ -16,6 +16,9 @@ pub(crate) const MISSING_VALUE: &str = "MISSING VALUE"; // 'MIXNODE' const DEFAULT_MIX_LISTENING_PORT: u16 = 1789; +const DEFAULT_VERLOC_LISTENING_PORT: u16 = 1790; +const DEFAULT_HTTP_API_LISTENING_PORT: u16 = 8000; + pub(crate) const DEFAULT_VALIDATOR_REST_ENDPOINTS: &[&str] = &[ "http://testnet-finney-validator.nymtech.net:1317", "http://testnet-finney-validator2.nymtech.net:1317", @@ -64,6 +67,14 @@ fn default_mix_port() -> u16 { DEFAULT_MIX_LISTENING_PORT } +fn default_verloc_port() -> u16 { + DEFAULT_VERLOC_LISTENING_PORT +} + +fn default_http_api_port() -> u16 { + DEFAULT_HTTP_API_LISTENING_PORT +} + // basically a migration helper that deserialises string representation of a maybe socket addr (like "1.1.1.1:1234") // into just the ipaddr (like "1.1.1.1") pub(super) fn de_ipaddr_from_maybe_str_socks_addr<'de, D>( @@ -197,6 +208,16 @@ impl Config { self } + pub fn with_verloc_port(mut self, port: u16) -> Self { + self.mixnode.verloc_port = port; + self + } + + pub fn with_http_api_port(mut self, port: u16) -> Self { + self.mixnode.http_api_port = port; + self + } + pub fn announce_address_from_listening_address(mut self) -> Self { self.mixnode.announce_address = self.mixnode.listening_address.to_string(); self @@ -260,6 +281,14 @@ impl Config { self.mixnode.mix_port } + pub fn get_verloc_port(&self) -> u16 { + self.mixnode.verloc_port + } + + pub fn get_http_api_port(&self) -> u16 { + self.mixnode.http_api_port + } + pub fn get_packet_forwarding_initial_backoff(&self) -> Duration { self.debug.packet_forwarding_initial_backoff } @@ -343,6 +372,16 @@ pub struct MixNode { #[serde(default = "default_mix_port")] mix_port: u16, + /// Port used for listening for verloc traffic. + /// (default: 1790) + #[serde(default = "default_verloc_port")] + verloc_port: u16, + + /// Port used for listening for http requests. + /// (default: 8000) + #[serde(default = "default_http_api_port")] + http_api_port: u16, + /// Path to file containing private identity key. #[serde(default = "missing_string_value")] private_identity_key_file: PathBuf, @@ -401,6 +440,8 @@ impl Default for MixNode { listening_address: bind_all_address(), announce_address: "127.0.0.1".to_string(), mix_port: DEFAULT_MIX_LISTENING_PORT, + verloc_port: DEFAULT_VERLOC_LISTENING_PORT, + http_api_port: DEFAULT_HTTP_API_LISTENING_PORT, private_identity_key_file: Default::default(), public_identity_key_file: Default::default(), private_sphinx_key_file: Default::default(), diff --git a/mixnode/src/config/template.rs b/mixnode/src/config/template.rs index dfaae35eae..404dacb409 100644 --- a/mixnode/src/config/template.rs +++ b/mixnode/src/config/template.rs @@ -48,6 +48,14 @@ announce_address = '{{ mixnode.announce_address }}' # (default: 1789) mix_port = {{ mixnode.mix_port }} +# Port used for listening for verloc traffic. +# (default: 1790) +verloc_port = {{ mixnode.verloc_port }} + +# Port used for listening for http requests. +# (default: 8000) +http_api_port = {{ mixnode.http_api_port }} + # Validator server to which the node will be getting information about the network. validator_rest_urls = [ {{#each mixnode.validator_rest_urls }}