This commit is contained in:
anlicheng 2026-02-05 23:12:16 +08:00
parent 79eded8c96
commit b3a51adc95

View File

@ -400,16 +400,16 @@ handle_cast({policy_request, Sock, {ClientIp, ClientPort}, #sdl_policy_request{c
maybe
{ok, #endpoint{client_id = ClientId, session_token = ST}} ?= maps:find(Mac, Endpoints),
%% todo
Bin = <<1, 80:16, 2, 9090:16>>,
RulesBin = iolist_to_binary(lists:map(fun(_Id) -> Bin end, lists:seq(1, 1000))),
case byte_size(RulesBin) > 1200 of
true ->
%%
Groups = chunk_rules(RulesBin, 1200),
logger:debug("[sdlan_network] policy_response, groups: ~p", [Groups]),
TotalNum = length(Groups),
Fragments = lists:zip(lists:seq(0, TotalNum - 1), Groups),
lists:foreach(fun({Idx, ChunkRulesBin}) ->
[begin
FragmentPolicyResponse = sdlan_pb:encode_msg(#sdl_policy_response {
network_id = NetworkId,
src_identity_id = SrcIdentityId,
@ -420,9 +420,8 @@ handle_cast({policy_request, Sock, {ClientIp, ClientPort}, #sdl_policy_request{c
rules = ChunkRulesBin
}),
FragmentPolicyResponsePkt = <<?PACKET_POLICY_RESPONSE, FragmentPolicyResponse/binary>>,
logger:debug("[sdlan_network] will send policy response: ~p", [FragmentPolicyResponsePkt]),
gen_udp:send(Sock, ClientIp, ClientPort, FragmentPolicyResponsePkt)
end, Fragments);
end || {Idx, ChunkRulesBin} <- Fragments];
false ->
%% 1200
PolicyResponse = sdlan_pb:encode_msg(#sdl_policy_response {