feat(channel): add peerport field in ClientInfo
This commit is contained in:
parent
b34e66bdf7
commit
68da627b4d
|
@ -213,7 +213,7 @@ caps(#channel{clientinfo = #{zone := Zone}}) ->
|
|||
-spec init(emqx_types:conninfo(), opts()) -> channel().
|
||||
init(
|
||||
ConnInfo = #{
|
||||
peername := {PeerHost, _Port},
|
||||
peername := {PeerHost, PeerPort},
|
||||
sockname := {_Host, SockPort}
|
||||
},
|
||||
#{
|
||||
|
@ -237,6 +237,7 @@ init(
|
|||
listener => ListenerId,
|
||||
protocol => Protocol,
|
||||
peerhost => PeerHost,
|
||||
peerport => PeerPort,
|
||||
sockport => SockPort,
|
||||
clientid => undefined,
|
||||
username => undefined,
|
||||
|
|
|
@ -72,6 +72,22 @@ t_chan_info(_) ->
|
|||
conn_state := connected,
|
||||
clientinfo := ClientInfo
|
||||
} = emqx_channel:info(channel()),
|
||||
?assertMatch(
|
||||
#{
|
||||
zone := default,
|
||||
listener := {tcp, default},
|
||||
protocol := mqtt,
|
||||
peerhost := {127, 0, 0, 1},
|
||||
peerport := 3456,
|
||||
sockport := 1883,
|
||||
clientid := <<"clientid">>,
|
||||
username := <<"username">>,
|
||||
is_superuser := false,
|
||||
is_bridge := false,
|
||||
mountpoint := undefined
|
||||
},
|
||||
ClientInfo
|
||||
),
|
||||
?assertEqual(clientinfo(), ClientInfo).
|
||||
|
||||
t_chan_caps(_) ->
|
||||
|
@ -1063,7 +1079,8 @@ clientinfo(InitProps) ->
|
|||
listener => {tcp, default},
|
||||
protocol => mqtt,
|
||||
peerhost => {127, 0, 0, 1},
|
||||
sockport => 3456,
|
||||
peerport => 3456,
|
||||
sockport => 1883,
|
||||
clientid => <<"clientid">>,
|
||||
username => <<"username">>,
|
||||
is_superuser => false,
|
||||
|
|
|
@ -108,6 +108,7 @@ clientinfo() ->
|
|||
{zone, zone()},
|
||||
{protocol, protocol()},
|
||||
{peerhost, ip()},
|
||||
{peerport, port()},
|
||||
{sockport, port()},
|
||||
{clientid, clientid()},
|
||||
{username, username()},
|
||||
|
|
Loading…
Reference in New Issue