relayserver

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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).

func (*Server) Snapshot

func (s *Server) Snapshot() metrics.Snapshot

Snapshot returns the server's counter snapshot for metrics.Registry.

Jump to

Keyboard shortcuts

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