summaryrefslogtreecommitdiff
path: root/kvmd/apps/otgnet/netctl.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2021-02-16 08:10:10 +0300
committerDevaev Maxim <[email protected]>2021-02-16 08:10:10 +0300
commit70fb46d4287e33d34dbf72156372a5c55cb273f7 (patch)
tree6ba474f01872e74fdcaf3d5a8a6d996e89d832ad /kvmd/apps/otgnet/netctl.py
parentecdc65ceb33d3c4f7809b9c7879a717be09771c2 (diff)
otgnet forwarding
Diffstat (limited to 'kvmd/apps/otgnet/netctl.py')
-rw-r--r--kvmd/apps/otgnet/netctl.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/kvmd/apps/otgnet/netctl.py b/kvmd/apps/otgnet/netctl.py
index 4d838513..59dca782 100644
--- a/kvmd/apps/otgnet/netctl.py
+++ b/kvmd/apps/otgnet/netctl.py
@@ -85,6 +85,33 @@ class IptablesAllowPortCtl(BaseCtl):
]
+class IptablesForwardOut(BaseCtl):
+ def __init__(self, base_cmd: List[str], iface: str) -> None:
+ self.__base_cmd = base_cmd
+ self.__iface = iface
+
+ def get_command(self, direct: bool) -> List[str]:
+ return [
+ *self.__base_cmd,
+ "--table", "nat",
+ ("-A" if direct else "-D"), "POSTROUTING",
+ "-o", self.__iface, "-j", "MASQUERADE",
+ ]
+
+
+class IptablesForwardIn(BaseCtl):
+ def __init__(self, base_cmd: List[str], iface: str) -> None:
+ self.__base_cmd = base_cmd
+ self.__iface = iface
+
+ def get_command(self, direct: bool) -> List[str]:
+ return [
+ *self.__base_cmd,
+ ("-A" if direct else "-D"), "FORWARD",
+ "-i", self.__iface, "-j", "ACCEPT",
+ ]
+
+
class CustomCtl(BaseCtl):
def __init__(
self,