AdGuardHome/internal/aghnet/ipset.go
Ainar Garipov a9127c4a45 Pull request: upd-fmt
Merge in DNS/adguard-home from upd-fmt to master

Squashed commit of the following:

commit 73d9a71feccd8256841ae5a01e4a6aae0bcb2f65
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Aug 31 18:37:39 2022 +0300

    all: upd fmt
2022-08-31 18:57:02 +03:00

31 lines
842 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)
}