fix: clients ip address params trans (#5657)

* fix: clients ip address params trans
This commit is contained in:
DDDHuang 2021-09-06 13:32:29 +08:00 committed by GitHub
parent f514f0c89b
commit b1023d9733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -289,6 +289,7 @@ to_type_(V, atom) -> to_atom(V);
to_type_(V, integer) -> to_integer(V); to_type_(V, integer) -> to_integer(V);
to_type_(V, timestamp) -> to_timestamp(V); to_type_(V, timestamp) -> to_timestamp(V);
to_type_(V, ip) -> aton(V); to_type_(V, ip) -> aton(V);
to_type_(V, ip_port) -> to_ip_port(V);
to_type_(V, _) -> V. to_type_(V, _) -> V.
to_atom(A) when is_atom(A) -> to_atom(A) when is_atom(A) ->
@ -309,6 +310,12 @@ to_timestamp(B) when is_binary(B) ->
aton(B) when is_binary(B) -> aton(B) when is_binary(B) ->
list_to_tuple([binary_to_integer(T) || T <- re:split(B, "[.]")]). list_to_tuple([binary_to_integer(T) || T <- re:split(B, "[.]")]).
to_ip_port(IPAddress) ->
[IP0, Port0] = string:tokens(binary_to_list(IPAddress), ":"),
{ok, IP} = inet:parse_address(IP0),
Port = list_to_integer(Port0),
{IP, Port}.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% EUnits %% EUnits
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------

View File

@ -45,7 +45,7 @@
[ {<<"node">>, atom} [ {<<"node">>, atom}
, {<<"username">>, binary} , {<<"username">>, binary}
, {<<"zone">>, atom} , {<<"zone">>, atom}
, {<<"ip_address">>, ip} , {<<"ip_address">>, ip_port}
, {<<"conn_state">>, atom} , {<<"conn_state">>, atom}
, {<<"clean_start">>, atom} , {<<"clean_start">>, atom}
, {<<"proto_name">>, binary} , {<<"proto_name">>, binary}
@ -566,10 +566,10 @@ ms(username, X) ->
#{clientinfo => #{username => X}}; #{clientinfo => #{username => X}};
ms(zone, X) -> ms(zone, X) ->
#{clientinfo => #{zone => X}}; #{clientinfo => #{zone => X}};
ms(ip_address, X) ->
#{clientinfo => #{peerhost => X}};
ms(conn_state, X) -> ms(conn_state, X) ->
#{conn_state => X}; #{conn_state => X};
ms(ip_address, X) ->
#{conninfo => #{peername => X}};
ms(clean_start, X) -> ms(clean_start, X) ->
#{conninfo => #{clean_start => X}}; #{conninfo => #{clean_start => X}};
ms(proto_name, X) -> ms(proto_name, X) ->