fix
This commit is contained in:
parent
66935409c9
commit
a6d140afaa
@ -17,27 +17,11 @@
|
|||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
%% 重新加载对应的主机信息
|
%% 重新加载对应的主机信息
|
||||||
handle_request("POST", "/test/auth_token", _, PostParams) ->
|
handle_request("POST", "/test/auth_access_token", _, _PostParams) ->
|
||||||
logger:debug("[test_handler] get post params: ~p", [PostParams]),
|
{ok, 200, sdlan_util:json_data(<<"ok">>)};
|
||||||
Data = #{
|
|
||||||
<<"network_id">> => 8,
|
|
||||||
<<"upgrade_type">> => 0,
|
|
||||||
<<"upgrade_prompt">> => <<"simple upgrade">>,
|
|
||||||
<<"upgrade_address">> => <<"upgrade_address">>
|
|
||||||
},
|
|
||||||
{ok, 200, sdlan_util:json_data(Data)};
|
|
||||||
|
|
||||||
handle_request("POST", "/test/upgrade", _, PostParams) ->
|
|
||||||
logger:debug("[test_handler] get post params: ~p", [PostParams]),
|
|
||||||
Data = #{
|
|
||||||
<<"upgrade_type">> => 1,
|
|
||||||
<<"upgrade_prompt">> => <<"prompt需要升级"/utf8>>,
|
|
||||||
<<"upgrade_address">> => <<"macappstore://apps.apple.com/app/id836500024">>
|
|
||||||
},
|
|
||||||
{ok, 200, sdlan_util:json_data(Data)};
|
|
||||||
|
|
||||||
handle_request("GET", "/test/get_all_networks", _, _) ->
|
handle_request("GET", "/test/get_all_networks", _, _) ->
|
||||||
{ok, 200, sdlan_util:json_data([8, 9, 10])};
|
{ok, 200, sdlan_util:json_data([8])};
|
||||||
|
|
||||||
handle_request("GET", "/test/get_network", #{<<"id">> := Id0}, _) ->
|
handle_request("GET", "/test/get_network", #{<<"id">> := Id0}, _) ->
|
||||||
Id = binary_to_integer(Id0),
|
Id = binary_to_integer(Id0),
|
||||||
@ -45,23 +29,10 @@ handle_request("GET", "/test/get_network", #{<<"id">> := Id0}, _) ->
|
|||||||
8 => #{
|
8 => #{
|
||||||
<<"id">> => 8,
|
<<"id">> => 8,
|
||||||
<<"name">> => <<"test1">>,
|
<<"name">> => <<"test1">>,
|
||||||
|
<<"domain">> => <<"punchnet.cn">>,
|
||||||
<<"ipaddr">> => <<"10.211.179.0/24">>,
|
<<"ipaddr">> => <<"10.211.179.0/24">>,
|
||||||
<<"owner_id">> => 1234,
|
<<"owner_id">> => 1234,
|
||||||
<<"disabled_clients">> => []
|
<<"disabled_clients">> => []
|
||||||
},
|
|
||||||
9 => #{
|
|
||||||
<<"id">> => 9,
|
|
||||||
<<"name">> => <<"test2">>,
|
|
||||||
<<"ipaddr">> => <<"10.211.180.0/24">>,
|
|
||||||
<<"owner_id">> => 1234,
|
|
||||||
<<"disabled_clients">> => []
|
|
||||||
},
|
|
||||||
10 => #{
|
|
||||||
<<"id">> => 10,
|
|
||||||
<<"name">> => <<"test3">>,
|
|
||||||
<<"ipaddr">> => <<"10.211.181.0/24">>,
|
|
||||||
<<"owner_id">> => 1234,
|
|
||||||
<<"disabled_clients">> => []
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Network = maps:get(Id, Networks),
|
Network = maps:get(Id, Networks),
|
||||||
|
|||||||
@ -50,18 +50,17 @@ get_network(Id) when is_integer(Id) ->
|
|||||||
%% todo
|
%% todo
|
||||||
-spec auth_access_token(Params :: map()) -> {ok, Resp :: map()} | {error, Reason :: any()}.
|
-spec auth_access_token(Params :: map()) -> {ok, Resp :: map()} | {error, Reason :: any()}.
|
||||||
auth_access_token(Params) when is_map(Params) ->
|
auth_access_token(Params) when is_map(Params) ->
|
||||||
{ok, #{<<"result">> => <<"ok">>}}.
|
case catch do_post("auth_access_token", Params) of
|
||||||
%case catch do_post("auth_token", Params) of
|
{ok, Resp} ->
|
||||||
% {ok, Resp} ->
|
case catch jiffy:decode(Resp, [return_maps]) of
|
||||||
% case catch jiffy:decode(Resp, [return_maps]) of
|
Result when is_map(Result) ->
|
||||||
% Result when is_map(Result) ->
|
{ok, Result};
|
||||||
% {ok, Result};
|
{error, Reason} ->
|
||||||
% {error, Reason} ->
|
{error, Reason}
|
||||||
% {error, Reason}
|
end;
|
||||||
% end;
|
Error ->
|
||||||
% Error ->
|
Error
|
||||||
% Error
|
end.
|
||||||
%end.
|
|
||||||
|
|
||||||
-spec node_online(ClientId :: binary(), NetworkId :: integer(), IpAddr :: binary()) -> {ok, Resp :: map()} | {error, Reason :: any()}.
|
-spec node_online(ClientId :: binary(), NetworkId :: integer(), IpAddr :: binary()) -> {ok, Resp :: map()} | {error, Reason :: any()}.
|
||||||
node_online(ClientId, NetworkId, IpAddr) when is_binary(ClientId), is_integer(NetworkId), is_binary(IpAddr) ->
|
node_online(ClientId, NetworkId, IpAddr) when is_binary(ClientId), is_integer(NetworkId), is_binary(IpAddr) ->
|
||||||
|
|||||||
@ -41,8 +41,7 @@ start_link() ->
|
|||||||
init([]) ->
|
init([]) ->
|
||||||
SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600},
|
SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600},
|
||||||
{ok, NetworkIds} = sdlan_api:get_all_networks(),
|
{ok, NetworkIds} = sdlan_api:get_all_networks(),
|
||||||
Specs = lists:map(fun child_spec/1, []),
|
Specs = lists:map(fun child_spec/1, NetworkIds),
|
||||||
|
|
||||||
set_network_bind(length(Specs)),
|
set_network_bind(length(Specs)),
|
||||||
|
|
||||||
{ok, {SupFlags, Specs}}.
|
{ok, {SupFlags, Specs}}.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user