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 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.
Example ¶
package main
import (
"fmt"
"net/http"
"net/http/httptest"
"github.com/tmc/go-iroh/relayserver"
)
func main() {
srv := httptest.NewServer(relayserver.New())
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).