Add enum for chain names
@@ -10,25 +10,35 @@ public class IpTables {
private static final String COMMAND = "ip6tables";
public static String[] allowFromAddress(String ipAddress) {
- return new String[]{COMMAND, "-A", "INPUT", "-s", ipAddress, "-j", "ACCEPT"};
+ return new String[]{COMMAND, "-A", Chain.INPUT.name, "-s", ipAddress, "-j", Action.ACCEPT.target};
}
- public static String[] chainPolicy(Policy policy) {
- return new String[]{COMMAND, "-P", "INPUT", policy.target};
+ public static String[] chainPolicy(Action action) {
+ return new String[]{COMMAND, "-P", Chain.INPUT.name, action.target};
}
public static String[] flushChain() {
- return new String[]{COMMAND, "-F", "INPUT"};
+ return new String[]{COMMAND, "-F", Chain.INPUT.name};
}
- public enum Policy {
+ public enum Action {
DROP("DROP"),
ACCEPT("ACCEPT");
private final String target;
- Policy(String target) {
+ Action(String target) {
this.target = target;
}
}
+
+ public enum Chain {
+ INPUT("INPUT");
+
+ private final String name;
+
+ Chain(String name) {
+ this.name = name;
+ }
+ }
}
