mirror of
https://github.com/DarrylNixon/drawbridge
synced 2024-04-22 12:17:07 -07:00
Fix imports and validation call
This commit is contained in:
parent
5efb10ce98
commit
d4d9147b23
2 changed files with 6 additions and 6 deletions
|
@ -2,7 +2,7 @@ import os
|
|||
|
||||
import iptc
|
||||
|
||||
from net_queue import NetQueue
|
||||
from .net_queue import NetQueue
|
||||
|
||||
|
||||
def is_root():
|
||||
|
|
|
@ -7,8 +7,8 @@ from typing import Union
|
|||
|
||||
import iptc
|
||||
|
||||
from utils.logger import logger
|
||||
from utils.lookup import Protocols
|
||||
from .utils.logger import logger
|
||||
from .utils.lookup import Protocols
|
||||
|
||||
|
||||
class NetQueue:
|
||||
|
@ -30,7 +30,7 @@ class NetQueue:
|
|||
self.dst_ip = self.validate_ip(dst_ip, "destination")
|
||||
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()
|
||||
|
||||
def _create_rule(self) -> iptc.Rule:
|
||||
|
@ -72,14 +72,14 @@ class NetQueue:
|
|||
return ip
|
||||
|
||||
@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 not 0 <= port <= 65535:
|
||||
raise ValueError(f"Invalid {description} port: {port}")
|
||||
return port
|
||||
|
||||
@staticmethod
|
||||
def validate_protocol(protocol: Optional[str]) -> Union(str, None):
|
||||
def validate_protocol(protocol: Optional[str]) -> Union[str, None]:
|
||||
if protocol:
|
||||
try:
|
||||
Protocols(protocol)
|
||||
|
|
Loading…
Reference in a new issue