rstream Go SDK and CLI
rstream connects services and devices through outbound tunnels. Publish an endpoint for ordinary clients or let authenticated rstream clients dial a private service by name.
This repository contains the reference Go SDK and the rstream CLI. The CLI forwards an existing service. The SDK lets an application own its tunnel and use standard Go listeners, connections and packet connections.
| Task | Start here |
|---|---|
| Forward an existing service | Install the CLI and configure your first HTTP tunnel. |
| Integrate with a Go application | Run an HTTP handler on a tunnel or run a private Go pair. |
| Build or contribute to this checkout | Build from source, then see Contributing. |
| Evaluate a hosted or self-hosted deployment | Editions and plans and the security model. |
Start with the CLI
With a CLI connection configured and an HTTP service on local port 8080, the following command publishes an HTTP endpoint. A self-hosted endpoint follows the Engine's network reachability and access policy. For a restricted service choose HTTP authentication or private access before forwarding.
rstream forward 127.0.0.1:8080 --http
Open the printed address to reach the service. Stop forwarding with Ctrl+C. Use the CLI walkthrough to try this with a disposable service and understand its access policy.
Use the Go library
With an authenticated control channel, create a published HTTP/1.1 tunnel
and pass its listener to net/http.
tunnel, err := control.CreateTunnel(ctx, rstream.TunnelProperties{
Protocol: rstream.ProtocolPtr(rstream.ProtocolHTTP),
HTTPVersion: rstream.HTTPVersionPtr(rstream.HTTP1_1),
Publish: rstream.BoolPtr(true),
})
if err != nil {
return err
}
defer tunnel.Close()
address, err := tunnel.ForwardingAddress()
if err != nil {
return err
}
fmt.Println(address)
listener, ok := tunnel.(rstream.BytestreamTunnel)
if !ok {
return fmt.Errorf("expected a bytestream tunnel")
}
server := &http.Server{
Handler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
hostname, _ := os.Hostname()
fmt.Fprintln(w, hostname)
}),
ReadHeaderTimeout: 5 * time.Second,
}
return server.Serve(listener)
The published module includes a complete HTTP server. With a CLI context that permits HTTP publication, Go can fetch and run it directly.
go run github.com/rstreamlabs/rstream-go/examples/http-h1-server@v1.38.1 --publish
Open the printed HTTPS address to receive the machine hostname. Stop with Ctrl+C. The Go SDK walkthrough covers adding the SDK to an application and dialing a private service.
Documentation
Use the documentation index to choose a tunnel protocol or find guides for files, terminals, integrations and configuration. The Go API reference documents exported types and methods. See Troubleshooting for connection and routing checks.
Security and support
Report vulnerabilities through the channels in Security. Use GitHub issues for reproducible bugs and usage questions. The SDK and CLI are licensed under Apache-2.0.