Expose Node.js services to RingLink
RingLink Node.js SDK is a library that allows you to embed RingLink mesh network capabilities into your Node.js applications. You can programmatically connect to your RingLink network, for example, to access other devices on the network or to publish local services to the RingLink network.
The RingLink SDK is built on a user-space TCP/IP stack, developers do not need to modify system network settings or require elevated privileges. This makes it flexible to connect to an existing RingLink network.
The current RingLink Node.js SDK is in the alpha stage. Its features are incomplete and the API may change.
Features
- IPv4
- IPv6 (In Tunnel)
- Incoming TCP proxy
- TCP server and client
- UDP
Getting Started
Using the RingLink SDK in Node.js is very easy, just install the @ringlink-sdk/core
package.
npm install @ringlink-sdk/core
pnpm install @ringlink-sdk/core
yarn add @ringlink-sdk/core
Requirements
Before using the RingLink Node.js SDK, please ensure you meet the following requirements:
- Node.js
- A Config Key
Example
Publish a local service to the RingLink network via proxy:
import { createRinglink } from "@ringlink-sdk/core";
const stack = await createRinglink({
network: "53cd98d2",
token: "<your-config-key>"
});
const handle = stack.proxy("tcp", "0.0.0.0:80", "127.0.0.1:8000");
// run your server here, typically a web server run forever
// call handle.stop() to stop the proxy
In this code, a RingLink instance is first created using the createRinglink
function, passing your config key
and network ID.
Then, RingLink.proxy
is used to create a proxy tunnel.
The first parameter is protocol, only tcp are supported now, second is the local address and port to listen on (usually 0.0.0.0
),
and the last is the address and port of the service to be published.
When this code runs, RingLink automatically creates a TCP proxy tunnel.
Other devices on the current RingLink network accessing <private-ip>:80
will be forwarded to the local 127.0.0.1:8000
.