update errors and variable names
This commit is contained in:
parent
bdf41fa605
commit
3c4d6fb2cf
@ -103,12 +103,12 @@ impl Context {
|
|||||||
.send()
|
.send()
|
||||||
.await;
|
.await;
|
||||||
let req = match resp {
|
let req = match resp {
|
||||||
Ok(re) => re,
|
Ok(o) => o,
|
||||||
Err(err) => return Err(err),
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
let data: Discovery = match req.json().await {
|
let data: Discovery = match req.json().await {
|
||||||
Ok(res) => res,
|
Ok(o) => o,
|
||||||
Err(err) => return Err(err),
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
Ok(data)
|
Ok(data)
|
||||||
}
|
}
|
||||||
@ -127,8 +127,8 @@ impl Context {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(e) => {
|
||||||
println!("error loading config: {err}, retrying in {CONFIG_RETRY_INTERVAL}s");
|
println!("error loading config: {e}, retrying in {CONFIG_RETRY_INTERVAL}s");
|
||||||
last_in_err = true;
|
last_in_err = true;
|
||||||
sleep_s(CONFIG_RETRY_INTERVAL).await;
|
sleep_s(CONFIG_RETRY_INTERVAL).await;
|
||||||
}
|
}
|
||||||
@ -365,12 +365,12 @@ impl Config {
|
|||||||
.send()
|
.send()
|
||||||
.await;
|
.await;
|
||||||
let req = match resp {
|
let req = match resp {
|
||||||
Ok(re) => re,
|
Ok(o) => o,
|
||||||
Err(err) => return Err(err),
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
let data: GlobalConfigV2 = match req.json::<GlobalConfigV2>().await {
|
let data: GlobalConfigV2 = match req.json::<GlobalConfigV2>().await {
|
||||||
Ok(res) => res,
|
Ok(o) => o,
|
||||||
Err(err) => return Err(err),
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
|
|
||||||
for d in data.sets {
|
for d in data.sets {
|
||||||
@ -400,13 +400,13 @@ impl Config {
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
let req = match resp {
|
let req = match resp {
|
||||||
Ok(re) => re,
|
Ok(o) => o,
|
||||||
Err(err) => return Err(err),
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
|
|
||||||
let data: Vec<IpData> = match req.json::<Vec<IpData>>().await {
|
let data: Vec<IpData> = match req.json::<Vec<IpData>>().await {
|
||||||
Ok(res) => res,
|
Ok(o) => o,
|
||||||
Err(err) => return Err(err),
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(data)
|
Ok(data)
|
||||||
@ -417,8 +417,8 @@ impl Config {
|
|||||||
for trustnet in &self.trustnets {
|
for trustnet in &self.trustnets {
|
||||||
match trustnet.parse() {
|
match trustnet.parse() {
|
||||||
Ok(net) => trustnets.push(net),
|
Ok(net) => trustnets.push(net),
|
||||||
Err(err) => {
|
Err(e) => {
|
||||||
println!("error parsing {trustnet}, error: {err}");
|
println!("error parsing {trustnet}, error: {e}");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -189,8 +189,8 @@ async fn handle_fwblock(ctxclone: Arc<RwLock<Context>>, ret: &mut Vec<String>, f
|
|||||||
// apply firewall blocking
|
// apply firewall blocking
|
||||||
match fwblock(&toblock, ret, fwlen) {
|
match fwblock(&toblock, ret, fwlen) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(err) => {
|
Err(e) => {
|
||||||
println!("Err: {err}, unable to push firewall rules, use super user")
|
println!("err: {e}, unable to push firewall rules, use super user")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ pub async fn apiserver(ctxarc: &Arc<RwLock<Context>>) -> io::Result<()> {
|
|||||||
let ctxarc = ctxarc.clone();
|
let ctxarc = ctxarc.clone();
|
||||||
let addr: String = { ctxarc.read().await.cfg.api.parse().unwrap() };
|
let addr: String = { ctxarc.read().await.cfg.api.parse().unwrap() };
|
||||||
let listener = match TcpListener::bind(addr).await {
|
let listener = match TcpListener::bind(addr).await {
|
||||||
Ok(l) => l,
|
Ok(o) => o,
|
||||||
Err(err) => {
|
Err(e) => {
|
||||||
println!("Error: {err}");
|
println!("error: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -29,13 +29,13 @@ pub async fn apiserver(ctxarc: &Arc<RwLock<Context>>) -> io::Result<()> {
|
|||||||
match socket.try_read(&mut buf) {
|
match socket.try_read(&mut buf) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("{e}");
|
println!("error: {e}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("{e}");
|
println!("error: {e}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,8 +49,8 @@ pub async fn apiserver(ctxarc: &Arc<RwLock<Context>>) -> io::Result<()> {
|
|||||||
|
|
||||||
match socket.write_all(res.as_bytes()).await {
|
match socket.write_all(res.as_bytes()).await {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(err) => {
|
Err(e) => {
|
||||||
println!("ee {err}");
|
println!("error: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ use tokio::time::{sleep, Duration};
|
|||||||
|
|
||||||
pub fn read_lines(filename: &String, offset: u64) -> Option<Box<dyn Read>> {
|
pub fn read_lines(filename: &String, offset: u64) -> Option<Box<dyn Read>> {
|
||||||
let mut file = match File::open(filename) {
|
let mut file = match File::open(filename) {
|
||||||
Ok(f) => f,
|
Ok(o) => o,
|
||||||
Err(err) => {
|
Err(e) => {
|
||||||
println!("{err}");
|
println!("error: {e}");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -15,8 +15,8 @@ pub async fn send_to_ipbl_api(server: &str, ip: &IpEvent) {
|
|||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(e) => {
|
||||||
println!("{err}");
|
println!("error: {e}");
|
||||||
sleep_s(1).await;
|
sleep_s(1).await;
|
||||||
if try_req == MAX_FAILED_API_RATE {
|
if try_req == MAX_FAILED_API_RATE {
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user