kuic

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

README

kuic

基于 quic-go 实现同一端口,同时当服务端又当客户端,从而实现nat穿透

使用前可能需要

go mod edit -replace github.com/quic-go/quic-go=github.com/chuccp/quic-go@v0.0.4

Documentation

Index

Constants

View Source
const MaxPacketBufferSize = 1452
View Source
const MaxSeqNum uint16 = 0x7FFF

Variables

View Source
var ErrConnNumOver = errors.New("conn number Over")

Functions

func NewBaseServer

func NewBaseServer(udpConn *net.UDPConn, context context.Context) *baseServer

Types

type Addr

type Addr struct {
	net.Addr
	// contains filtered or unexported fields
}

func NewAddr

func NewAddr(addr net.Addr, seq uint16) *Addr

func (*Addr) Network

func (a *Addr) Network() string

func (*Addr) String

func (a *Addr) String() string

type BaseServer

type BaseServer interface {
	GetServerConn() (*BasicConn, error)
	GetClientConn() (*BasicConn, error)
}

type BasicConn added in v0.0.17

type BasicConn struct {
	net.PacketConn
	UDPConn *net.UDPConn
	// contains filtered or unexported fields
}

func NewBasicConn

func NewBasicConn(conn *net.UDPConn, writeToFunc WriteToFunc, lAddr net.Addr, ctx context.Context) *BasicConn

func (*BasicConn) Close added in v0.0.17

func (c *BasicConn) Close() error

func (*BasicConn) GetContext added in v0.0.17

func (c *BasicConn) GetContext() context.Context

func (*BasicConn) LocalAddr added in v0.0.17

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

func (*BasicConn) ReadFrom added in v0.0.17

func (c *BasicConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

func (*BasicConn) SetReadBuffer added in v0.0.17

func (c *BasicConn) SetReadBuffer(bytes int) error

func (*BasicConn) SetReadDeadline added in v0.0.17

func (c *BasicConn) SetReadDeadline(t time.Time) error

func (*BasicConn) SetWriteBuffer added in v0.0.17

func (c *BasicConn) SetWriteBuffer(bytes int) error

func (*BasicConn) WaitClose added in v0.0.17

func (c *BasicConn) WaitClose()

func (*BasicConn) WriteTo added in v0.0.17

func (c *BasicConn) WriteTo(ps []byte, rAddr net.Addr) (n int, err error)

type Connection

type Connection interface {
	AcceptStream() (quic.Stream, error)
	OpenStreamSync() (quic.Stream, error)
	Close() error
}

type Listener

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

func Listen

func Listen(addr *net.UDPAddr) (*Listener, error)

func (*Listener) Accept

func (l *Listener) Accept() (Connection, error)

func (*Listener) Close

func (l *Listener) Close() error

func (*Listener) Dial

func (l *Listener) Dial(addr *net.UDPAddr) (Connection, error)

func (*Listener) GetClientConn

func (l *Listener) GetClientConn() (net.PacketConn, error)

func (*Listener) GetServerConn

func (l *Listener) GetServerConn() (net.PacketConn, error)

type WriteToFunc

type WriteToFunc func(ps []byte, addr net.Addr) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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