-
Notifications
You must be signed in to change notification settings - Fork 266
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
Parse proxy protocol #337
base: master
Are you sure you want to change the base?
Parse proxy protocol #337
Conversation
I guess it is a bit tricky to add a test for this? |
@ mworrell the fix is not proper. I will adjust it in the next days. |
I made the implementation much easy by using |
can be tested with haproxy basic config:
|
case Data of | ||
<<"PROXY ", _/binary>> -> | ||
case binary:split(Data, <<" ">>, [global]) of | ||
[<<"PROXY">>, InetFamily, SrcIp, _DstIp, _SrcPort, _DstPort] when InetFamily == <<"TCP4">> orelse InetFamily == <<"TCP6">> -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably use the right, address specific parser for v4 or v6, so if the proxy sends TCP4 with a v6 address, things fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh... can you be more explicit ?
ok = Transport:setopts(Socket, [{packet, line}, binary]), | ||
case Transport:recv(Socket, 0, 5000) of | ||
{ok, Data} -> | ||
case Data of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also a binary form of this protocol (version 2), were you planning on supporting this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can support if you think it makes sense. Idea is that you have control in what version you want to use:
send-proxy
is v1 (current implementation)
send-proxy-v2
- is v2
In case you want to load balance the servers with an HAPROXY and you need to properly detect the peer ip you need to use the PROXY PROTOCOL: http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt