Reverse proxy a local TCP/UDP service over HyperDHT - P2P reverse proxying, no signalling server required.
** V3 is still experimental and under heavy development. Expect breaking changes. Consider using V2 instead**
npm install holesail-server
const HolesailServer = require('holesail-server')
const server = new HolesailServer({
port: 8080,
host: '127.0.0.1'
})
await server.ready()
console.log(server.invite) // share this - anyone holding it can connect a clientA holesail-client given this invite can reach 127.0.0.1:8080 on this machine from anywhere.
By default the server generates a random keypair (and invite) on every ready(). Pass a seed to get the same one every time:
const server = new HolesailServer({
port: 8080,
host: '127.0.0.1',
seed: 'a1b2c3...' // 64 hex chars (32 bytes)
})Use require('@holesail/invite').randomSeed() to generate one.
const server = new HolesailServer({ port: 53, host: '127.0.0.1', udp: true })await server.close()await server.pause() // stop accepting new connections, keep existing tunnels alive
await server.resume()Creates a server. Nothing is listening until ready() is called.
{
port: 8080, // required - local port to forward tunneled connections to
host: '127.0.0.1', // required - local host to forward tunneled connections to
udp: false, // true to tunnel UDP instead of TCP. Defaults to false
seed: '<hex string>', // optional 64-char hex string for a deterministic keypair/invite
bootstrap: [], // optional custom HyperDHT bootstrap nodes
logger: undefined // optional {debug, info, warn, error} logger
}Generates a keypair (from seed if given, otherwise random) and starts listening on the DHT. Resolves once server.invite is ready to share.
The invite string clients need to connect. Encodes the server's public key and a capability token, a raw DHT connection alone isn't enough to open a tunnel, the client must present the matching capability.
Emitted once the server is listening and server.invite is available.
Emitted for every incoming stream, before the capability check runs - useful for connection-rate logging or metrics. Firing doesn't mean the connection presented a valid capability; invalid streams are destroyed right after.
{
state: 'listening', // 'starting' | 'listening' | 'paused' | 'destroyed'
port: 8080,
host: '127.0.0.1',
udp: false,
seed: '<hex string>',
invite: '<string>'
}Suspends the underlying DHT node without tearing anything down.
Resumes a paused server.
Destroys the DHT node and all open tunnels.
This project is licensed under the GNU AGPL v3 license - see the LICENSE and NOTICE files.
Join our Discord Support Server for help, discussions, and updates.