relay

package
v0.0.0-...-4c8c030 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: AGPL-3.0 Imports: 47 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

[INPUT]: 设备身份、签名握手、WebSocket 与对应通道的 yamux 配置。 [OUTPUT]: 验证设备证明,发布控制路由,按代次附着数据通道。 [POS]: 设备隧道入口,与 lease 的存活探测共用进程接管窗口。 [PROTOCOL]: 变更时更新此头部,然后检查 guidelines.md

[INPUT]: 设备登记与当前执行路由的存活窗口。 [OUTPUT]: 返回运行状态和分页设备快照。 [POS]: 设备目录的投影,按与代理一致的期限决定设备是否在线。 [PROTOCOL]: 变更时更新此头部,然后检查 guidelines.md

[INPUT]: 签名租约、授权存储、控制事件流与 yamux Ping。 [OUTPUT]: 核验访问租约,定期探测并按最近有效 Pong 判定失联,传递撤销。 [POS]: 设备控制路由的存活与授权检查,网络读写在服务锁外执行。 [PROTOCOL]: 变更时更新此头部,然后检查 guidelines.md

[INPUT]: 设备登记、身份授权、yamux 会话与结构化日志。 [OUTPUT]: 组装 relay 服务,按代次回收设备访问并记录首次关闭原因。 [POS]: relay 服务入口,按控制或数据通道分配复用器的超时预算。 [PROTOCOL]: 变更时更新此头部,然后检查 guidelines.md

Index

Constants

View Source
const Version = 1

Variables

This section is empty.

Functions

func FileGrantBytes

func FileGrantBytes(grant FileGrant) ([]byte, error)

func FileGrantV1Bytes

func FileGrantV1Bytes(grant FileGrantV1) ([]byte, error)

func PreviewGuard

func PreviewGuard(template string) func(http.Handler) http.Handler

func PreviewOrigin

func PreviewOrigin(template, server, user, machine, session, artifact string) string

func ProofBytes

func ProofBytes(hello Hello, challenge Challenge) ([]byte, error)

ProofBytes encodes the shared fixed-array proof payload.

Types

type Challenge

type Challenge struct {
	Type                string    `json:"type"`
	ServerID            string    `json:"server_id"`
	OwnerUserID         string    `json:"owner_user_id"`
	ChallengeID         string    `json:"challenge_id"`
	Nonce               string    `json:"nonce"`
	TTLMS               int64     `json:"ttl_ms"`
	ServerTime          time.Time `json:"server_time"`
	GrantID             string    `json:"grant_id"`
	RegistrationVersion int64     `json:"registration_version"`
}

type Config

type Config struct {
	DesktopOrigins        []string
	PreviewOriginTemplate string
	StateDir              string
	ServerID              string
	PublicURL             string
	FilesOrigin           string
	VerificationKeysFile  string
	SigningKeyFile        string
	MaxDevices            int
}

type ConnectionRequest

type ConnectionRequest struct {
	ConnectionID       string           `json:"connection_id,omitempty"`
	Scopes             *[]string        `json:"scopes,omitempty"`
	SupportedProtocols map[string][]int `json:"supported_protocols,omitempty"`
}

type ConnectionResponse

type ConnectionResponse struct {
	ConnectionID  string          `json:"connection_id"`
	MachineID     string          `json:"machine_id"`
	HTTPBase      string          `json:"http_base"`
	Ticket        string          `json:"ticket"`
	TicketVersion int64           `json:"ticket_version"`
	ExpiresAt     time.Time       `json:"expires_at"`
	ExpiresIn     int64           `json:"expires_in"`
	ServerTime    time.Time       `json:"server_time"`
	Scopes        []string        `json:"scopes"`
	Protocol      json.RawMessage `json:"protocol"`
}

type FileAuthorization

type FileAuthorization struct {
	ServerID      string   `json:"server_id"`
	OwnerUserID   string   `json:"owner_user_id"`
	MachineID     string   `json:"machine_id"`
	ConnectionID  string   `json:"connection_id"`
	ClientGrantID string   `json:"client_grant_id"`
	GrantVersion  int64    `json:"grant_version"`
	AccessVersion int64    `json:"access_version"`
	LeaseEpoch    int64    `json:"lease_epoch"`
	Scopes        []string `json:"scopes"`
}

type FileGrant

