client

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package client provides a minimal Go API for applications to open tunnels through a local pulse relay node.

The pulse TCP listener accepts connections that start with a single JSON line specifying the destination. After sending that line, the connection behaves exactly like a direct TCP connection to the target — no pulse-specific framing from that point on. Any library or protocol works transparently on top.

Example — connect a database driver through pulse:

conn, err := client.Dial("localhost:7000", "a3f2c1d4", "localhost:5432")
if err != nil { log.Fatal(err) }
// hand conn to any library that accepts a net.Conn

Example — dial with a context and timeout:

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
conn, err := client.DialContext(ctx, "localhost:7000", "a3f2c1d4", "localhost:22")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(pulseAddr, destNode, destAddr string) (net.Conn, error)

Dial opens a tunnel through the pulse node at pulseAddr to destAddr on destNode.

  • pulseAddr — TCP address of the local pulse listener, e.g. "localhost:7000"
  • destNode — NodeID of the target relay node (shown on startup or via `pulse status`)
  • destAddr — TCP address to reach on the destination node, e.g. "localhost:22"

The returned net.Conn is a transparent tunnel: read/write as if directly connected.

func DialContext

func DialContext(ctx context.Context, pulseAddr, destNode, destAddr string) (net.Conn, error)

DialContext is like Dial but honours the provided context for the initial connection.

Types

type Forwarder

type Forwarder struct {
	// contains filtered or unexported fields
}

Forwarder listens on a local TCP port and tunnels every connection through pulse to a fixed destination. Useful for apps that don't support proxy settings (e.g. RDP clients, legacy database drivers).

fwd, _ := client.NewForwarder("localhost:7000", "a3f2c1d4", "localhost:3389")
fwd.ListenAndServe(ctx, ":3389")  // RDP client connects to localhost:3389

func NewForwarder

func NewForwarder(pulseAddr, destNode, destAddr string) *Forwarder

NewForwarder creates a Forwarder that maps localPort → pulse → destNode:destAddr.

func (*Forwarder) ListenAndServe

func (f *Forwarder) ListenAndServe(ctx context.Context, localAddr string) error

ListenAndServe starts accepting on localAddr and tunnels each connection. Blocks until ctx is cancelled or a fatal listen error occurs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL