fix(telemetry & mesh): align prometheus/grafana compose mounts, add mesh gateway_mode.sh, and enhance file_transfer CLI
This commit is contained in:
1 parent
49d690e316
commit
06211f6959
4 files changed
+43
-3
No files matched your search
@@ -1,14 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Tiny file transfer. Receive: file_transfer.py recv OUT ; Send: file_transfer.py send HOST FILE"""
|
||||
import socket, sys, os
|
||||
|
||||
PORT = 9002
|
||||
|
||||
if len(sys.argv) < 3 or sys.argv[1] not in ("recv", "send"):
|
||||
print("Usage:\n Receive: python3 file_transfer.py recv <output_file>\n Send: python3 file_transfer.py send <host> <input_file>")
|
||||
sys.exit(1)
|
||||
|
||||
if sys.argv[1] == "recv":
|
||||
with socket.socket() as s:
|
||||
s.bind(("0.0.0.0", PORT)); s.listen(1)
|
||||
print(f"[*] Listening for incoming file transfer on port {PORT}...")
|
||||
conn, a = s.accept()
|
||||
with conn, open(os.path.basename(sys.argv[2]), "wb") as f:
|
||||
out_filename = os.path.basename(sys.argv[2])
|
||||
with conn, open(out_filename, "wb") as f:
|
||||
while chunk := conn.recv(65536): f.write(chunk)
|
||||
print("received from", a)
|
||||
print(f"[+] Successfully received file '{out_filename}' from {a}")
|
||||
else:
|
||||
with socket.create_connection((sys.argv[2], PORT)) as s, open(sys.argv[3], "rb") as f:
|
||||
if len(sys.argv) < 4:
|
||||
print("Usage for send: python3 file_transfer.py send <host> <input_file>")
|
||||
sys.exit(1)
|
||||
target_host = sys.argv[2]
|
||||
source_file = sys.argv[3]
|
||||
if not os.path.exists(source_file):
|
||||
print(f"[-] Error: Source file '{source_file}' does not exist.")
|
||||
sys.exit(1)
|
||||
with socket.create_connection((target_host, PORT)) as s, open(source_file, "rb") as f:
|
||||
print(f"[*] Sending '{source_file}' to {target_host}:{PORT}...")
|
||||
while chunk := f.read(65536): s.sendall(chunk)
|
||||
print("[+] File transmission complete.")
|
||||
Reference in new issue
Block a user