tina-hello / doh-cf-pages Goto Github PK
View Code? Open in Web Editor NEWDNS-over-HTTPS proxy on Cloudflare Pages
License: BSD Zero Clause License
DNS-over-HTTPS proxy on Cloudflare Pages
License: BSD Zero Clause License
"After deploying your page and using the same path as youraddress.pages.dev/dns-query, I found that it is no longer accessible."
For example: curl https://your-ip.pages.dev
It will echo user wan ip like:
172.172.172.172
This echo is very helpful for DDNS update.
const clientIP = request.headers.get("CF-Connecting-IP")
return new Response(clientIP);
If other new CF-pages repo for echo user ip geo data will be great,
For example: curl https://your-ip-geo.pages.dev
It will echo user wan ip geo data like:
Public IP: 172.172.172.172
ASN: 396982
ISP: Google Cloud
Country: US
City: The Dalles
Region: Oregon
Latitude, Longitude: 45.59990,-121.18710
Postal Code: 97058
Timezone: America/Los_Angeles
User Agent: curl/7.81.0
{
const clientUA = request.headers.get('User-Agent');
const clientIP = request.headers.get('CF-Connecting-IP');
const clientASN = request.cf.asn;
const clientISP = request.cf.asOrganization;
const clientCO = request.cf.country;
const clientCI = request.cf.city;
const clientRE = request.cf.region;
const clientLAT = request.cf.latitude;
const clientLON = request.cf.longitude;
const clientPC = request.cf.postalCode;
const clientTZ = request.cf.timezone;
return new Response("Public IP: " + clientIP + "\n" +
"ASN: " + clientASN + "\n" +
"ISP: " + clientISP + "\n" +
"Country: " + clientCO + "\n" +
"City: " + clientCI + "\n" +
"Region: " + clientRE + "\n" +
"Latitude, Longitude: " + clientLAT + "," + clientLON + "\n" +
"Postal Code: " + clientPC + "\n" +
"Timezone: " + clientTZ + "\n" +
"User Agent: " + clientUA + "\n"
);
}
thanks for this awesome project,
though, i couldn't get it to work
steps that i've done:
but when i put https://mycustomdomain.com/dns-query
as DoH on for example Hiddify VPN app or Sing-box ; i cant open any websites with them,
i've also change the index.js
like this and tested few DoH resolvers like Adguard and ControlD but i could get it to work:
const doh = 'https://cloudflare-dns.com/dns-query'
const dohjson = 'https://cloudflare-dns.com/dns-query'
const contype = 'application/dns-message'
const jstontype = 'application/dns-json'
export const onRequestGet = async ({request}) => {
const { method, headers, url } = request
const searchParams = new URL(url).searchParams
if (searchParams.has('dns')) {
return await fetch(doh + '?dns=' + searchParams.get('dns'), {
method: 'GET',
headers: {
'Accept': contype,
}
});
} else if (method== 'GET' && headers.get('Accept')==jstontype) {
const search = new URL(url).search
return await fetch(dohjson + search, {
method: 'GET',
headers: {
'Accept': jstontype,
}
});
} else {
return new Response("", {status: 404})
}
}
export const onRequestPost = async ({ request }) => {
const { headers } = request
if (headers.get('content-type')==contype) {
return fetch(doh, {
method: 'POST',
headers: {
'Accept': contype,
'Content-Type': contype,
},
body: request.body,
});
} else {
return new Response("", {status: 404})
}
}
For example : https://yourdoh.pages.dev/self-define-doh-path
Because this code just fix to no path and just use https://yourdoh.pages.dev
The no path URL for firefox and chrome is fine but windows 11 can't use no path URL in DoH
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.