relaytest

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 20 Imported by: 0 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 relaytest 是 relay 的一致性测试(黑盒):Go 自建版与 Cloudflare 版跑同一套用例, 对着一个已经起好的 relay(ws:// 或 wss:// 地址)连主机与客户端,只看线上的行为。

不同的限额要不同的 relay 实例,用例按 Profile 分组:

  • main:每主机流上限小(MaxStreamsPerHost),每 IP 不限、每天不限,跑认证、转发、替换、关闭码这些;
  • limits:每 IP 每分钟连接上限小、每天转发量小,跑限额(会让这个 IP 一分钟内连不上,单独起一个实例);
  • disabled:暂停服务,一律 4503。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHost

func NewHost(t *testing.T, relayURL string) *remote.Host

RunHostInterop 用真正的主机端(internal/remote 的 Host 与它的 relay 客户端)经 relayURL 这台 relay 走完一遍: 主机认证上线、扫码配对(配对会话)、设备会话里调用 App API、撤销以后会话收到 GOAWAY、之后连不上。 NewHost 起一台真正的主机(internal/remote 的 Host,库在临时目录,App API 换成回显),打开远程访问并等它经 relayURL 上线。

func Run

func Run(t *testing.T, tg Target)

Run 跑这个 Profile 的全部用例。

func RunHostInterop

func RunHostInterop(t *testing.T, relayURL string)

Types

type Profile

type Profile string

Profile 是 relay 实例的限额组合。

const (
	ProfileMain     Profile = "main"
	ProfileLimits   Profile = "limits"
	ProfileDisabled Profile = "disabled"
)

三种实例。

type Target

type Target struct {
	// URL 是 relay 的地址(ws://127.0.0.1:8787)
	URL string
	// Origin 是 relay 校验签名用的 origin;为空时按 URL 推导
	Origin  string
	Profile Profile
	// MaxStreamsPerHost 是这个实例的每主机流上限(main)
	MaxStreamsPerHost int
	// MaxConnPerIPPerMin 是每 IP 每分钟连接上限(limits)
	MaxConnPerIPPerMin int
	// DailyBytesPerHost 是每主机每天转发量上限(limits)
	DailyBytesPerHost int64
}

Target 是要测的 relay。

Jump to

Keyboard shortcuts

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