summaryrefslogtreecommitdiffstats
path: root/tv/3modules/iptables.nix
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2016-02-18 17:07:49 +0100
committerlassulus <lass@aidsballs.de>2016-02-18 17:07:49 +0100
commitb7e4fa76513f07674e6a32a706e0ffa9fca3e897 (patch)
treee1a1936c53a608b2e1fd4f401fbb127f8055ad1f /tv/3modules/iptables.nix
parent97798eb4ede9a121092229b2f9ab68800b0ae866 (diff)
parent482180639dcf6064f0b249aeb350347f6e8e461f (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'tv/3modules/iptables.nix')
-rw-r--r--tv/3modules/iptables.nix22
1 files changed, 22 insertions, 0 deletions
diff --git a/tv/3modules/iptables.nix b/tv/3modules/iptables.nix
index c0fd7ec..c0e71f2 100644
--- a/tv/3modules/iptables.nix
+++ b/tv/3modules/iptables.nix
@@ -26,6 +26,21 @@ let
type = with types; listOf (either int str);
default = [];
};
+
+ extra = {
+ nat.POSTROUTING = mkOption {
+ type = with types; listOf str;
+ default = [];
+ };
+ filter.FORWARD = mkOption {
+ type = with types; listOf str;
+ default = [];
+ };
+ filter.INPUT = mkOption {
+ type = with types; listOf str;
+ default = [];
+ };
+ };
};
imp = {
@@ -57,6 +72,11 @@ let
};
};
+ formatTable = table:
+ (concatStringsSep "\n"
+ (mapAttrsToList
+ (chain: concatMapStringsSep "\n" (rule: "-A ${chain} ${rule}"))
+ table));
rules = iptables-version: let
accept-echo-request = {
@@ -79,6 +99,7 @@ let
${concatMapStringsSep "\n" (rule: "-A OUTPUT ${rule}") [
"-o lo -p tcp -m tcp --dport 11423 -j REDIRECT --to-ports 22"
]}
+ ${formatTable cfg.extra.nat}
COMMIT
*filter
:INPUT DROP [0:0]
@@ -94,6 +115,7 @@ let
++ map accept-new-tcp (unique (map toString cfg.input-internet-accept-new-tcp))
++ ["-i retiolum -j Retiolum"]
)}
+ ${formatTable cfg.extra.filter}
${concatMapStringsSep "\n" (rule: "-A Retiolum ${rule}") ([]
++ optional (cfg.accept-echo-request == "retiolum") accept-echo-request
++ map accept-new-tcp (unique (map toString cfg.input-retiolum-accept-new-tcp))