Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tina-hello authored May 13, 2021
1 parent 6b1f9ef commit 8a86bff
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ addEventListener('fetch', function(event) {

async function handleRequest(request) {
const doh = 'https://security.cloudflare-dns.com/dns-query'
const contype = 'application/dns-message'
const { method, url } = request
const { host, searchParams } = new URL(url)
if (method == 'GET' && searchParams.has('dns')) {
return await fetch(doh + '?dns=' + searchParams.get('dns'), {
method: 'GET',
headers: {
'Accept': 'application/dns-message',
'Accept': contype,
}
});
} else if (method == 'POST') {
} else if (method == 'POST' && headers.get('Content-Type')=='application/dns-message') {
return await fetch(doh, {
method: 'POST',
headers: {
'Accept': 'application/dns-message',
'Content-Type': 'application/dns-message',
'Accept': contype,
'Content-Type': contype,
},
body: await request.arrayBuffer()
});
Expand Down

0 comments on commit 8a86bff

Please sign in to comment.