tunnel-manager 0.0.5__py3-none-any.whl → 1.0.0__py3-none-any.whl
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.
Potentially problematic release.
This version of tunnel-manager might be problematic. Click here for more details.
- tests/test_tunnel.py +78 -0
- tunnel_manager/__init__.py +22 -7
- tunnel_manager/tunnel_manager.py +770 -69
- tunnel_manager/tunnel_manager_mcp.py +1478 -151
- tunnel_manager-1.0.0.dist-info/METADATA +391 -0
- tunnel_manager-1.0.0.dist-info/RECORD +11 -0
- {tunnel_manager-0.0.5.dist-info → tunnel_manager-1.0.0.dist-info}/entry_points.txt +1 -0
- {tunnel_manager-0.0.5.dist-info → tunnel_manager-1.0.0.dist-info}/top_level.txt +1 -0
- tunnel_manager-0.0.5.dist-info/METADATA +0 -190
- tunnel_manager-0.0.5.dist-info/RECORD +0 -10
- {tunnel_manager-0.0.5.dist-info → tunnel_manager-1.0.0.dist-info}/WHEEL +0 -0
- {tunnel_manager-0.0.5.dist-info → tunnel_manager-1.0.0.dist-info}/licenses/LICENSE +0 -0
tests/test_tunnel.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from tunnel_manager.tunnel_manager import Tunnel
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
username = os.environ.get("TUNNEL_USERNAME")
|
|
6
|
+
password = os.environ.get("TUNNEL_PASSWORD")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_password_authentication():
|
|
10
|
+
print("Testing password-based authentication...")
|
|
11
|
+
try:
|
|
12
|
+
# Initialize tunnel with username and password
|
|
13
|
+
tunnel = Tunnel(
|
|
14
|
+
remote_host="10.0.0.11",
|
|
15
|
+
username=username,
|
|
16
|
+
password=password,
|
|
17
|
+
log_file="tunnel_password.log",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# Connect to the remote host
|
|
21
|
+
tunnel.connect()
|
|
22
|
+
|
|
23
|
+
# Run a simple command
|
|
24
|
+
out, err = tunnel.run_command("whoami; cd ~/Development/; ls -la")
|
|
25
|
+
print(f"Command 'whoami' output: {out}")
|
|
26
|
+
if err:
|
|
27
|
+
print(f"Command error: {err}")
|
|
28
|
+
|
|
29
|
+
print(f"Command output: {out}")
|
|
30
|
+
# Example file transfer (uncomment to test, ensure files exist)
|
|
31
|
+
tunnel.send_file(
|
|
32
|
+
"./tests/local_test.txt", "/home/genius/Downloads/remote_test.txt"
|
|
33
|
+
)
|
|
34
|
+
tunnel.receive_file(
|
|
35
|
+
"/home/genius/Downloads/remote_test.txt", "./tests/downloaded_test.txt"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
tunnel.close()
|
|
39
|
+
print("Password-based authentication test completed successfully.")
|
|
40
|
+
except Exception as e:
|
|
41
|
+
print(f"Password-based authentication test failed: {str(e)}")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_key_authentication():
|
|
45
|
+
print("\nTesting key-based authentication...")
|
|
46
|
+
try:
|
|
47
|
+
# Initialize tunnel with identity file
|
|
48
|
+
tunnel = Tunnel(
|
|
49
|
+
remote_host="10.0.0.11",
|
|
50
|
+
username=username,
|
|
51
|
+
identity_file=os.path.expanduser("~/.ssh/id_rsa"),
|
|
52
|
+
log_file="tunnel_key.log",
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# Connect to the remote host
|
|
56
|
+
tunnel.connect()
|
|
57
|
+
|
|
58
|
+
# Run a simple command
|
|
59
|
+
out, err = tunnel.run_command("whoami")
|
|
60
|
+
print(f"Command 'whoami' output: {out}")
|
|
61
|
+
if err:
|
|
62
|
+
print(f"Command error: {err}")
|
|
63
|
+
|
|
64
|
+
# Example file transfer (uncomment to test, ensure files exist)
|
|
65
|
+
# tunnel.send_file("local_test.txt", "/home/genius/remote_test.txt")
|
|
66
|
+
# tunnel.receive_file("/home/genius/remote_test.txt", "downloaded_test.txt")
|
|
67
|
+
|
|
68
|
+
tunnel.close()
|
|
69
|
+
print("Key-based authentication test completed successfully.")
|
|
70
|
+
except Exception as e:
|
|
71
|
+
print(f"Key-based authentication test failed: {str(e)}")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
if __name__ == "__main__":
|
|
75
|
+
print("Starting SSH Tunnel Tests\n")
|
|
76
|
+
test_password_authentication()
|
|
77
|
+
test_key_authentication()
|
|
78
|
+
print("\nAll tests completed.")
|
tunnel_manager/__init__.py
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# coding: utf-8
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import importlib
|
|
5
|
+
import inspect
|
|
6
|
+
|
|
7
|
+
# List of modules to import from
|
|
8
|
+
MODULES = [
|
|
9
|
+
"tunnel_manager.tunnel_manager",
|
|
10
|
+
"tunnel_manager.tunnel_manager_mcp",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
# Initialize __all__ to expose all public classes and functions
|
|
14
|
+
__all__ = []
|
|
15
|
+
|
|
16
|
+
# Dynamically import all classes and functions from the specified modules
|
|
17
|
+
for module_name in MODULES:
|
|
18
|
+
module = importlib.import_module(module_name)
|
|
19
|
+
for name, obj in inspect.getmembers(module):
|
|
20
|
+
# Include only classes and functions, excluding private (starting with '_')
|
|
21
|
+
if (inspect.isclass(obj) or inspect.isfunction(obj)) and not name.startswith(
|
|
22
|
+
"_"
|
|
23
|
+
):
|
|
24
|
+
globals()[name] = obj
|
|
25
|
+
__all__.append(name)
|
|
8
26
|
|
|
9
27
|
"""
|
|
10
28
|
tunnel-manager
|
|
11
29
|
|
|
12
30
|
Create SSH tunnels to your remote hosts!
|
|
13
31
|
"""
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
__all__ = ["tunnel_manager_mcp", "Tunnel"]
|