@serve.zone/remoteingress 3.0.1 → 3.0.2

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.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@serve.zone/remoteingress',
6
- version: '3.0.1',
6
+ version: '3.0.2',
7
7
  description: 'Edge ingress tunnel for DcRouter - accepts incoming TCP connections at network edge and tunnels them to DcRouter SmartProxy preserving client IP via PROXY protocol v1.'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSwyQkFBMkI7SUFDakMsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLHlLQUF5SztDQUN2TCxDQUFBIn0=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serve.zone/remoteingress",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "private": false,
5
5
  "description": "Edge ingress tunnel for DcRouter - accepts incoming TCP connections at network edge and tunnels them to DcRouter SmartProxy preserving client IP via PROXY protocol v1.",
6
6
  "main": "dist_ts/index.js",
package/readme.hints.md CHANGED
@@ -1,3 +1,9 @@
1
- * this module is part of the @serve.zone stack
2
- * it is used to reach private clusters from outside
3
- * it can be used to create private tunnels to private networks
1
+ * This module is part of the @serve.zone stack
2
+ * v3.0.0+ uses a Hub/Edge architecture with a Rust core binary (`remoteingress-bin`)
3
+ * TypeScript classes `RemoteIngressHub` and `RemoteIngressEdge` bridge to Rust via `@push.rocks/smartrust` RustBridge IPC
4
+ * Custom multiplexed binary frame protocol over TLS for tunneling TCP connections
5
+ * PROXY protocol v1 preserves client IP when forwarding to SmartProxy/DcRouter
6
+ * Edge authenticates to Hub via shared secret over TLS
7
+ * STUN-based public IP discovery at the edge (Cloudflare STUN server)
8
+ * Cross-compiled Rust binary for linux/amd64 and linux/arm64
9
+ * Old `ConnectorPublic`/`ConnectorPrivate` classes no longer exist (removed in v2.0.0/v3.0.0)
package/readme.md CHANGED
@@ -1,107 +1,215 @@
1
1
  # @serve.zone/remoteingress
2
2
 
3
- Provides a service for creating private tunnels and reaching private clusters from the outside as part of the @serve.zone stack.
3
+ Edge ingress tunnel for DcRouter accepts incoming TCP connections at the network edge and tunnels them to a DcRouter SmartProxy instance, preserving the original client IP via PROXY protocol v1.
4
4
 
5
- ## Install
5
+ ## Issue Reporting and Security
6
+
7
+ For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
6
8
 
7
- To install `@serve.zone/remoteingress`, run the following command in your terminal:
9
+ ## Install
8
10
 
9
11
  ```sh
10
- npm install @serve.zone/remoteingress
12
+ pnpm install @serve.zone/remoteingress
11
13
  ```
12
14
 
13
- This command will download and install the remoteingress package and its dependencies into your project.
15
+ ## 🏗️ Architecture
14
16
 
15
- ## Usage
17
+ `@serve.zone/remoteingress` uses a **Hub ↔ Edge** topology with a high-performance Rust core and a TypeScript API surface:
16
18
 
17
- `@serve.zone/remoteingress` is designed to facilitate the creation of secure private tunnels and enable access to private clusters from external sources, offering an integral part of the @serve.zone stack infrastructure. Below, we illustrate how to employ this package within your project, leveraging TypeScript and ESM syntax for modern, type-safe, and modular code.
19
+ ```
20
+ ┌─────────────────────┐ TLS Tunnel ┌─────────────────────┐
21
+ │ Network Edge │ ◄══════════════════════════► │ Private Cluster │
22
+ │ │ (multiplexed frames + │ │
23
+ │ RemoteIngressEdge │ shared-secret auth) │ RemoteIngressHub │
24
+ │ Listens on :80,:443│ │ Forwards to │
25
+ │ Accepts client TCP │ │ SmartProxy on │
26
+ │ │ │ local ports │
27
+ └─────────────────────┘ └─────────────────────┘
28
+ ▲ │
29
+ │ TCP from end users ▼
30
+ Internet DcRouter / SmartProxy
31
+ ```
18
32
 
