mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-24 23:58:17 +03:00
ef88f7462f
Updates #6233.
Squashed commit of the following:
commit 308754d9cfc24005352bae6db420ad8a5ccde3eb
Merge: 8289df04f 5d7e59e37
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Fri Oct 6 13:04:13 2023 +0300
Merge branch 'master' into 6233-imp-ipset
commit 8289df04f1827e28ea481e6880ceb72d4036dd4f
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Oct 5 19:53:53 2023 +0300
ipset: imp naming
commit b24ddd547128db58dcba1a0bf153398db8d9b71c
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Oct 5 19:16:40 2023 +0300
all: imp ipset
33 lines
873 B
Go
33 lines
873 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 is of type
|
|
// *aghos.UnsupportedError if the OS is not supported.
|
|
func NewManager(ipsetConf []string) (mgr Manager, err error) {
|
|
if len(ipsetConf) == 0 {
|
|
return nil, nil
|
|
}
|
|
|
|
return newManager(ipsetConf)
|
|
}
|