Refactor gatePolicy to gateRule

This commit is contained in:
Theodor S. Midtlien
2026-09-03 12:27:36 +02:00
parent d03b8b3a92
commit 70f075806b
4 changed files with 47 additions and 40 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ type program struct {
jsonServMu sync.Mutex
serverInstance *server.Server
serverInstanceMu sync.Mutex
policyGate *ipcauth.PolicyGate
ruleGate *ipcauth.RuleGate
}
func init() {
+4 -4
View File
@@ -80,12 +80,12 @@ func (p *program) Start(svc service.Service) error {
return fmt.Errorf("parse daemon address: %w", err)
}
p.policyGate = ipcauth.NewPolicyGate()
p.ruleGate = ipcauth.NewRuleGate()
// in any case, even if configuration does not exists we run daemon to serve CLI gRPC API.
opts := append(daemonServerOptions(network),
grpc.ChainUnaryInterceptor(p.policyGate.UnaryPolicyInterceptor()),
grpc.ChainStreamInterceptor(p.policyGate.StreamPolicyInterceptor()),
grpc.ChainUnaryInterceptor(p.ruleGate.UnaryPolicyInterceptor()),
grpc.ChainStreamInterceptor(p.ruleGate.StreamPolicyInterceptor()),
)
p.serv = grpc.NewServer(opts...)
@@ -151,7 +151,7 @@ func (p *program) serve(daemonListener, jsonListener *socketListener) error {
}
serverInstance := server.New(p.ctx, util.FindFirstLogPath(logFiles), configPath, profilesDisabled, updateSettingsDisabled, captureEnabled, networksDisabled)
p.policyGate.SetPolicy(serverInstance)
p.ruleGate.SetState(serverInstance)
if err := serverInstance.Start(); err != nil {
return fmt.Errorf("start daemon: %w", err)
}