Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return async function playdoh (request, response, next) {
if (request.headers[HTTP2_HEADER_ACCEPT] !== dohMediaType) {
return next()
}
if (request.httpVersionMajor < dohMinimumHttpVersionMajor) {
return next(new HTTPVersionNotSupported())
}
const dnsMessage = []
switch (request.method) {
case HTTP2_METHOD_GET:
const { url } = request
const dns = new URLSearchParams(url.substr(url.indexOf('?'))).get('dns')
if (!dns) {
return next(new BadRequest())
}
let decoded
try {
decoded = toBuffer(dns)
} catch (error) {
return next(new BadRequest())
}
httpVersionNotSupported: function httpVersionNotSupported (message) {
return new createError.HTTPVersionNotSupported(message)
},