validate LITE_RPC_HTTP_ADDR in config (#331)

validate config value for LITE_RPC_HTTP_ADDR and LITE_RPC_WS_ADDR
This commit is contained in:
Lou-Kamades 2024-02-21 05:17:14 -08:00 committed by GitHub
parent 2c42a536b6
commit 0678bc4f50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -1,5 +1,5 @@
## LiteRpc
LITE_RPC_HTTP_ADDR=http://0.0.0.0:8890
LITE_RPC_HTTP_ADDR=[::]:8890
LITE_RPC_WS_ADDR=[::]:8891
## RPC

View File

@ -1,6 +1,8 @@
use std::borrow::Cow;
use std::env;
use std::fmt::{Debug, Display, Formatter};
use std::net::SocketAddr;
use std::str::FromStr;
use crate::postgres_logger;
use crate::{
@ -126,6 +128,9 @@ impl Config {
config.lite_rpc_ws_addr = env::var("LITE_RPC_WS_ADDR").unwrap_or(config.lite_rpc_ws_addr);
SocketAddr::from_str(&config.lite_rpc_http_addr).expect("invalid LITE_RPC_HTTP_ADDR");
SocketAddr::from_str(&config.lite_rpc_ws_addr).expect("invalid LITE_RPC_WS_ADDR");
config.fanout_size = env::var("FANOUT_SIZE")
.map(|size| size.parse().unwrap())
.unwrap_or(config.fanout_size);