19
- ### Prerequisites
33
+ | Component | Role |
34
+ |-----------|------|
35
+ | **RemoteIngressEdge** | Deployed at the network edge (e.g. a VPS or cloud instance). Listens on public ports, accepts raw TCP connections, and multiplexes them over a single TLS tunnel to the hub. |
36
+ | **RemoteIngressHub** | Deployed alongside DcRouter/SmartProxy in a private cluster. Accepts edge connections, demuxes streams, and forwards each to SmartProxy with a PROXY protocol v1 header so the real client IP is preserved. |
37
+ | **Rust Binary** (`remoteingress-bin`) | The performance-critical networking core. Managed via `@push.rocks/smartrust` RustBridge IPC — you never interact with it directly. Cross-compiled for `linux/amd64` and `linux/arm64`. |
20
38
 
21
- Ensure that you have Node.js and TypeScript installed in your environment. Your project should be set up with TypeScript support, and you might want to familiarize yourself with basic networking concepts and TLS/SSL for secure communication.
39
+ ### 🔑 Key Features
22
40
 
23
- ### Importing and Initializing Connectors
41
+ - 🔒 **TLS-encrypted tunnel** between edge and hub (auto-generated self-signed cert or bring your own)
42
+ - 🔀 **Multiplexed streams** — thousands of client connections flow over a single tunnel
43
+ - 🌐 **PROXY protocol v1** — SmartProxy sees the real client IP, not the tunnel IP
44
+ - 🔐 **Shared-secret authentication** — edges must present valid credentials to connect
45
+ - 📡 **STUN-based public IP discovery** — the edge automatically discovers its public IP via Cloudflare STUN
46
+ - 🔄 **Auto-reconnect** with exponential backoff if the tunnel drops
47
+ - 📢 **Event-driven** — both Hub and Edge extend `EventEmitter` for real-time monitoring
48
+ - ⚡ **Rust core** — all frame encoding, TLS, and TCP proxying happen in native code for maximum throughput
24
49
 
25
- `@serve.zone/remoteingress` offers two primary components: `ConnectorPublic` and `ConnectorPrivate`. Here's how to use them:
50
+ ## Usage
26
51
 
27
- #### Setup ConnectorPublic
52
+ Both classes are imported from the package and communicate with the Rust binary under the hood. All you need to do is configure and start them.
28
53
 
29
- `ConnectorPublic` acts as a gateway, accepting incoming tunnel connections from `ConnectorPrivate` instances and facilitating secure communication between the internet and your private network.
54
+ ### Setting up the Hub (private cluster side)
30
55
 
31
56
  ```typescript
32
- import { ConnectorPublic } from '@serve.zone/remoteingress';
33
-
34
- // Initialize ConnectorPublic
35
- const publicConnector = new ConnectorPublic({
36
- tlsOptions: {
37
- key: fs.readFileSync("<path-to-your-tls/key.pem>"),
38
- cert: fs.readFileSync("<path-to-your-cert/cert.pem>"),
39
- // Consider including 'ca' and 'passphrase' if required for your setup
40
- },
41
- listenPort: 443 // Example listen port; adjust based on your needs
57
+ import { RemoteIngressHub } from '@serve.zone/remoteingress';
58
+
59
+ const hub = new RemoteIngressHub();
60
+
61
+ // Listen for events
62
+ hub.on('edgeConnected', ({ edgeId }) => {
63
+ console.log(`✅ Edge ${edgeId} connected`);
64
+ });
65
+ hub.on('edgeDisconnected', ({ edgeId }) => {
66
+ console.log(`❌ Edge ${edgeId} disconnected`);
67
+ });
68
+ hub.on('streamOpened', ({ edgeId, streamId }) => {
69
+ console.log(`🔗 Stream ${streamId} opened from edge ${edgeId}`);
70
+ });
71
+ hub.on('streamClosed', ({ edgeId, streamId }) => {
72
+ console.log(`🔗 Stream ${streamId} closed from edge ${edgeId}`);
73
+ });
74
+
75
+ // Start the hub — it will listen for incoming edge TLS connections
76
+ await hub.start({
77
+ tunnelPort: 8443, // port edges connect to (default: 8443)
78
+ targetHost: '127.0.0.1', // SmartProxy host to forward streams to (default: 127.0.0.1)
42
79
  });
43
- ```
44
80
 
