neruton 0.2.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.
neruton-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 neruton contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
neruton-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,136 @@
1
+ Metadata-Version: 2.4
2
+ Name: neruton
3
+ Version: 0.2.0
4
+ Summary: Native pure-Python tunnel client & SDK for Neruton (WSS + Yamux HTTP/WebSocket intranet proxy)
5
+ Author: neruton contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/kaecho/neruton
8
+ Project-URL: Repository, https://github.com/kaecho/neruton
9
+ Project-URL: Issues, https://github.com/kaecho/neruton/issues
10
+ Keywords: neruton,tunnel,proxy,yamux,websocket,intranet,reverse-proxy,cloudflared
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Environment :: Web Environment
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Internet :: Proxy Servers
25
+ Classifier: Topic :: Internet :: WWW/HTTP
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Classifier: Typing :: Typed
28
+ Requires-Python: >=3.9
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: websockets>=12.0
32
+ Requires-Dist: tomli>=2.0.1; python_version < "3.11"
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ # neruton (Python SDK & CLI)
38
+
39
+ Native pure-Python tunnel client & SDK for [Neruton](https://github.com/kaecho/neruton) — self-hosted intranet penetration, wildcard subdomain reverse proxy, and WebSocket tunneling over port 443 (`WSS + Yamux`).
40
+
41
+ - **100% pure Python** (no Rust binary wrapper, no C extensions) implementing the exact Neruton control protocol and **Yamux v0** multiplexer byte-for-byte compatible with `neruton-server` (`yamux 0.13`).
42
+ - **Async & Sync Python APIs** with full PEP 561 type annotations (`py.typed`).
43
+ - **Drop-in CLI** (`neruton` and `python -m neruton`) sharing `~/.config/neruton/config.toml` (`0600`) and `NERUTON_SERVER` / `NERUTON_TOKEN` environment variables with the Rust CLI.
44
+ - **Full HTTP/1.1 & WebSocket forwarding** with Host rewriting, chunked streaming, local HTTPS (`--no-tls-verify`), automatic reconnect with sticky prefix, and fail-fast on HTTP 401 auth errors.
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install neruton
50
+ ```
51
+
52
+ Requires Python 3.9+.
53
+
54
+ ## Quick Start — Python SDK
55
+
56
+ ### Async API (`asyncio` / FastAPI / Starlette / aiohttp)
57
+
58
+ ```python
59
+ import asyncio
60
+ import neruton
61
+
62
+ async def main() -> None:
63
+ async with neruton.connect(
64
+ url="http://127.0.0.1:3000",
65
+ server="https://neruton.moer.eu.org",
66
+ token="ntk_your_token_here",
67
+ subdomain="my-app", # optional; auto-assigns UUID v4 if omitted
68
+ ) as tunnel:
69
+ print("Public URL :", tunnel.public_url)
70
+ print("Preview URL:", tunnel.preview_url)
71
+ print("Path URL :", tunnel.path_url)
72
+ print("Prefix :", tunnel.prefix)
73
+ await tunnel.wait()
74
+
75
+ asyncio.run(main())
76
+ ```
77
+
78
+ Shorthand helpers for local ports:
79
+
80
+ ```python
81
+ async with neruton.forward(3000, subdomain="my-app") as tunnel:
82
+ print(tunnel.public_url)
83
+
84
+ # Alias matching `neruton http 8080`:
85
+ tunnel = await neruton.http(8080)
86
+ try:
87
+ print(tunnel.public_url)
88
+ finally:
89
+ await tunnel.close()
90
+ ```
91
+
92
+ ### Sync API (Flask / Django / Scripts / Notebooks)
93
+
94
+ `neruton.open(...)` runs the tunnel's `asyncio` event loop on a dedicated daemon thread and shuts down cleanly when exiting the `with` block:
95
+
96
+ ```python
97
+ import neruton
98
+
99
+ with neruton.open(5000, server="https://neruton.moer.eu.org", token="ntk_your_token_here") as tunnel:
100
+ print("Tunnel live at:", tunnel.public_url)
101
+ app.run(port=5000)
102
+ ```
103
+
104
+ ### Config Helpers
105
+
106
+ ```python
107
+ import neruton
108
+
109
+ print(neruton.config_path()) # ~/.config/neruton/config.toml
110
+ neruton.save_config(server="https://neruton.moer.eu.org", token="ntk_your_token_here")
111
+ cfg = neruton.load_config()
112
+ ```
113
+
114
+ ## Quick Start — CLI
115
+
116
+ ```bash
117
+ # Save default server and tunnel token (writes mode 0600 config.toml)
118
+ neruton config set --server https://neruton.moer.eu.org --token ntk_your_token_here
119
+ neruton config show
120
+ neruton config path
121
+
122
+ # Forward a local port with an auto-generated UUID v4 subdomain
123
+ neruton http 3000
124
+
125
+ # Forward with a custom subdomain prefix
126
+ neruton http 8080 -s my-app
127
+ neruton tunnel --url http://127.0.0.1:3000 --subdomain my-app
128
+
129
+ # Or invoke as a Python module
130
+ python -m neruton http 3000
131
+ python -m neruton version
132
+ ```
133
+
134
+ ## License
135
+
136
+ MIT
@@ -0,0 +1,100 @@
1
+ # neruton (Python SDK & CLI)
2
+
3
+ Native pure-Python tunnel client & SDK for [Neruton](https://github.com/kaecho/neruton) — self-hosted intranet penetration, wildcard subdomain reverse proxy, and WebSocket tunneling over port 443 (`WSS + Yamux`).
4
+
5
+ - **100% pure Python** (no Rust binary wrapper, no C extensions) implementing the exact Neruton control protocol and **Yamux v0** multiplexer byte-for-byte compatible with `neruton-server` (`yamux 0.13`).
6
+ - **Async & Sync Python APIs** with full PEP 561 type annotations (`py.typed`).
7
+ - **Drop-in CLI** (`neruton` and `python -m neruton`) sharing `~/.config/neruton/config.toml` (`0600`) and `NERUTON_SERVER` / `NERUTON_TOKEN` environment variables with the Rust CLI.
8
+ - **Full HTTP/1.1 & WebSocket forwarding** with Host rewriting, chunked streaming, local HTTPS (`--no-tls-verify`), automatic reconnect with sticky prefix, and fail-fast on HTTP 401 auth errors.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ pip install neruton
14
+ ```
15
+
16
+ Requires Python 3.9+.
17
+
18
+ ## Quick Start — Python SDK
19
+
20
+ ### Async API (`asyncio` / FastAPI / Starlette / aiohttp)
21
+
22
+ ```python
23
+ import asyncio
24
+ import neruton
25
+
26
+ async def main() -> None:
27
+ async with neruton.connect(
28
+ url="http://127.0.0.1:3000",
29
+ server="https://neruton.moer.eu.org",
30
+ token="ntk_your_token_here",
31
+ subdomain="my-app", # optional; auto-assigns UUID v4 if omitted
32
+ ) as tunnel:
33
+ print("Public URL :", tunnel.public_url)
34
+ print("Preview URL:", tunnel.preview_url)
35
+ print("Path URL :", tunnel.path_url)
36
+ print("Prefix :", tunnel.prefix)
37
+ await tunnel.wait()
38
+
39
+ asyncio.run(main())
40
+ ```
41
+
42
+ Shorthand helpers for local ports:
43
+
44
+ ```python
45
+ async with neruton.forward(3000, subdomain="my-app") as tunnel:
46
+ print(tunnel.public_url)
47
+
48
+ # Alias matching `neruton http 8080`:
49
+ tunnel = await neruton.http(8080)
50
+ try:
51
+ print(tunnel.public_url)
52
+ finally:
53
+ await tunnel.close()
54
+ ```
55
+
56
+ ### Sync API (Flask / Django / Scripts / Notebooks)
57
+
58
+ `neruton.open(...)` runs the tunnel's `asyncio` event loop on a dedicated daemon thread and shuts down cleanly when exiting the `with` block:
59
+
60
+ ```python
61
+ import neruton
62
+
63
+ with neruton.open(5000, server="https://neruton.moer.eu.org", token="ntk_your_token_here") as tunnel:
64
+ print("Tunnel live at:", tunnel.public_url)
65
+ app.run(port=5000)
66
+ ```
67
+
68
+ ### Config Helpers
69
+
70
+ ```python
71
+ import neruton
72
+
73
+ print(neruton.config_path()) # ~/.config/neruton/config.toml
74
+ neruton.save_config(server="https://neruton.moer.eu.org", token="ntk_your_token_here")
75
+ cfg = neruton.load_config()
76
+ ```
77
+
78
+ ## Quick Start — CLI
79
+
80
+ ```bash
81
+ # Save default server and tunnel token (writes mode 0600 config.toml)
82
+ neruton config set --server https://neruton.moer.eu.org --token ntk_your_token_here
83
+ neruton config show
84
+ neruton config path
85
+
86
+ # Forward a local port with an auto-generated UUID v4 subdomain
87
+ neruton http 3000
88
+
89
+ # Forward with a custom subdomain prefix
90
+ neruton http 8080 -s my-app
91
+ neruton tunnel --url http://127.0.0.1:3000 --subdomain my-app
92
+
93
+ # Or invoke as a Python module
94
+ python -m neruton http 3000
95
+ python -m neruton version
96
+ ```
97
+
98
+ ## License
99
+
100
+ MIT
@@ -0,0 +1,71 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "neruton"
7
+ version = "0.2.0"
8
+ description = "Native pure-Python tunnel client & SDK for Neruton (WSS + Yamux HTTP/WebSocket intranet proxy)"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.9"
13
+ authors = [{ name = "neruton contributors" }]
14
+ keywords = [
15
+ "neruton",
16
+ "tunnel",
17
+ "proxy",
18
+ "yamux",
19
+ "websocket",
20
+ "intranet",
21
+ "reverse-proxy",
22
+ "cloudflared",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 4 - Beta",
26
+ "Environment :: Console",
27
+ "Environment :: Web Environment",
28
+ "Intended Audience :: Developers",
29
+ "Intended Audience :: System Administrators",
30
+ "Operating System :: OS Independent",
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3.9",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Programming Language :: Python :: 3.13",
37
+ "Programming Language :: Python :: 3.14",
38
+ "Topic :: Internet :: Proxy Servers",
39
+ "Topic :: Internet :: WWW/HTTP",
40
+ "Topic :: Software Development :: Libraries :: Python Modules",
41
+ "Typing :: Typed",
42
+ ]
43
+ dependencies = [
44
+ "websockets>=12.0",
45
+ "tomli>=2.0.1; python_version < '3.11'",
46
+ ]
47
+
48
+ [project.optional-dependencies]
49
+ dev = [
50
+ "pytest>=7.0",
51
+ ]
52
+
53
+ [project.urls]
54
+ Homepage = "https://github.com/kaecho/neruton"
55
+ Repository = "https://github.com/kaecho/neruton"
56
+ Issues = "https://github.com/kaecho/neruton/issues"
57
+
58
+ [project.scripts]
59
+ neruton = "neruton.cli:main"
60
+
61
+ [tool.setuptools]
62
+ package-dir = { "" = "src" }
63
+
64
+ [tool.setuptools.packages.find]
65
+ where = ["src"]
66
+
67
+ [tool.setuptools.package-data]
68
+ neruton = ["py.typed"]
69
+
70
+ [tool.pytest.ini_options]
71
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,107 @@
1
+ """Native pure-Python tunnel client & SDK for Neruton (WSS + Yamux)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from ._version import (
6
+ DEFAULT_BASE_DOMAIN,
7
+ DEFAULT_PANEL_HOST,
8
+ DEFAULT_PUBLIC_SCHEME,
9
+ DEFAULT_SERVER_URL,
10
+ TUNNEL_WS_PATH,
11
+ __version__,
12
+ )
13
+ from .client import SyncTunnel, Tunnel, connect, forward, http
14
+ from .client import open_tunnel as open # noqa: A001
15
+ from .config import Config, config_path, load_config, resolve_server_and_token, save_config
16
+ from .errors import (
17
+ AuthError,
18
+ NerutonError,
19
+ PrefixError,
20
+ RegistrationError,
21
+ TunnelClosedError,
22
+ TunnelConnectionError,
23
+ YamuxClosedError,
24
+ YamuxError,
25
+ YamuxProtocolError,
26
+ YamuxStreamResetError,
27
+ )
28
+ from .forwarder import HostHeaderKind, HostHeaderMode, RequestEvent, TargetConfig
29
+ from .protocol import (
30
+ RESERVED_PREFIXES,
31
+ RegisterRequest,
32
+ RegisterResponse,
33
+ build_tunnel_ws_url,
34
+ generate_uuid_prefix,
35
+ normalize_target_url,
36
+ validate_prefix,
37
+ validate_prefix_format,
38
+ )
39
+ from .yamux import (
40
+ DEFAULT_CREDIT,
41
+ FrameFlags,
42
+ FrameHeader,
43
+ FrameType,
44
+ GoAwayCode,
45
+ Mode,
46
+ StreamState,
47
+ WsByteTransport,
48
+ YamuxSession,
49
+ YamuxStream,
50
+ )
51
+
52
+ __all__ = [
53
+ "__version__",
54
+ # High-level async & sync APIs
55
+ "connect",
56
+ "forward",
57
+ "http",
58
+ "open",
59
+ "Tunnel",
60
+ "SyncTunnel",
61
+ # Config helpers
62
+ "Config",
63
+ "config_path",
64
+ "load_config",
65
+ "save_config",
66
+ "resolve_server_and_token",
67
+ # Protocol & forwarder types
68
+ "DEFAULT_BASE_DOMAIN",
69
+ "DEFAULT_PANEL_HOST",
70
+ "DEFAULT_PUBLIC_SCHEME",
71
+ "DEFAULT_SERVER_URL",
72
+ "TUNNEL_WS_PATH",
73
+ "RESERVED_PREFIXES",
74
+ "RegisterRequest",
75
+ "RegisterResponse",
76
+ "RequestEvent",
77
+ "TargetConfig",
78
+ "HostHeaderKind",
79
+ "HostHeaderMode",
80
+ "build_tunnel_ws_url",
81
+ "normalize_target_url",
82
+ "generate_uuid_prefix",
83
+ "validate_prefix",
84
+ "validate_prefix_format",
85
+ # Low-level Yamux exports
86
+ "DEFAULT_CREDIT",
87
+ "FrameFlags",
88
+ "FrameHeader",
89
+ "FrameType",
90
+ "GoAwayCode",
91
+ "Mode",
92
+ "StreamState",
93
+ "WsByteTransport",
94
+ "YamuxSession",
95
+ "YamuxStream",
96
+ # Exceptions
97
+ "NerutonError",
98
+ "AuthError",
99
+ "PrefixError",
100
+ "RegistrationError",
101
+ "TunnelClosedError",
102
+ "TunnelConnectionError",
103
+ "YamuxError",
104
+ "YamuxProtocolError",
105
+ "YamuxClosedError",
106
+ "YamuxStreamResetError",
107
+ ]
@@ -0,0 +1,10 @@
1
+ """Allow invoking the CLI via `python -m neruton`."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import sys
6
+
7
+ from .cli import main
8
+
9
+ if __name__ == "__main__":
10
+ sys.exit(main())
@@ -0,0 +1,11 @@
1
+ """Version and protocol constants for Neruton."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __version__ = "0.2.0"
6
+
7
+ DEFAULT_BASE_DOMAIN = "moer.eu.org"
8
+ DEFAULT_PANEL_HOST = "neruton.moer.eu.org"
9
+ DEFAULT_SERVER_URL = "https://neruton.moer.eu.org"
10
+ DEFAULT_PUBLIC_SCHEME = "https"
11
+ TUNNEL_WS_PATH = "/_neruton/tunnel"