mirror of
https://github.com/stakwork/sphinx-key.git
synced 2025-12-18 15:54:31 +01:00
broker configurable ws port
This commit is contained in:
@@ -28,8 +28,8 @@ pub fn start_broker(
|
|||||||
|
|
||||||
let (mut link_tx, mut link_rx) = broker.link("localclient")?;
|
let (mut link_tx, mut link_rx) = broker.link("localclient")?;
|
||||||
|
|
||||||
link_tx.subscribe(format!("+/{}", topics::HELLO));
|
let _ = link_tx.subscribe(format!("+/{}", topics::HELLO));
|
||||||
link_tx.subscribe(format!("+/{}", topics::BYE));
|
let _ = link_tx.subscribe(format!("+/{}", topics::BYE));
|
||||||
|
|
||||||
let auth_sender_ = auth_sender.clone();
|
let auth_sender_ = auth_sender.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ pub fn read_broker_config() -> Settings {
|
|||||||
if let Some(http_port) = read_http_port_setting(&table) {
|
if let Some(http_port) = read_http_port_setting(&table) {
|
||||||
settings.http_port = http_port;
|
settings.http_port = http_port;
|
||||||
}
|
}
|
||||||
|
if let Some(ws_port) = read_ws_port_setting(&table) {
|
||||||
|
settings.websocket_port = Some(ws_port);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log::info!("File broker.conf not found, using default settings");
|
log::info!("File broker.conf not found, using default settings");
|
||||||
}
|
}
|
||||||
@@ -63,6 +66,13 @@ pub fn read_broker_config() -> Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Ok(env_port) = env::var("BROKER_WS_PORT") {
|
||||||
|
if let Ok(ws_port) = env_port.parse::<u16>() {
|
||||||
|
if ws_port > 1023 {
|
||||||
|
settings.websocket_port = Some(ws_port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
settings
|
settings
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,3 +167,23 @@ fn read_http_port_setting(table: &Value) -> Option<u16> {
|
|||||||
Some(temp.try_into().unwrap())
|
Some(temp.try_into().unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn read_ws_port_setting(table: &Value) -> Option<u16> {
|
||||||
|
if let None = table.get("ws_port") {
|
||||||
|
log::info!("Broker ws port not specified, setting to default 8083");
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
let temp = table["ws_port"]
|
||||||
|
.as_integer()
|
||||||
|
.expect("The ws port number is not an integer greater than 1023");
|
||||||
|
if temp <= 1023 {
|
||||||
|
panic!("The ws port number is not an integer greater than 1023")
|
||||||
|
}
|
||||||
|
let max: i64 = u16::MAX.into();
|
||||||
|
if temp > max {
|
||||||
|
panic!("The ws port number is way too big!")
|
||||||
|
}
|
||||||
|
log::info!("Read broker ws port setting: {}", temp);
|
||||||
|
Some(temp.try_into().unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user