fix panic for nil pointer

This commit is contained in:
ginuerzh
2025-08-13 21:24:05 +08:00
parent 0e5c285eb7
commit d0ff5358df
4 changed files with 24 additions and 6 deletions
+5 -3
View File
@@ -89,9 +89,11 @@ func NewAdmission(opts ...Option) admission.Admission {
ctx, cancel := context.WithCancel(context.Background())
p := &localAdmission{
cancelFunc: cancel,
options: options,
logger: options.logger,
ipMatcher: matcher.NopMatcher(),
cidrMatcher: matcher.NopMatcher(),
cancelFunc: cancel,
options: options,
logger: options.logger,
}
if p.logger == nil {
p.logger = xlogger.Nop()
+7 -3
View File
@@ -100,9 +100,13 @@ func NewBypass(opts ...Option) bypass.Bypass {
ctx, cancel := context.WithCancel(context.Background())
p := &localBypass{
cancelFunc: cancel,
options: options,
logger: options.logger,
cidrMatcher: matcher.NopMatcher(),
addrMatcher: matcher.NopMatcher(),
wildcardMatcher: matcher.NopMatcher(),
ipRangeMatcher: matcher.NopMatcher(),
cancelFunc: cancel,
options: options,
logger: options.logger,
}
if p.logger == nil {
p.logger = xlogger.Nop()
+1
View File
@@ -80,6 +80,7 @@ func NewIngress(opts ...Option) ingress.Ingress {
ctx, cancel := context.WithCancel(context.TODO())
ing := &localIngress{
rules: make(map[string]*ingress.Rule),
cancelFunc: cancel,
options: options,
logger: options.logger,
+11
View File
@@ -259,3 +259,14 @@ func (m *ipRangeMatcher) Match(addr string) bool {
}
return false
}
type nopMatcher struct {
}
func NopMatcher() Matcher {
return &nopMatcher{}
}
func (m *nopMatcher) Match(addr string) bool {
return false
}