Code Monkey home page Code Monkey logo

doh-cf-pages's People

Contributors

tina-hello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

doh-cf-pages's Issues

Fault notification

"After deploying your page and using the same path as youraddress.pages.dev/dns-query, I found that it is no longer accessible."

Would you release a new repo for echo user wan ip for use CF-pages?

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"
);
}

cant open any websites

thanks for this awesome project,
though, i couldn't get it to work
steps that i've done:

  1. forked this repo
  2. connected to couldflare pages and made a page there
  3. added a custom domain (this domain is new and tested , its not blocked)

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})
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.