mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-25 08:08:18 +03:00
dd7bf61323
Updates #4027. Squashed commit of the following: commit 9ac0cc27ca94e630cc321c90b60b271499af4d9b Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Dec 27 20:26:22 2021 +0300 aghnet: fix ipset init errors
31 lines
844 B
Go
31 lines
844 B
Go
package aghnet
|
|
|
|
import (
|
|
"net"
|
|
)
|
|
|
|
// IpsetManager is the ipset manager interface.
|
|
//
|
|
// TODO(a.garipov): Perhaps generalize this into some kind of a NetFilter type,
|
|
// since ipset is exclusive to Linux?
|
|
type IpsetManager interface {
|
|
Add(host string, ip4s, ip6s []net.IP) (n int, err error)
|
|
Close() (err error)
|
|
}
|
|
|
|
// NewIpsetManager returns a new ipset. IPv4 addresses are added to an ipset
|
|
// with an ipv4 family; IPv6 addresses, to an ipv6 ipset. ipset must exist.
|
|
//
|
|
// The syntax of the ipsetConf is:
|
|
//
|
|
// DOMAIN[,DOMAIN].../IPSET_NAME[,IPSET_NAME]...
|
|
//
|
|
// If ipsetConf is empty, msg and err are nil. The error is of type
|
|
// *aghos.UnsupportedError if the OS is not supported.
|
|
func NewIpsetManager(ipsetConf []string) (mgr IpsetManager, err error) {
|
|
if len(ipsetConf) == 0 {
|
|
return nil, nil
|
|
}
|
|
|
|
return newIpsetMgr(ipsetConf)
|
|
}
|