mirror of
https://github.com/catspace-dev/unicheckbot.git
synced 2024-11-10 16:36:32 +03:00
Port can be defined as host:port
This commit is contained in:
parent
87771c7505
commit
a54a938c2f
|
@ -103,15 +103,13 @@ class CheckerTargetPortHandler(CheckerBaseHandler):
|
|||
|
||||
|
||||
def process_args_for_host_port(text: str, default_port: int) -> list:
|
||||
port = None
|
||||
args = text.split()
|
||||
if len(args) < 2:
|
||||
port = default_port
|
||||
args = text.split(' ', 1)
|
||||
if len(args) != 2:
|
||||
raise NotEnoughArgs()
|
||||
if len(args) == 2:
|
||||
port = default_port
|
||||
if len(args) == 3:
|
||||
port = args[2]
|
||||
if not check_int(port):
|
||||
raise InvalidPort()
|
||||
host = args[1]
|
||||
if ":" in host:
|
||||
host, port = host.rsplit(":", 1)
|
||||
elif " " in host:
|
||||
host, port = host.rsplit(" ", 1)
|
||||
return [host, port]
|
||||
|
|
|
@ -29,15 +29,18 @@ class TCPCheckerHandler(CheckerTargetPortHandler):
|
|||
await super(TCPCheckerHandler, self).handler(message)
|
||||
|
||||
async def process_args(self, text: str) -> list:
|
||||
port = None
|
||||
args = text.split()
|
||||
if len(args) < 3:
|
||||
args = text.split(' ', 1)
|
||||
if len(args) != 2:
|
||||
raise NotEnoughArgs()
|
||||
if len(args) >= 3:
|
||||
port = args[2]
|
||||
if not check_int(port):
|
||||
raise InvalidPort()
|
||||
host = args[1]
|
||||
if ":" in host:
|
||||
host, port = host.rsplit(":", 1)
|
||||
elif " " in host:
|
||||
host, port = host.split(maxsplit=1)
|
||||
else:
|
||||
raise NotEnoughArgs()
|
||||
if not check_int(port):
|
||||
raise InvalidPort()
|
||||
return [host, port]
|
||||
|
||||
async def prepare_message(self, res: Response):
|
||||
|
|
Loading…
Reference in New Issue
Block a user