feat: add hyper proxy for handshake dns

This commit is contained in:
Derrick Hammer 2023-08-02 17:08:31 -04:00
parent 0cb070f47e
commit a47d83942c
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 14 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import { MultiSocketProxy } from "@lumeweb/libhyperproxy";
let api: PluginAPI; let api: PluginAPI;
const PROTOCOL = "lumeweb.proxy.handshake"; const PROTOCOL = "lumeweb.proxy.handshake";
const DNS_PROTOCOL = "lumeweb.proxy.handshake.dns";
const plugin: Plugin = { const plugin: Plugin = {
name: "handshake", name: "handshake",
@ -26,6 +27,19 @@ const plugin: Plugin = {
muxer, muxer,
}); });
}); });
const dnsProxy = new MultiSocketProxy({
swarm: api.swarm,
protocol: DNS_PROTOCOL,
allowedPorts: [53],
server: true,
});
api.protocols.register(DNS_PROTOCOL, (peer: any, muxer: any) => {
dnsProxy.handlePeer({
peer,
muxer,
});
});
}, },
}; };