45
- #### Setup ConnectorPrivate
81
+ // Register which edges are allowed to connect
82
+ await hub.updateAllowedEdges([
83
+ { id: 'edge-nyc-01', secret: 'supersecrettoken1' },
84
+ { id: 'edge-fra-02', secret: 'supersecrettoken2' },
85
+ ]);
86
+
87
+ // Check status at any time
88
+ const status = await hub.getStatus();
89
+ console.log(status);
90
+ // {
91
+ // running: true,
92
+ // tunnelPort: 8443,
93
+ // connectedEdges: [
94
+ // { edgeId: 'edge-nyc-01', connectedAt: 1700000000, activeStreams: 12 }
95
+ // ]
96
+ // }
97
+
98
+ // Graceful shutdown
99
+ await hub.stop();
100
+ ```
46
101
 
47
- `ConnectorPrivate` establishes a secure tunnel to `ConnectorPublic`, effectively bridging your internal services with the external point of access.
102
+ ### Setting up the Edge (network edge side)
48
103
 
49
104
  ```typescript
50
- import { ConnectorPrivate } from '@serve.zone/remoteingress';
51
-
52
- // Initialize ConnectorPrivate pointing to your ConnectorPublic instance
53
- const privateConnector = new ConnectorPrivate({
54
- publicHost: 'your.public.domain.tld',
55
- publicPort: 443, // Ensure this matches the listening port of ConnectorPublic
56
- tlsOptions: {
57
- // You might want to specify TLS options here, similar to ConnectorPublic
58
- }
105
+ import { RemoteIngressEdge } from '@serve.zone/remoteingress';
106
+
107
+ const edge = new RemoteIngressEdge();
108
+
109
+ // Listen for events
110
+ edge.on('tunnelConnected', () => {
111
+ console.log('🟢 Tunnel to hub established');
112
+ });
113
+ edge.on('tunnelDisconnected', () => {
114
+ console.log('🔴 Tunnel to hub lost — will auto-reconnect');
115
+ });
116
+ edge.on('publicIpDiscovered', ({ ip }) => {
117
+ console.log(`🌐 Public IP: ${ip}`);
59
118
  });
119
+
120
+ // Start the edge — it connects to the hub and starts listening for clients
121
+ await edge.start({
122
+ hubHost: 'hub.example.com', // hostname or IP of the hub
123
+ hubPort: 8443, // must match hub's tunnelPort (default: 8443)
124
+ edgeId: 'edge-nyc-01', // unique edge identifier
125
+ secret: 'supersecrettoken1', // must match the hub's allowed edge secret
126
+ listenPorts: [80, 443], // public ports to accept TCP connections on
127
+ stunIntervalSecs: 300, // STUN refresh interval in seconds (default: 300)
128
+ });
129
+
130
+ // Check status at any time
131
+ const status = await edge.getStatus();
132
+ console.log(status);
133
+ // {
134
+ // running: true,
135
+ // connected: true,
136
+ // publicIp: '203.0.113.42',
137
+ // activeStreams: 5,
138
+ // listenPorts: [80, 443]
139
+ // }
140
+
141
+ // Graceful shutdown
142
+ await edge.stop();
60
143
  ```
61
144
 
62
- ### Secure Communication
145
+ ### API Reference
63
146
 
64
- It's imperative to ensure that the communication between `ConnectorPublic` and `ConnectorPrivate` is secure:
147
+ #### `RemoteIngressHub`
65
148
 
66
- - Always use valid TLS certificates.
67
- - Prefer using certificates issued by recognized Certificate Authorities (CA).
68
- - Optionally, configure mutual TLS (mTLS) by requiring client certificates for an added layer of security.
149
+ | Method / Property | Description |
150
+ |-------------------|-------------|
151
+ | `start(config?)` | Spawns the Rust binary and starts the tunnel listener. Config: `{ tunnelPort?: number, targetHost?: string }` |
152
+ | `stop()` | Gracefully shuts down the hub and kills the Rust process. |
153
+ | `updateAllowedEdges(edges)` | Dynamically update which edges are authorized. Each edge: `{ id: string, secret: string }` |
154
+ | `getStatus()` | Returns current hub status including connected edges and active stream counts. |
155
+ | `running` | `boolean` — whether the Rust binary is alive. |
69
156
 
70
- ### Advanced Usage
157
+ **Events:** `edgeConnected`, `edgeDisconnected`, `streamOpened`, `streamClosed`
71
158
 
72
- Both connectors can be finely tuned:
159
+ #### `RemoteIngressEdge`
73
160
 
74
- - **Logging and Monitoring:** Integrate with your existing logging and monitoring systems to keep tabs on tunnel activity, performance metrics, and potential security anomalies.
161
+ | Method / Property | Description |
162
+ |-------------------|-------------|
163
+ | `start(config)` | Spawns the Rust binary, connects to the hub, and starts listening on the specified ports. |
164
+ | `stop()` | Gracefully shuts down the edge and kills the Rust process. |
165
+ | `getStatus()` | Returns current edge status including connection state, public IP, and active streams. |
166
+ | `running` | `boolean` — whether the Rust binary is alive. |
75
167
 
76
- - **Custom Handlers:** Implement custom traffic handling logic for specialized routing, filtering, or protocol-specific processing.
168
+ **Events:** `tunnelConnected`, `tunnelDisconnected`, `publicIpDiscovered`
77
169
 
78
- - **Automation:** Automate the deployment and scaling of both `ConnectorPublic` and `ConnectorPrivate` instances using infrastructure-as-code (IAC) tools and practices, ensuring that your tunneling infrastructure can dynamically adapt to the ever-changing needs of your services.
170
+ ### 🔌 Wire Protocol
79
171
 
80
- ### Example Scenarios
172
+ The tunnel uses a custom binary frame protocol over TLS:
81
173
 
82
- 1. **Securing Application APIs:** Use `@serve.zone/remoteingress` to expose private APIs to your frontend deployed on a public cloud, ensuring that only your infrastructure can access these endpoints.
174
+ ```
175
+ [stream_id: 4 bytes][type: 1 byte][length: 4 bytes][payload: N bytes]
176
+ ```
83
177
 
84
- 2. **Remote Database Access:** Securely access databases within a private VPC from your local development machine without opening direct access to the internet.
178
+ | Frame Type | Value | Direction | Purpose |
179
+ |------------|-------|-----------|---------|
180
+ | `OPEN` | `0x01` | Edge → Hub | Open a new stream; payload is PROXY v1 header |
181
+ | `DATA` | `0x02` | Edge → Hub | Client data flowing upstream |
182
+ | `CLOSE` | `0x03` | Edge → Hub | Client closed the connection |
183
+ | `DATA_BACK` | `0x04` | Hub → Edge | Response data flowing downstream |
184
+ | `CLOSE_BACK` | `0x05` | Hub → Edge | Upstream (SmartProxy) closed the connection |
85
185
 
86
- 3. **Service Mesh Integration:** Integrate `@serve.zone/remoteingress` as part of a service mesh setup to securely connect services across multiple clusters with robust identity and encryption at the tunnel level.
186
+ Max payload size per frame: **16 MB**.
187
+
188
+ ### Example Scenarios
87
189
 
88
- For detailed documentation, API references, and additional use cases, please refer to the inline documentation and source code within the package. Always prioritize security and robustness when dealing with network ingress to protect your infrastructure and data from unauthorized access and threats.
190
+ 1. **Expose a private Kubernetes cluster to the internet** — Deploy an Edge on a public VPS, configure your DNS to point to the VPS IP. The Edge tunnels all traffic to the Hub running inside the cluster, which hands it off to SmartProxy/DcRouter. Your cluster stays fully private no public-facing ports needed.
191
+
192
+ 2. **Multi-region edge ingress** — Run multiple Edges in different geographic regions (NYC, Frankfurt, Tokyo) all connecting to a single Hub. Use GeoDNS to route users to their nearest Edge. The Hub sees the real client IPs via PROXY protocol regardless of which edge they connected through.
193
+
194
+ 3. **Secure API exposure** — Your backend runs on a private network with no direct internet access. An Edge on a minimal cloud instance acts as the only public entry point. TLS tunnel + shared-secret auth ensure only your authorized Edge can forward traffic.
89
195
 
90
196
  ## License and Legal Information
91
197
 
92
- This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
198
+ This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
93
199
 
94
200
  **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
95
201
 
96
202
  ### Trademarks
97
203
 
98
- This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
204
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
205
+
206
+ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
99
207
 
100
208
  ### Company Information
101
209
 
102
- Task Venture Capital GmbH
103
- Registered at District court Bremen HRB 35230 HB, Germany
210
+ Task Venture Capital GmbH
211
+ Registered at District Court Bremen HRB 35230 HB, Germany
104
212
 
105
- For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
213
+ For any legal inquiries or further information, please contact us via email at hello@task.vc.
106
214
 
107
215
  By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@serve.zone/remoteingress',
6
- version: '3.0.1',
6
+ version: '3.0.2',
7
7
  description: 'Edge ingress tunnel for DcRouter - accepts incoming TCP connections at network edge and tunnels them to DcRouter SmartProxy preserving client IP via PROXY protocol v1.'
8
8
  }