mirror of
https://github.com/LittleChest/Dohna-NS.git
synced 2026-05-06 22:44:50 +08:00
worker: Fix IP header
This commit is contained in:
parent
f0e016f13b
commit
2795686625
@ -1,5 +1,6 @@
|
||||
import handler from "./common";
|
||||
|
||||
export default {
|
||||
fetch: async (request, env) => handler(request, env.DNS, env.API),
|
||||
fetch: async (request, env) =>
|
||||
handler(request, env.DNS, env.API, request.headers.get("cf-connecting-ip")),
|
||||
};
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
export default async function handler(
|
||||
request,
|
||||
dns = "https://dns.google/dns-query",
|
||||
api = "https://dns.google/resolve"
|
||||
api = "https://dns.google/resolve",
|
||||
rawIP
|
||||
) {
|
||||
const { method, headers, url } = request;
|
||||
const { search, searchParams, pathname } = new URL(url);
|
||||
const ip = headers.get("x-forwarded-for");
|
||||
|
||||
const ip =
|
||||
rawIP ||
|
||||
headers.get("x-forwarded-for").split(",")[0].trim() ||
|
||||
headers.get("x-real-ip");
|
||||
|
||||
// Anti-GFW
|
||||
if (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user