Add protocol in client object

This commit is contained in:
terry-xiaoyu 2019-09-21 12:20:20 +08:00
parent ab9d7232a9
commit 18edf5cec3
2 changed files with 4 additions and 2 deletions

View File

@ -172,7 +172,7 @@ set_field(Name, Val, Channel) ->
%%--------------------------------------------------------------------
-spec(init(emqx_types:conninfo(), proplists:proplist()) -> channel()).
init(ConnInfo = #{peername := {PeerHost, _Port}}, Options) ->
init(ConnInfo = #{peername := {PeerHost, _Port}, protocol := Protocol}, Options) ->
Zone = proplists:get_value(zone, Options),
Peercert = maps:get(peercert, ConnInfo, undefined),
Username = case peer_cert_as_username(Options) of
@ -183,6 +183,7 @@ init(ConnInfo = #{peername := {PeerHost, _Port}}, Options) ->
end,
MountPoint = emqx_zone:get_env(Zone, mountpoint),
ClientInfo = #{zone => Zone,
protocol => Protocol,
peerhost => PeerHost,
peercert => Peercert,
client_id => undefined,

View File

@ -103,6 +103,7 @@
atom() => term()
}).
-type(client() :: #{zone := zone(),
protocol := protocol(),
peerhost := peerhost(),
client_id := client_id(),
username := username(),
@ -121,7 +122,7 @@
-type(password() :: maybe(binary())).
-type(peerhost() :: inet:ip_address()).
-type(peername() :: {inet:ip_address(), inet:port_number()}).
-type(protocol() :: mqtt | 'mqtt-sn' | coap | stomp | none | atom()).
-type(protocol() :: mqtt | 'mqtt-sn' | coap | lwm2m | stomp | none | atom()).
-type(auth_result() :: success
| client_identifier_not_valid
| bad_username_or_password