diff --git a/apps/iot/src/iot_auth.erl b/apps/iot/src/iot_auth.erl index 55c2805..b0b6305 100644 --- a/apps/iot/src/iot_auth.erl +++ b/apps/iot/src/iot_auth.erl @@ -14,6 +14,8 @@ %% 检测token是否是合法值 -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) -> BinTimestamp = integer_to_binary(Timestamp), %% 1分钟内有效 diff --git a/apps/iot/src/iot_sup.erl b/apps/iot/src/iot_sup.erl index 04c6318..c644a48 100644 --- a/apps/iot/src/iot_sup.erl +++ b/apps/iot/src/iot_sup.erl @@ -27,7 +27,7 @@ start_link() -> %% modules => modules()} % optional init([]) -> SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600}, - Specs0 = [ + Specs = [ #{ id => 'iot_device_sup', start => {'iot_device_sup', start_link, []}, @@ -47,7 +47,7 @@ init([]) -> } ], - {ok, {SupFlags, pools() ++ []}}. + {ok, {SupFlags, pools() ++ Specs}}. %% internal functions diff --git a/apps/iot/src/websocket/tcp_channel.erl b/apps/iot/src/websocket/tcp_channel.erl index fc84e7c..9ae6666 100644 --- a/apps/iot/src/websocket/tcp_channel.erl +++ b/apps/iot/src/websocket/tcp_channel.erl @@ -78,7 +78,7 @@ handle_cast(_Msg, State) -> %% auth验证 handle_info({tcp, Socket, <>}, 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), - 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 true -> case host_bo:get_host_by_uuid(UUID) of diff --git a/config/sys-dev.config b/config/sys-dev.config index 1d8ab33..702a458 100644 --- a/config/sys-dev.config +++ b/config/sys-dev.config @@ -44,6 +44,21 @@ ]}, {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_pool, [{size, 10}, {max_overflow, 20}, {worker_module, eredis}],