daguej / node-proxywrap

Wrap node's Server interfaces to be compatible with the PROXY protocol
48 stars 36 forks source link

UDP support? #12

Closed dsshap closed 8 years ago

dsshap commented 8 years ago

Any plans to add UDP support?

Or can you recommend comparable lib for UDP?

Much appreciated!

daguej commented 8 years ago

Hadn't considered it. I don't really have a need for UDP support and it's unlikely that I'll have time to implement it. PR welcome!

Do you know of a UDP proxy that implements the PROXY protocol?

dsshap commented 8 years ago

Haven't researched it too much, but found this repo: https://github.com/gildean/node-udp-proxy

dsshap commented 8 years ago

not even sure that does what i am looking for.

daguej commented 8 years ago

Looks like that proxies UDP traffic, but does not implement the PROXY protocol.

daguej commented 8 years ago

Actually, after a second reading of the protocol spec, it does not appear that the PROXY protocol really defines how UDP should work. It does mention UDP a couple times in passing, but the rest of the spec is very stream- (TCP) and connection-oriented. The spec is silent on how UDP is supposed to work -- is every UDP packet supposed to have a PROXY header? What does "connection" even mean in a connectionless protocol like UDP?

Additionally, the v1 protocol--which is the only version this module currently supports--explicitly does not support UDP:

  • a string indicating the proxied INET protocol and family. As of version 1, only "TCP4" ( \x54 \x43 \x50 \x34 ) for TCP over IPv4, and "TCP6" ( \x54 \x43 \x50 \x36 ) for TCP over IPv6 are allowed. Other, unsupported, or unknown protocols must be reported with the name "UNKNOWN" ...

The binary v2 protocol does enumerate a UDP connection type, but it's not clear what "the forwarded connection" really means in the context of a connectionless protocol.

  • 0x2 : DGRAM : the forwarded connection uses a SOCK_DGRAM protocol (eg: UDP or UNIX_DGRAM). When used with AF_INET/AF_INET6 (UDP), the addresses are followed by the source and destination ports represented on 2 bytes each in network byte order.

Indeed, HAProxy (the inventor of the PROXY protocol) doesn't support UDP at all, so it's not surprising that using UDP with PROXY appears to be not entirely thought out.

Given that the spec doesn't seem to properly support UDP, I don't think there's anything that can be done here.