conn

package
v0.0.0-...-afb774d Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoCopy

func GoCopy(src, dst io.ReadWriteCloser) error

func GoFunc

func GoFunc(ctx context.Context, f func(ctx context.Context) error)

Types

type ChanStatus

type ChanStatus string
const (
	Opening ChanStatus = "opening"
	Idle    ChanStatus = "idle"
	Active  ChanStatus = "active"
	Closed  ChanStatus = "closed"
)

type Channel

type Channel struct {
	Type webrtc.SDPType
	// contains filtered or unexported fields
}

func NewAnswerChannel

func NewAnswerChannel(sname, cid string, dc *webrtc.DataChannel, label *Label, accept, release chan ReadWriterReleaser) *Channel

func NewOfferChannel

func NewOfferChannel(sname, cid string, dc *webrtc.DataChannel, label *Label, release chan ReadWriterReleaser) *Channel

func (*Channel) Close

func (c *Channel) Close() error

func (*Channel) Label

func (c *Channel) Label() *Label

func (*Channel) LocalAddr

func (c *Channel) LocalAddr() net.Addr

func (*Channel) OnMessage

func (c *Channel) OnMessage(msg webrtc.DataChannelMessage)

func (*Channel) Read

func (c *Channel) Read(data []byte) (n int, err error)

func (*Channel) Release

func (c *Channel) Release()

func (*Channel) RemoteAddr

func (c *Channel) RemoteAddr() net.Addr

func (*Channel) TakeConn

func (c *Channel) TakeConn() bool

func (*Channel) Write

func (c *Channel) Write(data []byte) (int, error)

type ChannelPool

type ChannelPool struct {
	sync.RWMutex

	Type           webrtc.SDPType
	Id             string
	RemoteId       string
	RemoteClientId string
	// contains filtered or unexported fields
}

func NewChannelPool

func NewChannelPool(pc *webrtc.PeerConnection, rid, rcid string, pt webrtc.SDPType) *ChannelPool

func (*ChannelPool) Close

func (p *ChannelPool) Close() error

func (*ChannelPool) Get

func (p *ChannelPool) Get(ct ChannelType, labels ...string) (ch ReadWriterReleaser, err error)

func (*ChannelPool) OnChannelOpen

func (p *ChannelPool) OnChannelOpen(dc *webrtc.DataChannel) error

func (*ChannelPool) OnRelease

func (p *ChannelPool) OnRelease(label string)

type ChannelReader

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

func NewChannelReader

func NewChannelReader(batchSize int) *ChannelReader

func (*ChannelReader) OnData

func (r *ChannelReader) OnData(data []byte)

func (*ChannelReader) Read

func (r *ChannelReader) Read(p []byte) (int, error)

func (*ChannelReader) Release

func (c *ChannelReader) Release()

type ChannelType

type ChannelType string
const (
	Keepalive ChannelType = "keepalive"
	Cmd       ChannelType = "command"
	Web       ChannelType = "web"
	Proxy     ChannelType = "proxy"
	Ssh       ChannelType = "ssh"
	File      ChannelType = "file"
)

func (ChannelType) String

func (t ChannelType) String() string

type ClientAddr

type ClientAddr struct {
	Label    *Label
	ClientId string
}

func NewClientAddr

func NewClientAddr(clientId string, label *Label) *ClientAddr

func (*ClientAddr) Network

func (a *ClientAddr) Network() string

func (*ClientAddr) String

func (a *ClientAddr) String() string

type ClientId

type ClientId string

type ClientPeer

type ClientPeer struct {
	ClientId string
	PeerId   string
}

type ClusterName

type ClusterName string

type Command

type Command string
const (
	CmdConnect    Command = "connnect"
	CmdDisConnect Command = "disconnect"
	CmdEOF        Command = "EOF"
)

type DataChannelCommand

type DataChannelCommand struct {
	Cmd   Command
	Label string
}

type Label

type Label struct {
	ChannelType ChannelType
	Index       uint64
}

func NewLabel

func NewLabel(ct ChannelType, idx uint64) *Label

func (*Label) String

func (l *Label) String() string

type Peer

type Peer struct {
	*ChannelPool
	// contains filtered or unexported fields
}

func NewAnswerPeer

func NewAnswerPeer(sig Signalinger, remoteClientId, remoteId string, accept chan ReadWriterReleaser) (*Peer, error)

func NewOfferPeer

func NewOfferPeer(sig Signalinger, remoteClientId string) (*Peer, error)

