fix policy

This commit is contained in:
anlicheng 2026-05-19 23:14:06 +08:00
parent 3ab82a13b5
commit 082fb1547e
4 changed files with 20 additions and 5 deletions

View File

@ -261,7 +261,7 @@ extension SDLContextActor {
await self.handleEvent(event: event) await self.handleEvent(event: event)
case .policyReponse(let policyResponse): case .policyReponse(let policyResponse):
// //
await self.policyService.identifyStore.applyPolicyResponse(policyResponse) await self.policyService.applyPolicyResponse(policyResponse)
case .arpResponse(let arpResponse): case .arpResponse(let arpResponse):
SDLLogger.log("[SDLContext] get arp response: \(arpResponse)") SDLLogger.log("[SDLContext] get arp response: \(arpResponse)")
await self.arpServer.handleArpResponse(arpResponse: arpResponse) await self.arpServer.handleArpResponse(arpResponse: arpResponse)

View File

@ -101,10 +101,8 @@ extension SDLTunPacketRouter.RouteDecision {
switch self { switch self {
case .forwardToNextHop(_, _, _, let kind): case .forwardToNextHop(_, _, _, let kind):
switch kind { switch kind {
case .sameNetwork, .exitNode: case .sameNetwork, .exitNode, .dnsExitNode:
return true return true
case .dnsExitNode:
return false
} }
default: default:
return false return false

View File

@ -80,6 +80,13 @@ actor IdentityStore {
let snapshot = compileSnapshot() let snapshot = compileSnapshot()
publisher.publish(snapshot) publisher.publish(snapshot)
} }
func clear() {
self.coolingDown.removeAll()
self.versions.removeAll()
self.identityMap.removeAll()
self.publisher.publish(IdentitySnapshot.empty())
}
private func compileSnapshot() -> IdentitySnapshot { private func compileSnapshot() -> IdentitySnapshot {
return IdentitySnapshot(identityMap: identityMap) return IdentitySnapshot(identityMap: identityMap)

View File

@ -68,9 +68,19 @@ actor PolicyService {
await superService.send(type: .policyRequest, data: request) await superService.send(type: .policyRequest, data: request)
} }
} }
func applyPolicyResponse(_ policyResponse: SDLPolicyResponse) async {
guard policyResponse.dstIdentityID == self.identityId else {
SDLLogger.log("[PolicyService] ignore policy response, dstIdentityID mismatch: \(policyResponse.dstIdentityID), expected: \(self.identityId)", for: .debug)
return
}
await self.identifyStore.applyPolicyResponse(policyResponse)
}
func clear() { func clear() async {
self.flowSessionManager.clear() self.flowSessionManager.clear()
await self.identifyStore.clear()
} }
deinit { deinit {