add some helper structs

This commit is contained in:
ginuerzh
2022-08-23 21:46:27 +08:00
parent 2cc1d6f52c
commit ff51aef518
4 changed files with 61 additions and 1 deletions

View File

@ -5,3 +5,22 @@ type Bypass interface {
// Contains reports whether the bypass includes addr.
Contains(addr string) bool
}
type bypassList struct {
bypasses []Bypass
}
func BypassList(bypasses ...Bypass) Bypass {
return &bypassList{
bypasses: bypasses,
}
}
func (p *bypassList) Contains(addr string) bool {
for _, bypass := range p.bypasses {
if bypass != nil && bypass.Contains(addr) {
return true
}
}
return false
}