Put sockname to credentials (#2532)

* Add sockname to credentials

* Explicit credentials type define
This commit is contained in:
JianBo He 2019-05-14 10:22:30 +08:00 committed by GitHub
parent 97cca1a5ba
commit 79c1b7eb78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -40,6 +40,7 @@
-record(pstate, {
zone,
sendfun,
sockname,
peername,
peercert,
proto_ver,
@ -87,12 +88,14 @@
%%------------------------------------------------------------------------------
-spec(init(map(), list()) -> state()).
init(SocketOpts = #{ peername := Peername
init(SocketOpts = #{ sockname := Sockname
, peername := Peername
, peercert := Peercert
, sendfun := SendFun}, Options) ->
Zone = proplists:get_value(zone, Options),
#pstate{zone = Zone,
sendfun = SendFun,
sockname = Sockname,
peername = Peername,
peercert = Peercert,
proto_ver = ?MQTT_PROTO_V4,
@ -208,11 +211,13 @@ client_id(#pstate{client_id = ClientId}) ->
credentials(#pstate{zone = Zone,
client_id = ClientId,
username = Username,
sockname = Sockname,
peername = Peername,
peercert = Peercert,
ws_cookie = WsCookie}) ->
with_cert(#{zone => Zone,
client_id => ClientId,
sockname => Sockname,
username => Username,
peername => Peername,
ws_cookie => WsCookie,

View File

@ -80,11 +80,15 @@
| banned
| bad_authentication_method).
-type(protocol() :: mqtt | 'mqtt-sn' | coap | stomp | none | atom()).
-type(credentials() :: #{client_id := client_id(),
-type(credentials() :: #{zone := zone(),
client_id := client_id(),
username := username(),
sockname := peername(),
peername := peername(),
auth_result := auth_result(),
zone => zone(),
ws_cookie := undefined | list(),
mountpoint := binary(),
password => binary(),
auth_result => auth_result(),
atom() => term()
}).
-type(subscription() :: #subscription{}).