Fix imports and validation call

This commit is contained in:
Darryl Nixon 2023-06-30 11:49:18 -07:00
parent 5efb10ce98
commit d4d9147b23
2 changed files with 6 additions and 6 deletions

View file

@ -2,7 +2,7 @@ import os
import iptc import iptc
from net_queue import NetQueue from .net_queue import NetQueue
def is_root(): def is_root():

View file

@ -7,8 +7,8 @@ from typing import Union
import iptc import iptc
from utils.logger import logger from .utils.logger import logger
from utils.lookup import Protocols from .utils.lookup import Protocols
class NetQueue: class NetQueue:
@ -30,7 +30,7 @@ class NetQueue:
self.dst_ip = self.validate_ip(dst_ip, "destination") self.dst_ip = self.validate_ip(dst_ip, "destination")
self.protocol = self.validate_protocol(protocol) self.protocol = self.validate_protocol(protocol)
self.queue = self.validate_queue(queue, override) self.queue = self._validate_queue(queue, override)
self.rule = self._create_rule() self.rule = self._create_rule()
def _create_rule(self) -> iptc.Rule: def _create_rule(self) -> iptc.Rule:
@ -72,14 +72,14 @@ class NetQueue:
return ip return ip
@staticmethod @staticmethod
def validate_port(port: Optional[int], description: str) -> Union(int, None): def validate_port(port: Optional[int], description: str) -> Union[int, None]:
if port: if port:
if not 0 <= port <= 65535: if not 0 <= port <= 65535:
raise ValueError(f"Invalid {description} port: {port}") raise ValueError(f"Invalid {description} port: {port}")
return port return port
@staticmethod @staticmethod
def validate_protocol(protocol: Optional[str]) -> Union(str, None): def validate_protocol(protocol: Optional[str]) -> Union[str, None]:
if protocol: if protocol:
try: try:
Protocols(protocol) Protocols(protocol)