This commit is contained in:
anlicheng 2025-04-21 17:38:48 +08:00
parent 010a478bdf
commit 47a16df2c5
4 changed files with 20 additions and 3 deletions

View File

@ -14,6 +14,8 @@
%% token是否是合法值 %% token是否是合法值
-spec check(Username :: binary(), Token :: binary(), UUID :: binary(), Salt :: binary(), Timestamp :: integer()) -> boolean(). -spec check(Username :: binary(), Token :: binary(), UUID :: binary(), Salt :: binary(), Timestamp :: integer()) -> boolean().
check(Username, Token, UUID, Salt, Timestamp) when is_binary(Username), is_binary(Token), is_binary(UUID), is_binary(Salt), is_integer(Timestamp) ->
true;
check(Username, Token, UUID, Salt, Timestamp) when is_binary(Username), is_binary(Token), is_binary(UUID), is_binary(Salt), is_integer(Timestamp) -> check(Username, Token, UUID, Salt, Timestamp) when is_binary(Username), is_binary(Token), is_binary(UUID), is_binary(Salt), is_integer(Timestamp) ->
BinTimestamp = integer_to_binary(Timestamp), BinTimestamp = integer_to_binary(Timestamp),
%% 1 %% 1

View File

@ -27,7 +27,7 @@ start_link() ->
%% modules => modules()} % optional %% modules => modules()} % optional
init([]) -> init([]) ->
SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600}, SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600},
Specs0 = [ Specs = [
#{ #{
id => 'iot_device_sup', id => 'iot_device_sup',
start => {'iot_device_sup', start_link, []}, start => {'iot_device_sup', start_link, []},
@ -47,7 +47,7 @@ init([]) ->
} }
], ],
{ok, {SupFlags, pools() ++ []}}. {ok, {SupFlags, pools() ++ Specs}}.
%% internal functions %% internal functions

View File

@ -78,7 +78,7 @@ handle_cast(_Msg, State) ->
%% auth验证 %% auth验证
handle_info({tcp, Socket, <<?PACKET_REQUEST, PacketId:32, ?METHOD_AUTH:8, AuthRequestBin/binary>>}, State = #state{transport = Transport, socket = Socket}) -> handle_info({tcp, Socket, <<?PACKET_REQUEST, PacketId:32, ?METHOD_AUTH:8, AuthRequestBin/binary>>}, State = #state{transport = Transport, socket = Socket}) ->
#auth_request{ uuid = UUID, username = Username, token = Token, salt = Salt, timestamp = Timestamp } = message_pb:decode_msg(AuthRequestBin, auth_request), #auth_request{ uuid = UUID, username = Username, token = Token, salt = Salt, timestamp = Timestamp } = message_pb:decode_msg(AuthRequestBin, auth_request),
lager:debug("[ws_channel] auth uuid: ~p, request message: ~p", [UUID]), lager:debug("[ws_channel] auth uuid: ~p", [UUID]),
case iot_auth:check(Username, Token, UUID, Salt, Timestamp) of case iot_auth:check(Username, Token, UUID, Salt, Timestamp) of
true -> true ->
case host_bo:get_host_by_uuid(UUID) of case host_bo:get_host_by_uuid(UUID) of

View File

@ -44,6 +44,21 @@
]}, ]},
{pools, [ {pools, [
%% mysql连接池配置
{mysql_iot,
[{size, 10}, {max_overflow, 20}, {worker_module, mysql}],
[
{host, {39, 98, 184, 67}},
{port, 3306},
{user, "nannonguser"},
{connect_mode, synchronous},
{keep_alive, true},
{password, "nannong@Fe7w"},
{database, "nannong"},
{queries, [<<"set names utf8">>]}
]
},
%% redis连接池 %% redis连接池
{redis_pool, {redis_pool,
[{size, 10}, {max_overflow, 20}, {worker_module, eredis}], [{size, 10}, {max_overflow, 20}, {worker_module, eredis}],