Pass ##EXTERNAL_IP## to the client to replace

This commit is contained in:
Alex 2022-09-12 14:29:34 -04:00
parent 1be6b4318e
commit 455e87c168
Signed by: technically
GPG Key ID: 46E0A080F69E83F1

View File

@ -65,13 +65,13 @@ pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result<Respo
return match kv.get("base_pjsip").cache_ttl(300).text().await? {
Some(base) => {
let mut conf = base + "";
let remote_ip =
match _req.headers().get("CF-Connecting-IP").unwrap_or_default() {
Some(ip) => ip,
None => return Response::error("Could not find remote IP", 500),
};
// let remote_ip =
// match _req.headers().get("CF-Connecting-IP").unwrap_or_default() {
// Some(ip) => ip,
// None => return Response::error("Could not find remote IP", 500),
// };
conf = conf.replace("##EXTERNAL_IP##", &remote_ip) + "\n";
// conf = conf.replace("##EXTERNAL_IP##", &remote_ip) + "\n";
match kv.get("users").cache_ttl(300).text().await? {
Some(users) => {