java.lang.Object
com.aoindustries.aoserv.daemon.iptables.Ipset
Handles access to ipset.
- Author:
- AO Industries, Inc.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
ipset has a global namespace.static enum
-
Field Summary
Modifier and TypeFieldDescriptionstatic final short
static final int
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Callsipset -A
.static void
create
(String setName, Ipset.SetType setType, String... options) Callsipset -N
.static void
Callsipset -D
.static void
Parses an ipset save file, returning the mutable set of IP addresses in order dumped.static String
Callsipset -S
, skipping any comment lines.static void
synchronize
(Set<Integer> entries, short networkPrefix, String setName, PosixFile setDir) Synchronizes a single set to the expected entries, both in-kernel and on-disk versions.
-
Field Details
-
MAX_IPSET_SIZE
public static final int MAX_IPSET_SIZE- See Also:
-
HOST_NETWORK_PREFIX
public static final short HOST_NETWORK_PREFIX- See Also:
-
-
Method Details
-
save
Callsipset -S
, skipping any comment lines.- Parameters:
setName
- the name of the setmissingAsNull
- when true, a missing set will be returned as null, otherwise will throw an exception- Throws:
IOException
-
create
public static void create(String setName, Ipset.SetType setType, String... options) throws IOException Callsipset -N
.- Throws:
IOException
-
delete
Callsipset -D
.- Throws:
IOException
-
add
Callsipset -A
.- Throws:
IOException
-
parse
Parses an ipset save file, returning the mutable set of IP addresses in order dumped.- Throws:
IOException
-
synchronize
public static void synchronize(Set<Integer> entries, short networkPrefix, String setName, PosixFile setDir) throws IOException Synchronizes a single set to the expected entries, both in-kernel and on-disk versions. Creates set in kernel if missing. Adds/removes any necessary changes. Updates on-disk only if missing or set modified.- Parameters:
entries
- the ip or network entries, only the firstMAX_IPSET_SIZE
entries will be usednetworkPrefix
- the network prefix orHOST_NETWORK_PREFIX
for individual hostssetName
- the set name used both in-kernel and on-disksetDir
- the directory that stores the on-disk version- Throws:
IOException
-