Skip to content

Commit

Permalink
Merge pull request #187 from AirportR/dev
Browse files Browse the repository at this point in the history
🐛 Fixed ssh.py
  • Loading branch information
AirportR authored Apr 4, 2024
2 parents e6a0328 + 60c3aae commit b4a1fe7
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions addons/builtin/ssh22.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import asyncio

import socket

import async_timeout
import socks
import aiohttp
from loguru import logger
Expand Down Expand Up @@ -51,21 +53,21 @@ async def check():
mysocket.set_proxy(socks.PROXY_TYPE_SOCKS5, addr=paddr, port=pport)

mysocket.settimeout(10)
mysocket.connect((_host, _sport))
reader, writer = await asyncio.open_connection(sock=mysocket)

# a = mysocket.recv(1024)
a = await reader.read(1024)
if a:
writer.close()
await writer.wait_closed()
if b"ssh" in a or b"SSH" in a:
collector.info['ssh'] = "允许访问"

async with async_timeout.timeout(10):
mysocket.connect((_host, _sport))
reader, writer = await asyncio.open_connection(sock=mysocket)
a = await reader.read(1024)
if a:
writer.close()
await writer.wait_closed()
if b"ssh" in a or b"SSH" in a:
collector.info['ssh'] = "允许访问"
else:
collector.info['ssh'] = "-"
else:
collector.info['ssh'] = "-"
else:
collector.info['ssh'] = "无法访问"
return True
collector.info['ssh'] = "无法访问"
return True

try:
res = await check()
Expand Down

0 comments on commit b4a1fe7

Please sign in to comment.