Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 15 additions & 27 deletions bin/reth/src/args/rpc_server_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ pub(crate) const RPC_DEFAULT_MAX_CONNECTIONS: u32 = 100;
pub(crate) const RPC_DEFAULT_MAX_TRACING_REQUESTS: u32 = 25;

/// Parameters for configuring the rpc more granularity via CLI
#[derive(Debug, Args, PartialEq, Eq, Default)]
#[derive(Debug, Args, PartialEq, Eq)]
#[command(next_help_heading = "RPC")]
pub struct RpcServerArgs {
/// Enable the HTTP-RPC server
#[arg(long, default_value_if("dev", "true", "true"))]
pub http: bool,

/// Http server address to listen on
#[arg(long = "http.addr")]
pub http_addr: Option<IpAddr>,
#[arg(long = "http.addr", default_value_t = IpAddr::V4(Ipv4Addr::LOCALHOST))]
pub http_addr: IpAddr,

/// Http server port to listen on
#[arg(long = "http.port")]
pub http_port: Option<u16>,
#[arg(long = "http.port", default_value_t = constants::DEFAULT_HTTP_RPC_PORT)]
pub http_port: u16,

/// Rpc Modules to be configured for the HTTP server
#[arg(long = "http.api", value_parser = RpcModuleSelectionValueParser::default())]
Expand All @@ -80,12 +80,12 @@ pub struct RpcServerArgs {
pub ws: bool,

/// Ws server address to listen on
#[arg(long = "ws.addr")]
pub ws_addr: Option<IpAddr>,
#[arg(long = "ws.addr", default_value_t = IpAddr::V4(Ipv4Addr::LOCALHOST))]
pub ws_addr: IpAddr,

/// Ws server port to listen on
#[arg(long = "ws.port")]
pub ws_port: Option<u16>,
#[arg(long = "ws.port", default_value_t = constants::DEFAULT_WS_RPC_PORT)]
pub ws_port: u16,

/// Origins from which to accept WebSocket requests
#[arg(long = "ws.origins", name = "ws.origins")]
Expand All @@ -104,8 +104,8 @@ pub struct RpcServerArgs {
pub ipcpath: Option<String>,

/// Auth server address to listen on
#[arg(long = "authrpc.addr")]
pub auth_addr: Option<IpAddr>,
#[arg(long = "authrpc.addr", default_value_t = IpAddr::V4(Ipv4Addr::LOCALHOST))]
pub auth_addr: IpAddr,

/// Auth server port to listen on
#[arg(long = "authrpc.port", default_value_t = constants::DEFAULT_AUTH_PORT)]
Expand Down Expand Up @@ -356,10 +356,7 @@ impl RpcServerArgs {
Network: NetworkInfo + Peers + Clone + 'static,
Tasks: TaskSpawner + Clone + 'static,
{
let socket_address = SocketAddr::new(
self.auth_addr.unwrap_or(IpAddr::V4(Ipv4Addr::LOCALHOST)),
self.auth_port,
);
let socket_address = SocketAddr::new(self.auth_addr, self.auth_port);

reth_rpc_builder::auth::launch(
provider,
Expand Down Expand Up @@ -427,10 +424,7 @@ impl RpcServerArgs {
let mut config = RpcServerConfig::default();

if self.http {
let socket_address = SocketAddr::new(
self.http_addr.unwrap_or(IpAddr::V4(Ipv4Addr::LOCALHOST)),
self.http_port.unwrap_or(constants::DEFAULT_HTTP_RPC_PORT),
);
let socket_address = SocketAddr::new(self.http_addr, self.http_port);
config = config
.with_http_address(socket_address)
.with_http(self.http_ws_server_builder())
Expand All @@ -439,10 +433,7 @@ impl RpcServerArgs {
}

if self.ws {
let socket_address = SocketAddr::new(
self.ws_addr.unwrap_or(IpAddr::V4(Ipv4Addr::LOCALHOST)),
self.ws_port.unwrap_or(constants::DEFAULT_WS_RPC_PORT),
);
let socket_address = SocketAddr::new(self.ws_addr, self.ws_port);
config = config.with_ws_address(socket_address).with_ws(self.http_ws_server_builder());
}

Expand All @@ -457,10 +448,7 @@ impl RpcServerArgs {

/// Creates the [AuthServerConfig] from cli args.
fn auth_server_config(&self, jwt_secret: JwtSecret) -> Result<AuthServerConfig, RpcError> {
let address = SocketAddr::new(
self.auth_addr.unwrap_or(IpAddr::V4(Ipv4Addr::LOCALHOST)),
self.auth_port,
);
let address = SocketAddr::new(self.auth_addr, self.auth_port);

Ok(AuthServerConfig::builder(jwt_secret).socket_addr(address).build())
}
Expand Down