feat(frame): better log for proxy_protocol config disabled
This commit is contained in:
parent
9a43125c9b
commit
b9acf94fd7
|
@ -629,10 +629,15 @@ parse_incoming(Data, Packets, State = #state{parse_state = ParseState}) ->
|
|||
NState = State#state{parse_state = NParseState},
|
||||
parse_incoming(Rest, [Packet|Packets], NState)
|
||||
catch
|
||||
error:proxy_protocol_config_disabled:_Stk ->
|
||||
?LOG(error,
|
||||
"~nMalformed packet, "
|
||||
"please check proxy_protocol config for specific listeners and zones~n"),
|
||||
{[{frame_error, proxy_protocol_config_disabled} | Packets], State};
|
||||
error:Reason:Stk ->
|
||||
?LOG(error, "~nParse failed for ~0p~n~0p~nFrame data:~0p",
|
||||
[Reason, Stk, Data]),
|
||||
{[{frame_error, Reason}|Packets], State}
|
||||
{[{frame_error, Reason} | Packets], State}
|
||||
end.
|
||||
|
||||
-compile({inline, [next_incoming_msgs/1]}).
|
||||
|
|
|
@ -71,6 +71,13 @@
|
|||
|
||||
-define(MULTIPLIER_MAX, 16#200000).
|
||||
|
||||
%% proxy_protocol v1 header human readable
|
||||
-define(PPV1_PROXY, "PROXY ").
|
||||
-define(PPV1_PROXY_UNKNOWN, "PROXY UNKNOWN").
|
||||
%% proxy_protocol v2 header signature:
|
||||
%% 16#0D,16#0A, 16#0D,16#0A,16#00,16#0D,16#0A,16#51,16#55,16#49,16#54,16#0A
|
||||
-define(PPV2_HEADER_SIG, "\r\n\r\n\0\r\nQUIT\n").
|
||||
|
||||
-dialyzer({no_match, [serialize_utf8_string/2]}).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
|
@ -100,6 +107,13 @@ parse(Bin) ->
|
|||
-spec(parse(binary(), parse_state()) -> parse_result()).
|
||||
parse(<<>>, {none, Options}) ->
|
||||
{more, {none, Options}};
|
||||
parse(<<?PPV1_PROXY, IPVer:5/binary, _Rest/binary>>, {none, _Options})
|
||||
when IPVer =:= <<"TCP4 ">> orelse IPVer =:= <<"TCP6 ">> ->
|
||||
error(proxy_protocol_config_disabled);
|
||||
parse(<<?PPV1_PROXY_UNKNOWN, _Rest/binary>>, {none, _Options}) ->
|
||||
error(proxy_protocol_config_disabled);
|
||||
parse(<<?PPV2_HEADER_SIG, _Rest/binary>>, {none, _Options}) ->
|
||||
error(proxy_protocol_config_disabled);
|
||||
parse(<<Type:4, Dup:1, QoS:2, Retain:1, Rest/binary>>,
|
||||
{none, Options = #{strict_mode := StrictMode}}) ->
|
||||
%% Validate header if strict mode.
|
||||
|
|
Loading…
Reference in New Issue