quic

package
v1.2.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package quic defines functions to listen and dial quic, with some customizable congestion settings.

我们这里暂时使用 quic-go包。注意该包是不完美的,对阻塞控制支持不好,而且cpu占用率高。以后有更好的包的话要及时切换到好包。

这里我们 还选择性 使用 hysteria的 brutal阻控. 见 https://github.com/tobyxdd/quic-go 中 toby的 *-mod 分支, 里面会多一个 congestion 文件夹.

Index

Constants

View Source
const (
	//100mbps
	Default_hysteriaMaxByteCount = 1024 * 1024 / 8 * 100
)

Variables

View Source
var (
	//h3
	DefaultAlpnList = []string{"h3"}
)
View Source
var TheCustomRate = 0.75

Functions

func CloseConn

func CloseConn(conn any)

func ListenInitialLayers

func ListenInitialLayers(addr string, tlsConf tls.Config, arg arguments) (newConnChan chan net.Conn, returnCloser io.Closer)

non-blocking

Types

type BrutalSender

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

func NewBrutalSender

func NewBrutalSender(bps congestion.ByteCount) *BrutalSender

func (*BrutalSender) CanSend

func (b *BrutalSender) CanSend(bytesInFlight congestion.ByteCount) bool

func (*BrutalSender) GetCongestionWindow

func (b *BrutalSender) GetCongestionWindow() congestion.ByteCount

func (*BrutalSender) HasPacingBudget

func (b *BrutalSender) HasPacingBudget() bool

func (*BrutalSender) InRecovery

func (b *BrutalSender) InRecovery() bool

func (*BrutalSender) InSlowStart

func (b *BrutalSender) InSlowStart() bool

func (*BrutalSender) MaybeExitSlowStart

func (b *BrutalSender) MaybeExitSlowStart()

func (*BrutalSender) OnPacketAcked

func (b *BrutalSender) OnPacketAcked(number congestion.PacketNumber, ackedBytes congestion.ByteCount,
	priorInFlight congestion.ByteCount, eventTime time.Time)

func (*BrutalSender) OnPacketLost

func (b *BrutalSender) OnPacketLost(number congestion.PacketNumber, lostBytes congestion.ByteCount,
	priorInFlight congestion.ByteCount)

func (*BrutalSender) OnPacketSent

func (b *BrutalSender) OnPacketSent(sentTime time.Time, bytesInFlight congestion.ByteCount,
	packetNumber congestion.PacketNumber, bytes congestion.ByteCount, isRetransmittable bool)

func (*BrutalSender) OnRetransmissionTimeout

func (b *BrutalSender) OnRetransmissionTimeout(packetsRetransmitted bool)

func (*BrutalSender) SetMaxDatagramSize

func (b *BrutalSender) SetMaxDatagramSize(size congestion.ByteCount)

func (*BrutalSender) SetRTTStatsProvider

func (b *BrutalSender) SetRTTStatsProvider(rttStats congestion.RTTStatsProvider)

func (*BrutalSender) TimeUntilSend

func (b *BrutalSender) TimeUntilSend(bytesInFlight congestion.ByteCount) time.Time

type BrutalSender_M

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

func NewBrutalSender_M

func NewBrutalSender_M(bps congestion.ByteCount) *BrutalSender_M

func (*BrutalSender_M) CanSend

func (b *BrutalSender_M) CanSend(bytesInFlight congestion.ByteCount) bool

func (*BrutalSender_M) GetCongestionWindow

func (b *BrutalSender_M) GetCongestionWindow() congestion.ByteCount

func (*BrutalSender_M) HasPacingBudget

func (b *BrutalSender_M) HasPacingBudget() bool

func (*BrutalSender_M) InRecovery

func (b *BrutalSender_M) InRecovery() bool

func (*BrutalSender_M) InSlowStart

func (b *BrutalSender_M) InSlowStart() bool

func (*BrutalSender_M) MaybeExitSlowStart

func (b *BrutalSender_M) MaybeExitSlowStart()

func (*BrutalSender_M) OnPacketAcked

func (b *BrutalSender_M) OnPacketAcked(number congestion.PacketNumber, ackedBytes congestion.ByteCount, priorInFlight congestion.ByteCount, eventTime time.Time)

func (*BrutalSender_M) OnPacketLost

func (b *BrutalSender_M) OnPacketLost(number congestion.PacketNumber, lostBytes congestion.ByteCount, priorInFlight congestion.ByteCount)

func (*BrutalSender_M) OnPacketSent

func (b *BrutalSender_M) OnPacketSent(sentTime time.Time, bytesInFlight congestion.ByteCount,
	packetNumber congestion.PacketNumber, bytes congestion.ByteCount, isRetransmittable bool)

func (*BrutalSender_M) OnRetransmissionTimeout

func (b *BrutalSender_M) OnRetransmissionTimeout(packetsRetransmitted bool)

func (*BrutalSender_M) SetMaxDatagramSize

func (b *BrutalSender_M) SetMaxDatagramSize(size congestion.ByteCount)

func (*BrutalSender_M) SetRTTStatsProvider

func (b *BrutalSender_M) SetRTTStatsProvider(rttStats congestion.RTTStatsProvider)

func (*BrutalSender_M) TimeUntilSend

func (b *BrutalSender_M) TimeUntilSend(bytesInFlight congestion.ByteCount) time.Time

type Client

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

implements advLayer.MuxClient

func NewClient

func NewClient(addr *netLayer.Addr, alpnList []string, host string, insecure bool, args arguments) *Client

func (*Client) DialSubConn

func (c *Client) DialSubConn(thing any) (net.Conn, error)

func (*Client) GetCommonConn

func (c *Client) GetCommonConn(_ net.Conn) (any, error)

获取已拨号的连接,或者重新从底层拨号。返回一个可作 c.DialSubConn 参数 的值.

func (*Client) GetPath

func (c *Client) GetPath() string

func (*Client) IsEarly

func (c *Client) IsEarly() bool

func (*Client) IsMux

func (c *Client) IsMux() bool

func (*Client) IsSuper

func (c *Client) IsSuper() bool

type Creator

type Creator struct{}

func (Creator) GetDefaultAlpn

func (Creator) GetDefaultAlpn() (alpn string, mustUse bool)

func (Creator) NewClientFromConf

func (Creator) NewClientFromConf(conf *advLayer.Conf) (advLayer.Client, error)

func (Creator) NewServerFromConf

func (Creator) NewServerFromConf(conf *advLayer.Conf) (advLayer.Server, error)

func (Creator) PackageID

func (Creator) PackageID() string

type Server

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

func (*Server) GetPath

func (s *Server) GetPath() string

func (*Server) IsMux

func (*Server) IsMux() bool

func (*Server) IsSuper

func (*Server) IsSuper() bool

func (*Server) StartHandle

func (s *Server) StartHandle(underlay net.Conn, newSubConnChan chan net.Conn, fallbackConnChan chan advLayer.FallbackMeta)

非阻塞,不支持回落。

func (*Server) StartListen

func (s *Server) StartListen() (newSubConnChan chan net.Conn, baseConn io.Closer)

func (*Server) Stop

func (s *Server) Stop()

type StreamConn

type StreamConn struct {
	quic.Stream
	// contains filtered or unexported fields
}

implements net.Conn.

func (*StreamConn) Close

func (sc *StreamConn) Close() error

func (*StreamConn) LocalAddr

func (sc *StreamConn) LocalAddr() net.Addr

func (*StreamConn) RemoteAddr

func (sc *StreamConn) RemoteAddr() net.Addr

Jump to

Keyboard shortcuts

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