add more config files
This commit is contained in:
parent
0ceef499bb
commit
1be6b4318e
56
src/lib.rs
56
src/lib.rs
@ -136,6 +136,62 @@ pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result<Respo
|
||||
}
|
||||
Response::error("Bad Request", 400)
|
||||
})
|
||||
.get_async("/logger/:hostname/:token", |_req, ctx| async move {
|
||||
if let Some(token) = ctx.param("token") {
|
||||
if !check_endpoint_auth(token, ctx.kv("GONK_NODES")?).await {
|
||||
return Response::error("Unauthorized", 401);
|
||||
}
|
||||
}
|
||||
if let Some(hostname) = ctx.param("hostname") {
|
||||
let kv = ctx.kv("GONK_NODES")?;
|
||||
|
||||
return match kv.get("base_logger").cache_ttl(300).text().await? {
|
||||
Some(base) => Response::ok(&base),
|
||||
None => {
|
||||
Response::error(format!("Could not find logger.conf for {}", hostname), 404)
|
||||
}
|
||||
};
|
||||
}
|
||||
Response::error("Bad Request", 400)
|
||||
})
|
||||
.get_async("/f2b/asterisk/:hostname/:token", |_req, ctx| async move {
|
||||
if let Some(token) = ctx.param("token") {
|
||||
if !check_endpoint_auth(token, ctx.kv("GONK_NODES")?).await {
|
||||
return Response::error("Unauthorized", 401);
|
||||
}
|
||||
}
|
||||
if let Some(hostname) = ctx.param("hostname") {
|
||||
let kv = ctx.kv("GONK_NODES")?;
|
||||
|
||||
return match kv.get("base_f2b_asterisk").cache_ttl(300).text().await? {
|
||||
Some(base) => Response::ok(&base),
|
||||
None => Response::error(
|
||||
format!("Could not find fail2ban asterisk.conf for {}", hostname),
|
||||
404,
|
||||
),
|
||||
};
|
||||
}
|
||||
Response::error("Bad Request", 400)
|
||||
})
|
||||
.get_async("/f2b/voipbl/:hostname/:token", |_req, ctx| async move {
|
||||
if let Some(token) = ctx.param("token") {
|
||||
if !check_endpoint_auth(token, ctx.kv("GONK_NODES")?).await {
|
||||
return Response::error("Unauthorized", 401);
|
||||
}
|
||||
}
|
||||
if let Some(hostname) = ctx.param("hostname") {
|
||||
let kv = ctx.kv("GONK_NODES")?;
|
||||
|
||||
return match kv.get("base_f2b_voipbl").cache_ttl(300).text().await? {
|
||||
Some(base) => Response::ok(&base),
|
||||
None => Response::error(
|
||||
format!("Could not find fail2ban voipbl.conf for {}", hostname),
|
||||
404,
|
||||
),
|
||||
};
|
||||
}
|
||||
Response::error("Bad Request", 400)
|
||||
})
|
||||
.run(req, env)
|
||||
.await
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user