vssh 3.6.7__tar.gz → 3.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vssh-3.6.7/vssh.egg-info → vssh-3.7.0}/PKG-INFO +1 -1
- {vssh-3.6.7 → vssh-3.7.0}/pyproject.toml +1 -1
- {vssh-3.6.7 → vssh-3.7.0/vssh.egg-info}/PKG-INFO +1 -1
- {vssh-3.6.7 → vssh-3.7.0}/vssh.py +42 -6
- {vssh-3.6.7 → vssh-3.7.0}/LICENSE +0 -0
- {vssh-3.6.7 → vssh-3.7.0}/README.md +0 -0
- {vssh-3.6.7 → vssh-3.7.0}/setup.cfg +0 -0
- {vssh-3.6.7 → vssh-3.7.0}/vssh.egg-info/SOURCES.txt +0 -0
- {vssh-3.6.7 → vssh-3.7.0}/vssh.egg-info/dependency_links.txt +0 -0
- {vssh-3.6.7 → vssh-3.7.0}/vssh.egg-info/entry_points.txt +0 -0
- {vssh-3.6.7 → vssh-3.7.0}/vssh.egg-info/top_level.txt +0 -0
- {vssh-3.6.7 → vssh-3.7.0}/vssh_mcp_server.py +0 -0
- {vssh-3.6.7 → vssh-3.7.0}/vssh_p2p.py +0 -0
|
@@ -159,8 +159,9 @@ def vssh_connect(host: str, timeout: float = 5.0) -> socket.socket:
|
|
|
159
159
|
pass # Timeout — WireGuard may be re-handshaking, retry once
|
|
160
160
|
|
|
161
161
|
if not _wire_refused:
|
|
162
|
-
# Retry: wait
|
|
163
|
-
|
|
162
|
+
# Retry: wait 300ms for WireGuard handshake to complete, then retry
|
|
163
|
+
# (WireGuard handshake typically completes in <200ms; 1s was too slow)
|
|
164
|
+
time.sleep(0.3)
|
|
164
165
|
try:
|
|
165
166
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
166
167
|
sock.settimeout(min(timeout, 5.0)) # 5s: handshake should be done by now
|
|
@@ -527,7 +528,22 @@ def check_transfer_safety(host: str) -> bool:
|
|
|
527
528
|
|
|
528
529
|
|
|
529
530
|
# Wire VPN coordinator servers for name resolution
|
|
530
|
-
|
|
531
|
+
# Dynamically read from /etc/wire/config.json (server_url field)
|
|
532
|
+
# Falls back to hardcoded list only if config is missing
|
|
533
|
+
def _load_wire_servers() -> list:
|
|
534
|
+
import json as _json, re as _re
|
|
535
|
+
try:
|
|
536
|
+
with open("/etc/wire/config.json") as _f:
|
|
537
|
+
_cfg = _json.load(_f)
|
|
538
|
+
_url = _cfg.get("server_url", "")
|
|
539
|
+
_m = _re.match(r'https?://([^:/]+)', _url)
|
|
540
|
+
if _m:
|
|
541
|
+
return [_m.group(1)]
|
|
542
|
+
except (OSError, ValueError, KeyError):
|
|
543
|
+
pass
|
|
544
|
+
return []
|
|
545
|
+
|
|
546
|
+
WIRE_SERVERS = _load_wire_servers()
|
|
531
547
|
_name_cache = {} # name -> vpn_ip
|
|
532
548
|
_name_cache_time = 0
|
|
533
549
|
|
|
@@ -2479,6 +2495,8 @@ def pty_session(host: str, name: str = ''):
|
|
|
2479
2495
|
if not data:
|
|
2480
2496
|
raise EOFError
|
|
2481
2497
|
sock.sendall(data)
|
|
2498
|
+
except BlockingIOError:
|
|
2499
|
+
pass # send buffer full, drop keystroke (rare)
|
|
2482
2500
|
except (EOFError, BrokenPipeError):
|
|
2483
2501
|
raise EOFError
|
|
2484
2502
|
elif r == sock:
|
|
@@ -2500,7 +2518,7 @@ def pty_session(host: str, name: str = ''):
|
|
|
2500
2518
|
if old_settings:
|
|
2501
2519
|
try:
|
|
2502
2520
|
import termios as _termios
|
|
2503
|
-
_termios.tcsetattr(sys.stdin.fileno(), _termios.
|
|
2521
|
+
_termios.tcsetattr(sys.stdin.fileno(), _termios.TCSAFLUSH, old_settings)
|
|
2504
2522
|
except Exception:
|
|
2505
2523
|
pass # safe to ignore
|
|
2506
2524
|
sock.close()
|
|
@@ -4030,9 +4048,27 @@ Env: VSSH_SECRET
|
|
|
4030
4048
|
|
|
4031
4049
|
online = 0
|
|
4032
4050
|
total = 0
|
|
4033
|
-
#
|
|
4051
|
+
# Pre-warm WireGuard tunnels BEFORE status checks.
|
|
4052
|
+
# Fires short-timeout TCP probes to all peers simultaneously → triggers
|
|
4053
|
+
# WireGuard handshakes, then waits 1.2 s for them to finish.
|
|
4054
|
+
# By the time real checks run, all tunnels are warm → zero handshakes
|
|
4055
|
+
# during status → no disruption of the caller's active session.
|
|
4056
|
+
_peer_ips = [ip for ip in _servers.values() if ip and ip != _my_vpn_ip]
|
|
4057
|
+
def _prewarm(ip):
|
|
4058
|
+
try:
|
|
4059
|
+
_pw = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
4060
|
+
_pw.settimeout(0.15)
|
|
4061
|
+
_pw.connect((ip, PORT))
|
|
4062
|
+
_pw.close()
|
|
4063
|
+
except Exception:
|
|
4064
|
+
pass
|
|
4065
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=len(_peer_ips) or 1) as _wp:
|
|
4066
|
+
list(_wp.map(_prewarm, _peer_ips))
|
|
4067
|
+
time.sleep(1.2) # wait for WireGuard handshakes to complete
|
|
4068
|
+
|
|
4069
|
+
# Run checks in parallel for speed — tunnels are warm, no handshakes
|
|
4034
4070
|
results = []
|
|
4035
|
-
with concurrent.futures.ThreadPoolExecutor(max_workers=
|
|
4071
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=14) as pool:
|
|
4036
4072
|
futures = {pool.submit(_check_node, n, ip): n for n, ip in sorted(_servers.items()) if ip}
|
|
4037
4073
|
for f in concurrent.futures.as_completed(futures):
|
|
4038
4074
|
results.append(f.result())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|