add ssl 心跳机制
This commit is contained in:
parent
1fdd0bf5a5
commit
627be12a6e
@ -47,8 +47,10 @@ start_link() ->
|
|||||||
{ok, State :: #state{}} | {ok, State :: #state{}, timeout() | hibernate} |
|
{ok, State :: #state{}} | {ok, State :: #state{}, timeout() | hibernate} |
|
||||||
{stop, Reason :: term()} | ignore).
|
{stop, Reason :: term()} | ignore).
|
||||||
init([]) ->
|
init([]) ->
|
||||||
|
ok = iot_log:set_metadata(),
|
||||||
{ok, UdpServerProps} = application:get_env(iot, udp_server),
|
{ok, UdpServerProps} = application:get_env(iot, udp_server),
|
||||||
Port = proplists:get_value(port, UdpServerProps),
|
Port = proplists:get_value(port, UdpServerProps),
|
||||||
|
logger:debug("[udp_server] start at port: ~p", [Port]),
|
||||||
{ok, Socket} = gen_udp:open(Port, [binary, {active, true}]),
|
{ok, Socket} = gen_udp:open(Port, [binary, {active, true}]),
|
||||||
{ok, #state{socket = Socket}}.
|
{ok, #state{socket = Socket}}.
|
||||||
|
|
||||||
@ -116,6 +118,7 @@ handle_heartbeat_packet(Packet, Peer) when is_binary(Packet) ->
|
|||||||
{ok, UUID, Timestamp, Payload, Mac} ->
|
{ok, UUID, Timestamp, Payload, Mac} ->
|
||||||
case efka_client_store:verify_heartbeat(UUID, Timestamp, Payload, Mac) of
|
case efka_client_store:verify_heartbeat(UUID, Timestamp, Payload, Mac) of
|
||||||
true ->
|
true ->
|
||||||
|
logger:warning("[udp_server] heartbeat auth from peer: ~p, uuid: ~p", [Peer, UUID]),
|
||||||
Pid = iot_host:get_pid(UUID),
|
Pid = iot_host:get_pid(UUID),
|
||||||
iot_host:heartbeat(Pid);
|
iot_host:heartbeat(Pid);
|
||||||
false ->
|
false ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user