func (*Peer) Close

func (p *Peer) Close() error

func (*Peer) Connect

func (p *Peer) Connect(ctx context.Context) error

func (*Peer) IsClose

func (p *Peer) IsClose() bool

func (*Peer) Listen

func (p *Peer) Listen(ctx context.Context) error

func (*Peer) OnConnectionStateChange

func (p *Peer) OnConnectionStateChange(pcs webrtc.PeerConnectionState)

func (*Peer) PollOffer

func (p *Peer) PollOffer(ctx context.Context) error

func (*Peer) SendAnswer

func (p *Peer) SendAnswer(ctx context.Context) error

func (*Peer) SendOffer

func (p *Peer) SendOffer(ctx context.Context) error

func (*Peer) WaitAnswer

func (p *Peer) WaitAnswer(ctx context.Context) error

type PeerId

type PeerId string

type ReadWriterReleaser

type ReadWriterReleaser interface {
	io.ReadWriter
	Label() *Label
	TakeConn() bool
	Release()
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
}

type ServerAddr

type ServerAddr struct {
	Label      *Label
	ServerName string
}

func NewServerAddr

func NewServerAddr(serverName string, label *Label) *ServerAddr

func (*ServerAddr) Network

func (a *ServerAddr) Network() string

func (*ServerAddr) String

func (a *ServerAddr) String() string

type Session

type Session struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSession

func NewSession(id string) *Session

func (*Session) Close

func (s *Session) Close()

func (*Session) IsClose

func (s *Session) IsClose() bool

func (*Session) OnIceCandidate

func (s *Session) OnIceCandidate(ice *webrtc.ICECandidate)

func (*Session) OnSdp

func (s *Session) OnSdp(sdp *webrtc.SessionDescription)

type SigStatus

type SigStatus string
const (
	StatusIdle      SigStatus = "idle"
	StatusFetch     SigStatus = "fetch"
	StatusKeepalive SigStatus = "kl"
)

type Signalinger

type Signalinger interface {
	Id() string
	NewPeer() chan ClientPeer
	SendPacket(ctx context.Context, p proto.Packet) error
	RemoteSdp(id string) chan webrtc.SessionDescription
	RemoteIceCandidates(id string) chan *webrtc.ICECandidate
	Run(ctx context.Context) error
	Close(ctx context.Context) error
	CloseSession(id string)
	IsClose() bool
}

type WsBackendSigClient

type WsBackendSigClient struct {
	*WsSigClient
	// contains filtered or unexported fields
}

func NewWsBackendSigClient

func NewWsBackendSigClient(id, wsURL, clusterName string) *WsBackendSigClient

func (*WsBackendSigClient) NewClient

func (c *WsBackendSigClient) NewClient() chan ClientPeer

func (*WsBackendSigClient) OnSession

func (c *WsBackendSigClient) OnSession(id, clientId string)

type WsFrontendSigClient

type WsFrontendSigClient struct {
	*WsSigClient
}

func NewWsFrontendSigClient

func NewWsFrontendSigClient(id, wsURL, clusterName string) *WsFrontendSigClient

func (*WsFrontendSigClient) NewClient

func (c *WsFrontendSigClient) NewClient() chan string

type WsSigClient

type WsSigClient struct {
	sync.RWMutex

	websocket.Upgrader

	Type webrtc.SDPType

	OnSession func(id, cid string)
	// contains filtered or unexported fields
}

func NewWsSigClient

func NewWsSigClient(id, wsURL, clusterName string) *WsSigClient

func (*WsSigClient) Close

func (c *WsSigClient) Close(ctx context.Context) error

func (*WsSigClient) CloseSession

func (c *WsSigClient) CloseSession(id string)

func (*WsSigClient) GetSession

func (c *WsSigClient) GetSession(id string) *Session

func (*WsSigClient) Id

func (c *WsSigClient) Id() string

func (*WsSigClient) IsClose

func (c *WsSigClient) IsClose() bool

func (*WsSigClient) RemoteIceCandidates

func (c *WsSigClient) RemoteIceCandidates(id string) chan *webrtc.ICECandidate

func (*WsSigClient) RemoteSdp

func (c *WsSigClient) RemoteSdp(id string) chan webrtc.SessionDescription

func (*WsSigClient) Run

func (c *WsSigClient) Run(ctx context.Context) error

func (*WsSigClient) SendPacket

func (c *WsSigClient) SendPacket(ctx context.Context, p proto.Packet) error

Jump to

Keyboard shortcuts

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