mirror of
https://github.com/anten-ka/kaskad-pro.git
synced 2026-05-19 17:46:03 +00:00
Remove debug scripts
Made-with: Cursor
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
import paramiko, sys
|
||||
|
||||
host = "185.250.47.205"
|
||||
user = "root"
|
||||
pwd = "0i1sbf9NM36FkG5dFH"
|
||||
|
||||
def run(cmd, timeout=30):
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect(host, username=user, password=pwd, timeout=10)
|
||||
stdin, stdout, stderr = ssh.exec_command(cmd, timeout=timeout)
|
||||
out = stdout.read().decode(errors="replace")
|
||||
err = stderr.read().decode(errors="replace")
|
||||
rc = stdout.channel.recv_exit_status()
|
||||
ssh.close()
|
||||
return rc, out, err
|
||||
|
||||
if __name__ == "__main__":
|
||||
cmd = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else "echo ok"
|
||||
rc, out, err = run(cmd)
|
||||
if out: print(out, end="")
|
||||
if err: print("STDERR:", err, end="")
|
||||
print(f"\n[exit {rc}]")
|
||||
@@ -1,58 +0,0 @@
|
||||
import paramiko
|
||||
|
||||
host = "185.250.47.205"
|
||||
user = "root"
|
||||
pwd = "0i1sbf9NM36FkG5dFH"
|
||||
|
||||
test_script = """#!/bin/bash
|
||||
tcp_ping() {
|
||||
local ip="$1" port="$2" tout="${3:-3}"
|
||||
local raw
|
||||
raw=$(curl -so /dev/null -w '%{time_connect}' --max-time "$tout" --connect-timeout "$tout" "http://${ip}:${port}/" 2>/dev/null)
|
||||
[ -z "$raw" ] && return 1
|
||||
local ms
|
||||
ms=$(awk "BEGIN {v=$raw*1000; if(v<0.5) exit 1; printf \\"%.2f\\", v}" 2>/dev/null) || return 1
|
||||
echo "$ms"
|
||||
}
|
||||
|
||||
smart_ping() {
|
||||
local ip="$1" tout="${2:-3}" port="${3:-}"
|
||||
local ms
|
||||
ms=$(ping -c 1 -W "$tout" "$ip" 2>/dev/null | sed -n 's/.*time=\\([0-9.]*\\).*/\\1/p')
|
||||
if [ -n "$ms" ]; then echo "ICMP: ${ms}ms"; return 0; fi
|
||||
[ -z "$port" ] && { echo "NO_PORT"; return 1; }
|
||||
ms=$(tcp_ping "$ip" "$port" "$tout")
|
||||
if [ -n "$ms" ]; then echo "TCP: ${ms}ms"; return 0; fi
|
||||
echo "TIMEOUT"
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "=== Test 1: ICMP to 8.8.8.8 ==="
|
||||
smart_ping "8.8.8.8" 3
|
||||
|
||||
echo "=== Test 2: ICMP to 193.124.225.26 (no port) ==="
|
||||
smart_ping "193.124.225.26" 3
|
||||
|
||||
echo "=== Test 3: smart_ping 193.124.225.26 TCP:443 ==="
|
||||
smart_ping "193.124.225.26" 3 "443"
|
||||
|
||||
echo "=== Test 4: tcp_ping raw ==="
|
||||
result=$(tcp_ping "193.124.225.26" "443" 3)
|
||||
echo "result=$result rc=$?"
|
||||
"""
|
||||
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect(host, username=user, password=pwd, timeout=10)
|
||||
|
||||
sftp = ssh.open_sftp()
|
||||
with sftp.file("/tmp/_kaskad_test.sh", "w") as f:
|
||||
f.write(test_script)
|
||||
sftp.close()
|
||||
|
||||
stdin, stdout, stderr = ssh.exec_command("bash /tmp/_kaskad_test.sh", timeout=30)
|
||||
print(stdout.read().decode(errors="replace"))
|
||||
err = stderr.read().decode(errors="replace")
|
||||
if err:
|
||||
print("STDERR:", err)
|
||||
ssh.close()
|
||||
Reference in New Issue
Block a user