0.1.0 • Published 11 months ago

@dnspect/doh-worker v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

DNS over HTTPS Worker

npm   Lint  

A TypeScript library for building DNS over HTTPS reverse proxies that make DNS servers speak DoH, using Cloudflare Workers.

Install

Add this package to your package.json by running this in the root of your project's directory:

npm install @dnspect/doh-worker

Usage

This package is designed to be used with Cloudflare Workers.

Build a DoH proxy:

import { handle } from '@dnspect/doh-workers';

export interface Env {}

export default {
  async fetch(req: Request, _env: Env, ctx: ExecutionContext): Promise<Response> {
    const url = new URL(req.url);
    if (url.pathname === '/favicon.ico') {
      return new Response(null, { status: 404 });
    }

    return handle(ctx, req, { hostname: '1.1.1.1', port: 53 });
  },
};