Implement client side ACL for SOCKS5 TCP

This commit is contained in:
Toby
2020-04-26 14:58:50 -07:00
parent ee8558f2fb
commit 127e9e1b6c
8 changed files with 232 additions and 77 deletions

View File

@@ -25,13 +25,10 @@ type Entry struct {
ActionArg string
}
func (e Entry) Match(domain string, ip net.IP) bool {
func (e Entry) MatchDomain(domain string) bool {
if e.All {
return true
}
if e.Net != nil && ip != nil {
return e.Net.Contains(ip)
}
if len(e.Domain) > 0 && len(domain) > 0 {
ld := strings.ToLower(domain)
if e.Suffix {
@@ -43,6 +40,30 @@ func (e Entry) Match(domain string, ip net.IP) bool {
return false
}
func (e Entry) MatchIP(ip net.IP) bool {
if e.All {
return true
}
if e.Net != nil && ip != nil {
return e.Net.Contains(ip)
}
return false
}
func (e Entry) MatchIPs(ips []net.IP) bool {
if e.All {
return true
}
if e.Net != nil && len(ips) > 0 {
for _, ip := range ips {
if e.Net.Contains(ip) {
return true
}
}
}
return false
}
// Format: action cond_type cond arg
// Examples:
// proxy domain-suffix google.com