added timeout
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2023-04-23 10:14:16 +02:00
parent cdc3ac4064
commit dc3405d07a
2 changed files with 5 additions and 2 deletions

View File

@ -73,6 +73,7 @@ impl Context {
GIT_VERSION, GIT_VERSION,
gethostname(false) gethostname(false)
)) ))
.timeout(Duration::seconds(15).to_std().unwrap())
.build() .build()
.unwrap(), .unwrap(),
sas: HashMap::new(), sas: HashMap::new(),

View File

@ -5,8 +5,10 @@ use crate::utils::sleep_s;
use reqwest::Client; use reqwest::Client;
use reqwest::Error as ReqError; use reqwest::Error as ReqError;
const MAX_FAILED_API_RATE: u64 = 10;
pub async fn send_to_ipbl_api(client: &Client, server: &str, ip: &IpEvent) { pub async fn send_to_ipbl_api(client: &Client, server: &str, ip: &IpEvent) {
let mut i = 1; let mut i = 0;
loop { loop {
match push_ip(&client, &server, &ip.ipdata).await { match push_ip(&client, &server, &ip.ipdata).await {
Ok(_) => { Ok(_) => {
@ -15,7 +17,7 @@ pub async fn send_to_ipbl_api(client: &Client, server: &str, ip: &IpEvent) {
Err(err) => { Err(err) => {
println!("{err}"); println!("{err}");
sleep_s(1).await; sleep_s(1).await;
if i == 10 { if i == MAX_FAILED_API_RATE {
break; break;
} }
i += 1; i += 1;