bind

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WsStatusBase websocket.StatusCode = 3000

	WsStatusBadRequest         = WsStatusBase + http.StatusBadRequest
	WsStatusServiceUnavailable = WsStatusBase + http.StatusServiceUnavailable
	WsStatusNotAcceptable      = WsStatusBase + http.StatusNotAcceptable
	WsStatusTemporaryRedirect  = WsStatusBase + http.StatusTemporaryRedirect
	WsStatusPermanentRedirect  = WsStatusBase + http.StatusPermanentRedirect
	WsStatusClientClosed       = WsStatusBase + 499
)
View Source
const BatchSize = 1
View Source
const MTU = 2400 - 80

Variables

View Source
var ErrEndpointImpl = errors.New("endpoint is not wgortc.Endpoint")
View Source
var ErrNoDataChannel = errors.New("no available data channel")
View Source
var ErrWSCDrop = errors.New("drop data when ws transport disabled")
View Source
var ErrWebRTCDisabled = errors.New("drop data when ws transport disabled")
View Source
var WsAcceptOptions = &websocket.AcceptOptions{
	OriginPatterns: []string{"*"},
	Subprotocols:   []string{magicStr},
}

Functions

This section is empty.

Types

type Bind

type Bind struct {
	Device atomic.Pointer[device.Device]
	// contains filtered or unexported fields
}

func New

func New(config Config) *Bind

func (*Bind) BatchSize

func (*Bind) BatchSize() int

func (*Bind) Close

func (b *Bind) Close() error

func (*Bind) GetDevice added in v0.7.0

func (b *Bind) GetDevice() *device.Device

func (*Bind) NewPeerConnection

func (b *Bind) NewPeerConnection(cfg webrtc.Configuration) (*webrtc.PeerConnection, error)

func (*Bind) Open

func (b *Bind) Open(port uint16) (fns []conn.ReceiveFunc, actualPort uint16, err error)

func (*Bind) ParseEndpoint

func (b *Bind) ParseEndpoint(s string) (conn.Endpoint, error)

func (*Bind) Receive

func (b *Bind) Receive(ep conn.Endpoint, buf []byte) bool

func (*Bind) Send

func (*Bind) Send(bufs [][]byte, ep conn.Endpoint) error

func (*Bind) ServeHTTP

func (b *Bind) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Bind) SetLogger added in v0.5.0

func (b *Bind) SetLogger(logger *slog.Logger)

func (*Bind) SetMark

func (*Bind) SetMark(mark uint32) error

func (*Bind) SetName

func (b *Bind) SetName(name string)

type Config

type Config interface {
	GetPeer(initiator []byte, endpoint string) Peer
}

type Endpoint

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

func (*Endpoint) ClearSrc

func (ep *Endpoint) ClearSrc()

func (*Endpoint) DstIP

func (*Endpoint) DstIP() netip.Addr

func (*Endpoint) DstToBytes

func (ep *Endpoint) DstToBytes() []byte

func (*Endpoint) DstToString

func (ep *Endpoint) DstToString() (addr string)

func (*Endpoint) Send

func (ep *Endpoint) Send(buf []byte) error

func (*Endpoint) SrcIP

func (*Endpoint) SrcIP() netip.Addr

func (*Endpoint) SrcToString

func (ep *Endpoint) SrcToString() string

type HandshakeInitiation

type HandshakeInitiation struct {
	Initiator []byte `json:"initiator"`

	Extra json.RawMessage `json:"extra"`
}

type HandshakeResponse

type HandshakeResponse struct {
	TransportMode uint32 `json:"transport_mode"`

	Extra json.RawMessage `json:"extra"`
}

type Inbound

type Inbound struct {
	Endpoint
	nat.INAT
}

type Outbound

type Outbound struct {
	Endpoint
	nat.INAT
	// contains filtered or unexported fields
}

func (*Outbound) ClearSrc

func (ep *Outbound) ClearSrc()

func (*Outbound) Send

func (ep *Outbound) Send(buf []byte) error

type Packet

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

type Peer

type Peer interface {
	GetID() string // 用以辨别节点
	GetPeerInit() webrtc.Configuration
}

type PeerEndpiontRedirected added in v0.5.0

type PeerEndpiontRedirected interface {
	EndpiontRedirected(link string, lc int)
}

type PeerHandshakeHook added in v0.8.0

type PeerHandshakeHook interface {
	HandshakeInitiationHook(initiator *HandshakeInitiation)
	HandshakeResponseHook(hresp *HandshakeResponse)
	HandshakedHook(ep conn.Endpoint)
}

type PeerMode added in v0.3.0

type PeerMode interface {
	TransportMode() TransportMode
}

type PeerPubkey added in v0.7.0

type PeerPubkey interface {
	GetPubkey() device.NoisePublicKey
}

type TransportMode added in v0.3.0

type TransportMode uint32
const (
	WSTransportDisabled TransportMode = 1 << (iota + 1)
	WebRTCTransportDisabled
	WSRedirectEnabled
)
const (
	AllTransportDisabled TransportMode = WSTransportDisabled | WebRTCTransportDisabled
)

type WireGuardMessageType

type WireGuardMessageType = uint8
const (
	WireGuardMessageInitiator WireGuardMessageType = iota + 1
	WireGuardMessageResponder

	WireGuardMessageData
)

Directories

Path Synopsis
config
internal
wasm_test command

Jump to

Keyboard shortcuts

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