From 0c222e5258a90b8c474d95620afbf61a7a2ea70a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 21 Jun 2023 15:15:22 +0200 Subject: [PATCH] chore: update defaults in builder (#3299) Co-authored-by: 0xlosha Co-authored-by: rya <83345377+rya0x@users.noreply.github.com> --- bin/reth/src/args/rpc_server_args.rs | 10 +++++----- crates/rpc/rpc-builder/src/auth.rs | 2 +- crates/rpc/rpc-builder/src/lib.rs | 13 ++++++------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/bin/reth/src/args/rpc_server_args.rs b/bin/reth/src/args/rpc_server_args.rs index fa16ee3588..b7e7e2b8e9 100644 --- a/bin/reth/src/args/rpc_server_args.rs +++ b/bin/reth/src/args/rpc_server_args.rs @@ -353,7 +353,7 @@ impl RpcServerArgs { Tasks: TaskSpawner + Clone + 'static, { let socket_address = SocketAddr::new( - self.auth_addr.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)), + self.auth_addr.unwrap_or(IpAddr::V4(Ipv4Addr::LOCALHOST)), self.auth_port.unwrap_or(constants::DEFAULT_AUTH_PORT), ); @@ -424,7 +424,7 @@ impl RpcServerArgs { if self.http { let socket_address = SocketAddr::new( - self.http_addr.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)), + self.http_addr.unwrap_or(IpAddr::V4(Ipv4Addr::LOCALHOST)), self.http_port.unwrap_or(constants::DEFAULT_HTTP_RPC_PORT), ); config = config @@ -436,7 +436,7 @@ impl RpcServerArgs { if self.ws { let socket_address = SocketAddr::new( - self.ws_addr.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)), + self.ws_addr.unwrap_or(IpAddr::V4(Ipv4Addr::LOCALHOST)), self.ws_port.unwrap_or(constants::DEFAULT_WS_RPC_PORT), ); config = config.with_ws_address(socket_address).with_ws(self.http_ws_server_builder()); @@ -454,7 +454,7 @@ impl RpcServerArgs { /// Creates the [AuthServerConfig] from cli args. fn auth_server_config(&self, jwt_secret: JwtSecret) -> Result { let address = SocketAddr::new( - self.auth_addr.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)), + self.auth_addr.unwrap_or(IpAddr::V4(Ipv4Addr::LOCALHOST)), self.auth_port.unwrap_or(constants::DEFAULT_AUTH_PORT), ); @@ -556,7 +556,7 @@ mod tests { assert_eq!( config.http_address().unwrap(), SocketAddr::V4(SocketAddrV4::new( - Ipv4Addr::UNSPECIFIED, + Ipv4Addr::LOCALHOST, constants::DEFAULT_HTTP_RPC_PORT )) ); diff --git a/crates/rpc/rpc-builder/src/auth.rs b/crates/rpc/rpc-builder/src/auth.rs index 08a8ff6540..eb83578ee6 100644 --- a/crates/rpc/rpc-builder/src/auth.rs +++ b/crates/rpc/rpc-builder/src/auth.rs @@ -203,7 +203,7 @@ impl AuthServerConfigBuilder { pub fn build(self) -> AuthServerConfig { AuthServerConfig { socket_addr: self.socket_addr.unwrap_or_else(|| { - SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), constants::DEFAULT_AUTH_PORT) + SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), constants::DEFAULT_AUTH_PORT) }), secret: self.secret, server_config: self.server_config.unwrap_or_else(|| { diff --git a/crates/rpc/rpc-builder/src/lib.rs b/crates/rpc/rpc-builder/src/lib.rs index c82573e7a5..fb73bddf67 100644 --- a/crates/rpc/rpc-builder/src/lib.rs +++ b/crates/rpc/rpc-builder/src/lib.rs @@ -1030,7 +1030,7 @@ impl RpcServerConfig { /// Configures the [SocketAddr] of the http server /// - /// Default is [Ipv4Addr::UNSPECIFIED] and [DEFAULT_HTTP_RPC_PORT] + /// Default is [Ipv4Addr::LOCALHOST] and [DEFAULT_HTTP_RPC_PORT] pub fn with_http_address(mut self, addr: SocketAddr) -> Self { self.http_addr = Some(addr); self @@ -1038,7 +1038,7 @@ impl RpcServerConfig { /// Configures the [SocketAddr] of the ws server /// - /// Default is [Ipv4Addr::UNSPECIFIED] and [DEFAULT_WS_RPC_PORT] + /// Default is [Ipv4Addr::LOCALHOST] and [DEFAULT_WS_RPC_PORT] pub fn with_ws_address(mut self, addr: SocketAddr) -> Self { self.ws_addr = Some(addr); self @@ -1118,14 +1118,13 @@ impl RpcServerConfig { /// If both are on the same port, they are combined into one server. async fn build_ws_http(&mut self) -> Result { let http_socket_addr = self.http_addr.unwrap_or(SocketAddr::V4(SocketAddrV4::new( - Ipv4Addr::UNSPECIFIED, + Ipv4Addr::LOCALHOST, DEFAULT_HTTP_RPC_PORT, ))); - let ws_socket_addr = self.ws_addr.unwrap_or(SocketAddr::V4(SocketAddrV4::new( - Ipv4Addr::UNSPECIFIED, - DEFAULT_WS_RPC_PORT, - ))); + let ws_socket_addr = self + .ws_addr + .unwrap_or(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, DEFAULT_WS_RPC_PORT))); // If both are configured on the same port, we combine them into one server. if self.http_addr == self.ws_addr &&