diff options
Diffstat (limited to 'kvmd/apps/otgnet/netctl.py')
-rw-r--r-- | kvmd/apps/otgnet/netctl.py | 27 |
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, |