feat(exhook): provide the `peerport` field
- both in `ConnInfo` and `ClientInfo`
This commit is contained in:
parent
68da627b4d
commit
46201a8796
|
@ -368,6 +368,8 @@ message ConnInfo {
|
||||||
string proto_ver = 7;
|
string proto_ver = 7;
|
||||||
|
|
||||||
uint32 keepalive = 8;
|
uint32 keepalive = 8;
|
||||||
|
|
||||||
|
uint32 peerport = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ClientInfo {
|
message ClientInfo {
|
||||||
|
@ -397,6 +399,8 @@ message ClientInfo {
|
||||||
|
|
||||||
// subject of client TLS cert
|
// subject of client TLS cert
|
||||||
string dn = 12;
|
string dn = 12;
|
||||||
|
|
||||||
|
uint32 peerport = 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Message {
|
message Message {
|
||||||
|
|
|
@ -294,7 +294,7 @@ conninfo(
|
||||||
ConnInfo =
|
ConnInfo =
|
||||||
#{
|
#{
|
||||||
clientid := ClientId,
|
clientid := ClientId,
|
||||||
peername := {Peerhost, _},
|
peername := {Peerhost, PeerPort},
|
||||||
sockname := {_, SockPort}
|
sockname := {_, SockPort}
|
||||||
}
|
}
|
||||||
) ->
|
) ->
|
||||||
|
@ -307,6 +307,7 @@ conninfo(
|
||||||
clientid => ClientId,
|
clientid => ClientId,
|
||||||
username => maybe(Username),
|
username => maybe(Username),
|
||||||
peerhost => ntoa(Peerhost),
|
peerhost => ntoa(Peerhost),
|
||||||
|
peerport => PeerPort,
|
||||||
sockport => SockPort,
|
sockport => SockPort,
|
||||||
proto_name => ProtoName,
|
proto_name => ProtoName,
|
||||||
proto_ver => stringfy(ProtoVer),
|
proto_ver => stringfy(ProtoVer),
|
||||||
|
@ -319,6 +320,7 @@ clientinfo(
|
||||||
clientid := ClientId,
|
clientid := ClientId,
|
||||||
username := Username,
|
username := Username,
|
||||||
peerhost := PeerHost,
|
peerhost := PeerHost,
|
||||||
|
peerport := PeerPort,
|
||||||
sockport := SockPort,
|
sockport := SockPort,
|
||||||
protocol := Protocol,
|
protocol := Protocol,
|
||||||
mountpoint := Mountpoiont
|
mountpoint := Mountpoiont
|
||||||
|
@ -330,6 +332,7 @@ clientinfo(
|
||||||
username => maybe(Username),
|
username => maybe(Username),
|
||||||
password => maybe(maps:get(password, ClientInfo, undefined)),
|
password => maybe(maps:get(password, ClientInfo, undefined)),
|
||||||
peerhost => ntoa(PeerHost),
|
peerhost => ntoa(PeerHost),
|
||||||
|
peerport => PeerPort,
|
||||||
sockport => SockPort,
|
sockport => SockPort,
|
||||||
protocol => stringfy(Protocol),
|
protocol => stringfy(Protocol),
|
||||||
mountpoint => maybe(Mountpoiont),
|
mountpoint => maybe(Mountpoiont),
|
||||||
|
|
|
@ -118,6 +118,7 @@ t_access_failed_if_no_server_running(Config) ->
|
||||||
clientid => <<"user-id-1">>,
|
clientid => <<"user-id-1">>,
|
||||||
username => <<"usera">>,
|
username => <<"usera">>,
|
||||||
peerhost => {127, 0, 0, 1},
|
peerhost => {127, 0, 0, 1},
|
||||||
|
peerport => 3456,
|
||||||
sockport => 1883,
|
sockport => 1883,
|
||||||
protocol => mqtt,
|
protocol => mqtt,
|
||||||
mountpoint => undefined
|
mountpoint => undefined
|
||||||
|
@ -301,6 +302,7 @@ t_simulated_handler(_) ->
|
||||||
clientid => <<"user-id-1">>,
|
clientid => <<"user-id-1">>,
|
||||||
username => <<"usera">>,
|
username => <<"usera">>,
|
||||||
peerhost => {127, 0, 0, 1},
|
peerhost => {127, 0, 0, 1},
|
||||||
|
peerport => 3456,
|
||||||
sockport => 1883,
|
sockport => 1883,
|
||||||
protocol => mqtt,
|
protocol => mqtt,
|
||||||
mountpoint => undefined
|
mountpoint => undefined
|
||||||
|
|
|
@ -496,6 +496,9 @@ nodestr() ->
|
||||||
peerhost(#{peername := {Host, _}}) ->
|
peerhost(#{peername := {Host, _}}) ->
|
||||||
ntoa(Host).
|
ntoa(Host).
|
||||||
|
|
||||||
|
peerport(#{peername := {_, Port}}) ->
|
||||||
|
Port.
|
||||||
|
|
||||||
sockport(#{sockname := {_, Port}}) ->
|
sockport(#{sockname := {_, Port}}) ->
|
||||||
Port.
|
Port.
|
||||||
|
|
||||||
|
@ -564,6 +567,7 @@ from_conninfo(ConnInfo) ->
|
||||||
clientid => maps:get(clientid, ConnInfo),
|
clientid => maps:get(clientid, ConnInfo),
|
||||||
username => maybe(maps:get(username, ConnInfo, <<>>)),
|
username => maybe(maps:get(username, ConnInfo, <<>>)),
|
||||||
peerhost => peerhost(ConnInfo),
|
peerhost => peerhost(ConnInfo),
|
||||||
|
peerport => peerport(ConnInfo),
|
||||||
sockport => sockport(ConnInfo),
|
sockport => sockport(ConnInfo),
|
||||||
proto_name => maps:get(proto_name, ConnInfo),
|
proto_name => maps:get(proto_name, ConnInfo),
|
||||||
proto_ver => stringfy(maps:get(proto_ver, ConnInfo)),
|
proto_ver => stringfy(maps:get(proto_ver, ConnInfo)),
|
||||||
|
@ -577,6 +581,7 @@ from_clientinfo(ClientInfo) ->
|
||||||
username => maybe(maps:get(username, ClientInfo, <<>>)),
|
username => maybe(maps:get(username, ClientInfo, <<>>)),
|
||||||
password => maybe(maps:get(password, ClientInfo, <<>>)),
|
password => maybe(maps:get(password, ClientInfo, <<>>)),
|
||||||
peerhost => ntoa(maps:get(peerhost, ClientInfo)),
|
peerhost => ntoa(maps:get(peerhost, ClientInfo)),
|
||||||
|
peerport => maps:get(peerport, ClientInfo),
|
||||||
sockport => maps:get(sockport, ClientInfo),
|
sockport => maps:get(sockport, ClientInfo),
|
||||||
protocol => stringfy(maps:get(protocol, ClientInfo)),
|
protocol => stringfy(maps:get(protocol, ClientInfo)),
|
||||||
mountpoint => maybe(maps:get(mountpoint, ClientInfo, <<>>)),
|
mountpoint => maybe(maps:get(mountpoint, ClientInfo, <<>>)),
|
||||||
|
|
Loading…
Reference in New Issue