fix acl_changed event
This commit is contained in:
parent
5138a18364
commit
9ede6aaa40
@ -67,7 +67,7 @@
|
|||||||
{mysql_sdlan,
|
{mysql_sdlan,
|
||||||
[{size, 10}, {max_overflow, 20}, {worker_module, mysql}],
|
[{size, 10}, {max_overflow, 20}, {worker_module, mysql}],
|
||||||
[
|
[
|
||||||
{host, {118, 178, 229, 213}},
|
{host, {47, 111, 101, 3}},
|
||||||
{port, 3306},
|
{port, 3306},
|
||||||
{user, "punchnetuser"},
|
{user, "punchnetuser"},
|
||||||
{connect_mode, lazy},
|
{connect_mode, lazy},
|
||||||
@ -79,8 +79,8 @@
|
|||||||
}
|
}
|
||||||
]},
|
]},
|
||||||
|
|
||||||
{api_url, "http://127.0.0.1:18082/test/"}
|
%{api_url, "http://127.0.0.1:18082/test/"}
|
||||||
|
{api_url, "https://test.punchsky.com/api/"}
|
||||||
]},
|
]},
|
||||||
|
|
||||||
{throttle, [
|
{throttle, [
|
||||||
|
|||||||
@ -28,7 +28,7 @@ handle_request("POST", "/node/acl_changed", _, #{<<"network_id">> := NetworkId,
|
|||||||
undefined ->
|
undefined ->
|
||||||
{ok, 200, sdlan_util:json_error(-1, <<"network not found">>)};
|
{ok, 200, sdlan_util:json_error(-1, <<"network not found">>)};
|
||||||
Pid ->
|
Pid ->
|
||||||
case sdlan_network:acl_changed(Pid, ClientId) of
|
case sdlan_network:exposed_service_changed(Pid, ClientId) of
|
||||||
ok ->
|
ok ->
|
||||||
{ok, 200, sdlan_util:json_data(<<"success">>)};
|
{ok, 200, sdlan_util:json_data(<<"success">>)};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
%% API
|
%% API
|
||||||
-export([start_link/2]).
|
-export([start_link/2]).
|
||||||
-export([get_name/1, get_pid/1, lookup_pid/1, peer_info/3, unregister/3, debug_info/1, get_network_id/1, attach/7, arp_request/2]).
|
-export([get_name/1, get_pid/1, lookup_pid/1, peer_info/3, unregister/3, debug_info/1, get_network_id/1, attach/7, arp_request/2]).
|
||||||
-export([forward_by_ets/5, update_hole/7, disable_client/2, get_channel/2, acl_changed/2]).
|
-export([forward_by_ets/5, update_hole/7, disable_client/2, get_channel/2, exposed_service_changed/2]).
|
||||||
-export([command/4, wait_command_ack/2]).
|
-export([command/4, wait_command_ack/2]).
|
||||||
|
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
@ -155,9 +155,9 @@ update_hole(Pid, SessionToken, ClientId, Mac, Peer, NatType, V6Info) when is_pid
|
|||||||
disable_client(Pid, ClientId) when is_pid(Pid), is_binary(ClientId) ->
|
disable_client(Pid, ClientId) when is_pid(Pid), is_binary(ClientId) ->
|
||||||
gen_server:call(Pid, {disable_client, ClientId}).
|
gen_server:call(Pid, {disable_client, ClientId}).
|
||||||
|
|
||||||
-spec acl_changed(Pid :: pid(), ClientId :: binary()) -> ok | {error, Reason :: binary()}.
|
-spec exposed_service_changed(Pid :: pid(), ClientId :: binary()) -> ok | {error, Reason :: binary()}.
|
||||||
acl_changed(Pid, ClientId) when is_pid(Pid), is_binary(ClientId) ->
|
exposed_service_changed(Pid, ClientId) when is_pid(Pid), is_binary(ClientId) ->
|
||||||
gen_server:call(Pid, {acl_changed, ClientId}).
|
gen_server:call(Pid, {exposed_service_changed, ClientId}).
|
||||||
|
|
||||||
-spec get_channel(Pid :: pid(), ClientId :: binary()) -> error | {ok, ChannelPid :: pid()}.
|
-spec get_channel(Pid :: pid(), ClientId :: binary()) -> error | {ok, ChannelPid :: pid()}.
|
||||||
get_channel(Pid, ClientId) when is_pid(Pid), is_binary(ClientId) ->
|
get_channel(Pid, ClientId) when is_pid(Pid), is_binary(ClientId) ->
|
||||||
@ -300,7 +300,7 @@ handle_call({peer_info, SrcMac, DstMac}, _From, State = #state{endpoint_table =
|
|||||||
handle_call({arp_request, TargetIp}, _From, State = #state{endpoint_table = EndpointTable}) ->
|
handle_call({arp_request, TargetIp}, _From, State = #state{endpoint_table = EndpointTable}) ->
|
||||||
MatchSpec = ets:fun2ms(fun(Object = {_Mac, #endpoint{ip = Ip}}) when Ip =:= TargetIp ->
|
MatchSpec = ets:fun2ms(fun(Object = {_Mac, #endpoint{ip = Ip}}) when Ip =:= TargetIp ->
|
||||||
Object
|
Object
|
||||||
end),
|
end),
|
||||||
case select_endpoint(EndpointTable, MatchSpec) of
|
case select_endpoint(EndpointTable, MatchSpec) of
|
||||||
error ->
|
error ->
|
||||||
{reply, error, State};
|
{reply, error, State};
|
||||||
@ -323,7 +323,7 @@ handle_call({command, ReceiverPid, ClientId, SubCommand}, _From, State = #state{
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
%% 触发acl改变
|
%% 触发acl改变
|
||||||
handle_call({acl_changed, ClientId}, _From, State = #state{endpoint_table = EndpointTable}) ->
|
handle_call({exposed_service_changed, ClientId}, _From, State = #state{endpoint_table = EndpointTable}) ->
|
||||||
MatchSpec = ets:fun2ms(fun(Object = {_Mac, #endpoint{client_id = ClientId0}}) when ClientId0 =:= ClientId ->
|
MatchSpec = ets:fun2ms(fun(Object = {_Mac, #endpoint{client_id = ClientId0}}) when ClientId0 =:= ClientId ->
|
||||||
Object
|
Object
|
||||||
end),
|
end),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user