Dohna-NS/handler/entrypoint.js
2026-06-14 13:06:13 +08:00

37 lines
723 B
JavaScript

import dnsHandler from "./dns";
import mobileconfigHandler from "./mobileconfig";
export default async function handler(
request,
dns,
api,
ipv4Prefix = 32,
ipv6Prefix = 128,
concurrent = false,
rawIP,
enableMobileConfig = false,
) {
const { pathname } = new URL(request.url);
let res = new Response(null, { status: 404 });
// DNS over HTTPS & JSON API
if (pathname === "/dns-query" || pathname === "/resolve") {
res = dnsHandler(
request,
dns,
api,
ipv4Prefix,
ipv6Prefix,
concurrent,
rawIP,
);
}
// Apple Mobile Config
if (enableMobileConfig && pathname === "/mobileconfig") {
res = mobileconfigHandler(request);
}
return res;
}