Documentation
¶
Overview ¶
Package relayserver implements the server side of the iroh relay protocol.
It accepts relay WebSocket clients, authenticates them with the relay challenge protocol, and forwards relay datagrams between connected endpoint ids. It is intentionally small: persistence, metrics, access control, and clustering belong above this package.
The Go API is not stable before v1 and may change in any v0 release.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶ added in v0.1.1
type Option func(*Server)
Option configures a Server.
func WithClientRate ¶ added in v0.1.1
WithClientRate sets the per-client receive rate limit in bytes per second (default 64 MiB/s); <= 0 disables it.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an iroh relay protocol HTTP handler.
func New ¶
func New() *Server
New returns a relay server with default settings. Use NewWithOptions to configure it.
func NewWithOptions ¶ added in v0.1.1
NewWithOptions returns a relay server configured by opts.
Example ¶
package main
import (
"fmt"
"net/http"
"net/http/httptest"
"github.com/tmc/go-iroh/relayserver"
)
func main() {
// Override the default per-client receive rate when hosting the relay.
srv := httptest.NewServer(relayserver.NewWithOptions(relayserver.WithClientRate(8 << 20)))
defer srv.Close()
resp, err := http.Get(srv.URL + "/")
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.StatusCode)
}
Output: 404
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles relay WebSocket requests at /relay and net-report latency probes at /ping. Rust iroh clients require a 200 from /ping before selecting a relay as their home relay (iroh-relay/src/http.rs).