type FileGrant struct {
	ArtifactID    string    `json:"artifact_id,omitempty"`
	PreviewOrigin string    `json:"preview_origin,omitempty"`
	Version       int       `json:"version"`
	ServerID      string    `json:"server_id"`
	OwnerUserID   string    `json:"owner_user_id"`
	MachineID     string    `json:"machine_id"`
	SessionID     string    `json:"session_id"`
	Path          string    `json:"path"`
	Scope         string    `json:"scope"`
	KeyID         string    `json:"key_id"`
	GrantVersion  int64     `json:"grant_version"`
	IssuedAt      time.Time `json:"issued_at"`
	ExpiresAt     time.Time `json:"expires_at"`
	ConnectionID  string    `json:"-"`
	ClientGrantID string    `json:"-"`
	AccessVersion int64     `json:"-"`
	LeaseEpoch    int64     `json:"-"`
	Scopes        []string  `json:"-"`
}

type FileGrantV1

type FileGrantV1 struct {
	Type          string            `json:"type"`
	Version       int               `json:"version"`
	KeyID         string            `json:"key_id"`
	Authorization FileAuthorization `json:"authorization"`
	SessionID     string            `json:"session_id"`
	Path          string            `json:"path"`
	Purpose       string            `json:"purpose"`
	IssuedAt      int64             `json:"issued_at"`
	ExpiresAt     int64             `json:"expires_at"`
}

type Hello

type Hello struct {
	Type               string           `json:"type"`
	TunnelVersion      int              `json:"tunnel_version"`
	ChannelKind        string           `json:"channel_kind"`
	MachineID          string           `json:"machine_id"`
	ExecutionPublicKey string           `json:"execution_public_key"`
	BootID             string           `json:"boot_id"`
	DisplayName        string           `json:"display_name"`
	Platform           string           `json:"platform"`
	Arch               string           `json:"arch"`
	DeploymentMode     string           `json:"deployment_mode"`
	Intent             string           `json:"intent"`
	RestoreRevoked     bool             `json:"restore_revoked"`
	LeaseEpoch         int64            `json:"lease_epoch"`
	RuntimeVersion     string           `json:"runtime_version,omitempty"`
	EngineVersion      string           `json:"engine_version,omitempty"`
	Protocols          map[string][]int `json:"protocols"`
}

type LeaseRequest

type LeaseRequest struct {
	Type          string            `json:"type"`
	Authorization FileAuthorization `json:"authorization"`
	Nonce         string            `json:"nonce"`
	LeaseSeq      int64             `json:"lease_seq"`
	BootID        string            `json:"boot_id"`
	RequireFresh  bool              `json:"require_fresh"`
}

type Proof

type Proof struct {
	Type        string `json:"type"`
	ChallengeID string `json:"challenge_id"`
	Signature   string `json:"signature"`
}

type Ready

type Ready struct {
	Type                string            `json:"type"`
	ServerID            string            `json:"server_id"`
	MachineID           string            `json:"machine_id"`
	RegistrationVersion int64             `json:"registration_version"`
	GrantVersion        int64             `json:"grant_version"`
	LeaseEpoch          int64             `json:"lease_epoch,omitempty"`
	Bound               bool              `json:"bound,omitempty"`
	PublicAddresses     map[string]string `json:"public_addresses,omitempty"`
}

type ReadyAck

type ReadyAck struct {
	Type                string `json:"type"`
	RegistrationVersion int64  `json:"registration_version"`
	LeaseEpoch          int64  `json:"lease_epoch,omitempty"`
}

type Service

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

func NewService

func NewService(pool *pgxpool.Pool, identities *identity.Service, devices *endpoint.Execution, logger *slog.Logger, config Config) (*Service, error)

func (*Service) DeviceAuthorizationKey

func (s *Service) DeviceAuthorizationKey() []byte

func (*Service) Directory

func (s *Service) Directory() http.Handler

func (*Service) DisconnectRuntime

func (s *Service) DisconnectRuntime(user, machine string)

func (*Service) InvalidateDevice

func (s *Service) InvalidateDevice(user, machine string, version int64)

func (*Service) InvalidateGrant

func (s *Service) InvalidateGrant(id string)

func (*Service) Metadata

func (s *Service) Metadata() map[string]any

func (*Service) Metrics

func (s *Service) Metrics() map[string]int64

Metrics 可供宿主监控采集;数值也随流收尾写入结构化日志。

func (*Service) Register

func (s *Service) Register(router chi.Router)

func (*Service) Run

func (s *Service) Run(ctx context.Context)

func (*Service) RuntimeReady

func (s *Service) RuntimeReady(ctx context.Context, user, machine string) (bool, error)

func (*Service) RuntimeStatus

func (s *Service) RuntimeStatus(_ context.Context, user, machine string) (string, string, int64, error)

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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