mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-11-30 03:07:40 +08:00
feat: add port check
This commit is contained in:
parent
db709fa9c8
commit
9ae3fe32fa
@ -109,6 +109,8 @@
|
||||
, get_ipv6/1
|
||||
, trim_string/1
|
||||
, get_url_path/1
|
||||
, get_ports/0
|
||||
, check_port/1
|
||||
]).
|
||||
|
||||
-define(TIMEZONE, + 8).
|
||||
@ -890,3 +892,23 @@ url_path(Url) ->
|
||||
%% "192.168.0.183:5094/wordServer/20211112142832/1.jpg",
|
||||
{match, [{Start, _Len}]} = re:run(Url, <<"\/">>),
|
||||
to_binary(string:substr(Url, Start + 1, length(Url))).
|
||||
|
||||
get_ports() ->
|
||||
lists:foldl(fun(X, Acc) ->
|
||||
case inet:port(X) of
|
||||
{ok, Port} ->
|
||||
Acc ++ [Port];
|
||||
_ ->
|
||||
Acc
|
||||
end
|
||||
end, [], erlang:ports()).
|
||||
|
||||
check_port(Port) ->
|
||||
lists:any(fun(X) ->
|
||||
case inet:port(X) of
|
||||
{ok, Port} ->
|
||||
true;
|
||||
_ ->
|
||||
false
|
||||
end
|
||||
end, erlang:ports()).
|
@ -54,7 +54,7 @@ handle_info({message, #{<<"cmd">> := <<"LOGIN">>, <<"addr">> := Addr}}, #{<<"pro
|
||||
Auto andalso erlang:send_after(5000, self(), check),
|
||||
{ok, State#{<<"addr">> => Addr}};
|
||||
|
||||
handle_info({message, #{<<"cmd">> := <<"HEART">>}}, #{ <<"addr">> := Addr, <<"productId">> := ProductId, <<"channelId">> := ChannelId, <<"auto">>:= Auto} = State) ->
|
||||
handle_info({message, #{<<"cmd">> := <<"HEART">>}}, #{ <<"addr">> := Addr, <<"productId">> := ProductId, <<"channelId">> := ChannelId} = State) ->
|
||||
dgiot_bridge:send_log(ChannelId, ProductId, "DTU ~p HEART", [Addr]),
|
||||
{ok, State};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user