mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-25 14:35:48 +03:00
8432593be1
Merge in DNS/adguard-home from AG-33410-aghos-err to master Squashed commit of the following: commit 6014ea1e919ea685475561e4a46284847f67ac99 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Fri Jun 14 08:30:30 2024 +0300 all: imp code commit 232b207d8da42dad297f2730c42e5e84f9049ab9 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Thu Jun 13 12:18:41 2024 +0300 all: rm aghos unsupported err
33 lines
883 B
Go
33 lines
883 B
Go
// Package ipset provides ipset functionality.
|
|
package ipset
|
|
|
|
import (
|
|
"net"
|
|
)
|
|
|
|
// Manager 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 Manager interface {
|
|
Add(host string, ip4s, ip6s []net.IP) (n int, err error)
|
|
Close() (err error)
|
|
}
|
|
|
|
// NewManager returns a new ipset manager. 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's chain contains
|
|
// [errors.ErrUnsupported] if current OS is not supported.
|
|
func NewManager(ipsetConf []string) (mgr Manager, err error) {
|
|
if len(ipsetConf) == 0 {
|
|
return nil, nil
|
|
}
|
|
|
|
return newManager(ipsetConf)
|
|
}
|