faketurn

package
v0.0.0-...-a9a2de0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package faketurn provides an in-process TURN server for tests.

Why it is needed: the phase 5 acceptance criterion is "it connects over TURN on symmetric NAT". We cannot imitate symmetric NAT on a single machine, but we can build a situation that produces the SAME RESULT: force the agent to gather relay candidates only (ice.Config.RelayOnly) and point it here. Then the direct path is IMPOSSIBLE, so the tunnel opening is proof that the traffic went over TURN — stronger than a mobile hotspot attempt, where the direct path may have worked as well.

Same pattern as internal/nostr/fakerelay: a test that depends on the real internet is fragile.

Index

Constants

View Source
const Realm = "peerpages.test"

Realm is the TURN long-term credential realm.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// User and Pass are the only accepted credentials.
	User, Pass string
}

Options are the fake server's settings.

type Server

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

Server is the in-process TURN server.

func Start

func Start(opts Options) (*Server, error)

Start starts it on a free port.

func StartOn

func StartOn(port int, opts Options) (*Server, error)

StartOn starts it on the given port (0 = pick a free one).

Only 127.0.0.1 is listened on: this is a TEST server and must not be exposed to the network.

func (*Server) Allocations

func (s *Server) Allocations() int64

Allocations is how many allocations were granted.

This is the test's real claim: if the tunnel opened AND this counter went up, the traffic really did go over TURN.

func (*Server) Close

func (s *Server) Close() error

Close shuts the server down.

func (*Server) Port

func (s *Server) Port() int

Port is the port being listened on (to restart on the same address).

func (*Server) URL

func (s *Server) URL() string

URL is the TURN address to hand to the agent.

Jump to

Keyboard shortcuts

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