Help us shape the future of Go! Take the 2026 Go Developer Survey

link

package
v1.49.13 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderSize     = 5
	MaxPayload     = 65536
	MaxMessageSize = HeaderSize + MaxPayload
	Window         = 256 * 1024
)
View Source
const (
	Version     = 1
	ControlName = "slicc.link.v1"
	StreamName  = "slicc.link.v1.stream"
)
View Source
const CloseGrace = 10 * time.Second
View Source
const ReceiveBuffer = 4 << 20

Variables

View Source
var (
	ErrClosed       = errors.New("link: closed")
	ErrHelloTimeout = errors.New("link: no HELLO from the peer")
)
View Source
var (
	ErrNotAccepted   = errors.New("link: stream not accepted yet")
	ErrAlreadyOpened = errors.New("link: stream already answered")
	ErrWriteAfterEnd = errors.New("link: write after END")
)

Functions

func EncodeFrame

func EncodeFrame(t FrameType, id uint32, payload []byte) []byte

func NewAPI

func NewAPI(opts APIOptions) *webrtc.API

func PionLoggerFactory

func PionLoggerFactory(logf func(format string, args ...any)) pionlogging.LoggerFactory

Types

type APIOptions

type APIOptions struct {
	Logf     func(format string, args ...any)
	Loopback bool
}

type Addr added in v1.14.0

type Addr struct {
	Kind  string
	ID    uint32
	Local bool
}

func (Addr) Network added in v1.14.0

func (Addr) Network() string

func (Addr) String added in v1.14.0

func (a Addr) String() string

type Browser added in v1.11.0

type Browser struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Version string `json:"version"`
	Seven   bool   `json:"seven"`
}

type FSCapabilities added in v1.23.0

type FSCapabilities struct {
	MaxIO           int    `json:"maxIo"`
	Symlinks        bool   `json:"symlinks"`
	Chmod           bool   `json:"chmod"`
	CaseInsensitive bool   `json:"caseInsensitive"`
	Normalization   string `json:"normalization"`
	Ranges          bool   `json:"ranges"`
}

type Frame

type Frame struct {
	Type    FrameType
	ID      uint32
	Payload []byte
}

func DecodeFrame

func DecodeFrame(b []byte) (Frame, error)

type FrameType

type FrameType byte
const (
	FrameOpen   FrameType = 1
	FrameOpened FrameType = 2
	FrameData   FrameType = 3
	FrameEnd    FrameType = 4
	FrameReset  FrameType = 5
	FrameCredit FrameType = 6
)

func (FrameType) String

func (t FrameType) String() string

type Handler

type Handler func(*Stream)

type Hello

type Hello struct {
	V          int       `json:"v"`
	Role       Role      `json:"role"`
	Name       string    `json:"name,omitempty"`
	Host       string    `json:"host,omitempty"`
	Version    string    `json:"version,omitempty"`
	Mode       string    `json:"mode,omitempty"`
	Node       string    `json:"node,omitempty"`
	Caps       []string  `json:"caps"`
	Routes     *Routes   `json:"routes,omitempty"`
	Policy     *Policy   `json:"policy,omitempty"`
	SSHHostKey string    `json:"sshHostKey,omitempty"`
	Browsers   []Browser `json:"browsers,omitempty"`
	Mounts     []Mount   `json:"mounts,omitempty"`
	Jerk       *Jerk     `json:"jerk,omitempty"`
	Kernel     *Kernel   `json:"kernel,omitempty"`

	Raw json.RawMessage `json:"-"`
}

func (Hello) HasCap

func (h Hello) HasCap(c string) bool

type Jerk added in v1.35.0

type Jerk struct {
	Version string `json:"version"`
}

type Kernel added in v1.47.0

type Kernel struct {
	Port int `json:"port"`
}
type Link struct {
	// contains filtered or unexported fields
}

func Answer

func Answer(ctx context.Context, api *webrtc.API, offer signal.Message, send func(context.Context, signal.Message) error, opts Options) (*Link, error)

func New

func New(pc *webrtc.PeerConnection, role Role, opts Options) (*Link, error)

func (*Link) AddCandidate

func (l *Link) AddCandidate(c *signal.Candidate) error

func (*Link) Close

func (l *Link) Close() error

func (*Link) Done

func (l *Link) Done() <-chan struct{}

func (*Link) Err

func (l *Link) Err() error

func (*Link) Open

func (l *Link) Open(ctx context.Context, open any, opts OpenOptions) (*Stream, error)

func (*Link) PeerConnection

func (l *Link) PeerConnection() *webrtc.PeerConnection

func (*Link) PeerHello

func (l *Link) PeerHello() (Hello, bool)

func (*Link) Ready

func (l *Link) Ready() <-chan struct{}

func (*Link) Role

func (l *Link) Role() Role

type Mount added in v1.23.0

type Mount struct {
	Name         string         `json:"name"`
	Readonly     bool           `json:"readonly"`
	Capabilities FSCapabilities `json:"capabilities"`
}

type OpenOptions

type OpenOptions struct {
	Shared bool
}

type Options

type Options struct {
	Hello        Hello
	Handlers     map[string]Handler
	Logf         func(format string, args ...any)
	HelloTimeout time.Duration
	MaxChannels  int
	Certificates []webrtc.Certificate
}

type Policy

type Policy struct {
	Allow   []string `json:"allow"`
	Deny    []string `json:"deny"`
	Summary string   `json:"summary"`
}

type ResetError

type ResetError struct {
	Code    string
	Message string
	Remote  bool
}

func ParseReset

func ParseReset(reason string) *ResetError

func (*ResetError) Error

func (e *ResetError) Error() string

func (*ResetError) Reason

func (e *ResetError) Reason() string

type Role

type Role string
const (
	RolePage Role = "page"
	RoleNode Role = "node"
)

type Routes

type Routes struct {
	Prefixes []string `json:"prefixes"`
	Exit     bool     `json:"exit"`
}

type Stream

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

func (*Stream) Accept

func (s *Stream) Accept(opened any) error

func (*Stream) CloseWrite

func (s *Stream) CloseWrite() error

func (*Stream) Conn added in v1.14.0

func (s *Stream) Conn() net.Conn

func (*Stream) Done

func (s *Stream) Done() <-chan struct{}

func (*Stream) Err

func (s *Stream) Err() error

func (*Stream) ID

func (s *Stream) ID() uint32

func (*Stream) Kind

func (s *Stream) Kind() string
func (s *Stream) Link() *Link

func (*Stream) Local

func (s *Stream) Local() bool

func (*Stream) OpenPayload

func (s *Stream) OpenPayload() json.RawMessage

func (*Stream) OpenedPayload

func (s *Stream) OpenedPayload() json.RawMessage

func (*Stream) Read

func (s *Stream) Read(p []byte) (int, error)

func (*Stream) Reset

func (s *Stream) Reset(reason string) error

func (*Stream) SetReadDeadline added in v1.14.0

func (s *Stream) SetReadDeadline(t time.Time) error

func (*Stream) SetWriteDeadline added in v1.14.0

func (s *Stream) SetWriteDeadline(t time.Time) error

func (*Stream) Shared

func (s *Stream) Shared() bool

func (*Stream) TryWrite added in v1.42.0

func (s *Stream) TryWrite(p []byte) (bool, error)

func (*Stream) Write

func (s *Stream) Write(p []byte) (int, error)

func (*Stream) WriteTo

func (s *Stream) WriteTo(w io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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