Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy protocol support #81

Open
stefanwerfling opened this issue Sep 21, 2023 · 1 comment
Open

Proxy protocol support #81

stefanwerfling opened this issue Sep 21, 2023 · 1 comment

Comments

@stefanwerfling
Copy link

Hey @song940 first, great project!

Can you perhaps give all sockets the proxy protocol header? I would like to give the real client IP from the proxy. That the DNS server gets the correct IP from the client.

https://github.com/moznion/proxy-protocol-js

I imagined it in such a way that you can specify in the config whether you use it or not.

It should be enough to read the sockets and parse the header first before parsing the packets:

const proto = proxyProtocol.V1ProxyProtocol.parse(dnspacket);
console.log(proto);
// => V1ProxyProtocol {
//      inetProtocol: 'TCP4',
//      source: Host { ipAddress: '127.0.0.1', port: 12345 },
//      destination: Host { ipAddress: '192.0.2.1', port: 54321 },
//      data: '' }
const dnsrequest = proto.data
@stefanwerfling
Copy link
Author

Hello @lsongdev, it would really be a dream if you added an option to split the packet. I have an Nginx connected via stream in front of the DNS, which protects the DNS with IP checks, etc.

The Nginx passes the packet on as a proxy protocol so that the HTTP/HTTPS server gets the client's original IP, for example. I've already checked the DNS server here and the internal IP always arrives as the client.

It would be quite easy if I got the packet via callback

function(packet) {

const parse = parse(packet);

return {
    clientIp: parse.ip,
    rawPacket: parse.rawPacket
 };
}

If that is not possible, I will probably start my own project. Since my code is completely based on Typescript, I do not want to change anything in the node-dns code, since you know your code better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant