mirror of
https://github.com/catspace-dev/unicheckbot.git
synced 2024-11-21 21:46:32 +03:00
added patched app
This commit is contained in:
parent
6023e35742
commit
761991eae6
|
@ -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__)
|
||||
|
|
11
apps/api/api/checkers/tcp_port.py
Normal file
11
apps/api/api/checkers/tcp_port.py
Normal file
|
@ -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
|
4
apps/api/api/patched.py
Normal file
4
apps/api/api/patched.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
from gevent import monkey
|
||||
monkey.patch_all()
|
||||
|
||||
from api.app import app
|
|
@ -14,6 +14,8 @@ class ResponseStatus(str, Enum):
|
|||
class ErrorCodes(IntEnum):
|
||||
ConnectError = 1
|
||||
ICMPHostNotAlive = 2
|
||||
TCPPortClosed = 3
|
||||
UDPPortClosed = 4
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -12,12 +12,6 @@ icmp_help_message = """
|
|||
`/icmp <target>`
|
||||
"""
|
||||
|
||||
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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user