diff --git a/admission/admission.go b/admission/admission.go index 8d51fd3..1bb01cd 100644 --- a/admission/admission.go +++ b/admission/admission.go @@ -8,22 +8,3 @@ type Option func(opts *Options) type Admission interface { Admit(ctx context.Context, addr string, opts ...Option) bool } - -type admissionGroup struct { - admissions []Admission -} - -func AdmissionGroup(admissions ...Admission) Admission { - return &admissionGroup{ - admissions: admissions, - } -} - -func (p *admissionGroup) Admit(ctx context.Context, addr string, opts ...Option) bool { - for _, admission := range p.admissions { - if admission != nil && !admission.Admit(ctx, addr, opts...) { - return false - } - } - return true -} diff --git a/auth/auth.go b/auth/auth.go index adfa2b5..846fb19 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -10,29 +10,3 @@ type Option func(opts *Options) type Authenticator interface { Authenticate(ctx context.Context, user, password string, opts ...Option) (id string, ok bool) } - -type authenticatorGroup struct { - authers []Authenticator -} - -func AuthenticatorGroup(authers ...Authenticator) Authenticator { - return &authenticatorGroup{ - authers: authers, - } -} - -func (p *authenticatorGroup) Authenticate(ctx context.Context, user, password string, opts ...Option) (string, bool) { - if len(p.authers) == 0 { - return "", false - } - for _, auther := range p.authers { - if auther == nil { - continue - } - - if id, ok := auther.Authenticate(ctx, user, password, opts...); ok { - return id, ok - } - } - return "", false -} diff --git a/bypass/bypass.go b/bypass/bypass.go index c97f6a0..4651fed 100644 --- a/bypass/bypass.go +++ b/bypass/bypass.go @@ -2,7 +2,6 @@ package bypass import ( "context" - "slices" ) type Options struct { @@ -30,45 +29,3 @@ type Bypass interface { IsWhitelist() bool Contains(ctx context.Context, network, addr string, opts ...Option) bool } - -type bypassGroup struct { - bypasses []Bypass -} - -func BypassGroup(bypasses ...Bypass) Bypass { - return &bypassGroup{ - bypasses: bypasses, - } -} - -func (p *bypassGroup) Contains(ctx context.Context, network, addr string, opts ...Option) bool { - var whitelist, blacklist []bool - for _, bypass := range p.bypasses { - result := bypass.Contains(ctx, network, addr, opts...) - if bypass.IsWhitelist() { - whitelist = append(whitelist, result) - } else { - blacklist = append(blacklist, result) - } - } - status := false - if len(whitelist) > 0 { - if slices.Contains(whitelist, false) { - status = false - } else { - status = true - } - } - if !status && len(blacklist) > 0 { - if slices.Contains(blacklist, true) { - status = true - } else { - status = false - } - } - return status -} - -func (p *bypassGroup) IsWhitelist() bool { - return false -}