diff --git a/apps/api/api/app.py b/apps/api/api/app.py index 77724ce..62a04f3 100644 --- a/apps/api/api/app.py +++ b/apps/api/api/app.py @@ -1,11 +1,8 @@ from flask import Flask, request, abort, jsonify from gevent.pywsgi import WSGIServer -from gevent import monkey from helpers import access_token_required import config -monkey.patch_all() -# Monkey patch SSL in requests to prevent RecursionError! DO NOT REMOVE OR MOVE! from checkers import HttpChecker, ICMPChecker app = Flask(__name__) diff --git a/apps/api/api/checkers/tcp_port.py b/apps/api/api/checkers/tcp_port.py new file mode 100644 index 0000000..4efc487 --- /dev/null +++ b/apps/api/api/checkers/tcp_port.py @@ -0,0 +1,11 @@ +from core.coretypes import Response +from .base import BaseChecker + + +class TCPPortChecker(BaseChecker): + + def __init__(self, target: str): + super().__init__(target) + + def check(self) -> Response: + pass diff --git a/apps/api/api/patched.py b/apps/api/api/patched.py new file mode 100644 index 0000000..c242a85 --- /dev/null +++ b/apps/api/api/patched.py @@ -0,0 +1,4 @@ +from gevent import monkey +monkey.patch_all() + +from api.app import app diff --git a/apps/core/core/coretypes.py b/apps/core/core/coretypes.py index dfa26f8..a8d89dd 100644 --- a/apps/core/core/coretypes.py +++ b/apps/core/core/coretypes.py @@ -14,6 +14,8 @@ class ResponseStatus(str, Enum): class ErrorCodes(IntEnum): ConnectError = 1 ICMPHostNotAlive = 2 + TCPPortClosed = 3 + UDPPortClosed = 4 @dataclass diff --git a/apps/tgbot/tgbot/handlers/default/__init__.py b/apps/tgbot/tgbot/handlers/default/__init__.py index 2984851..7566142 100644 --- a/apps/tgbot/tgbot/handlers/default/__init__.py +++ b/apps/tgbot/tgbot/handlers/default/__init__.py @@ -4,7 +4,6 @@ from .start import start_cmd from .web import web_cmd from .whois import whois_cmd from .icmp import icmp_cmd -from .inline import inline_processor def setup(dp: Dispatcher): @@ -12,4 +11,3 @@ def setup(dp: Dispatcher): dp.register_message_handler(web_cmd, commands=['web', 'http']) dp.register_message_handler(whois_cmd, commands=['whois']) dp.register_message_handler(icmp_cmd, commands=['icmp']) - dp.register_inline_handler(inline_processor) diff --git a/apps/tgbot/tgbot/handlers/default/icmp.py b/apps/tgbot/tgbot/handlers/default/icmp.py index d890f32..a99d49e 100644 --- a/apps/tgbot/tgbot/handlers/default/icmp.py +++ b/apps/tgbot/tgbot/handlers/default/icmp.py @@ -12,12 +12,6 @@ icmp_help_message = """ `/icmp ` """ -no_icmp_text = """ -❗Не указана цель для пингования. - -Напишите /icmp чтобы посмотреть справку. -""" - async def prepare_icmp_check_result(res: Response): node = APINodeInfo(**res.json().get("node", None)) @@ -52,7 +46,7 @@ async def check_icmp(msg: Message, target: str): async def icmp_cmd(msg: Message): args = msg.text.split(" ") if len(args) == 1: - return await msg.answer(no_icmp_text) + return await msg.answer(icmp_help_message, parse_mode="Markdown") if len(args) >= 2: target = args[1] await check_icmp(msg, target) diff --git a/apps/tgbot/tgbot/handlers/default/web.py b/apps/tgbot/tgbot/handlers/default/web.py index 96f3ff1..032a740 100644 --- a/apps/tgbot/tgbot/handlers/default/web.py +++ b/apps/tgbot/tgbot/handlers/default/web.py @@ -2,7 +2,7 @@ from aiogram.types import Message from typing import Optional from tgbot.handlers.helpers import check_int from tgbot.nodes import nodes as all_nodes -from httpx import AsyncClient, Response +from httpx import Response from core.coretypes import ResponseStatus, HTTP_EMOJI from datetime import datetime from ..helpers import send_api_requests