Documentation
¶
Overview ¶
Package quic defines functions to listen and dial quic, with some customizable congestion settings.
这里我们使用 hysteria的 brutal阻控. 见 https://github.com/tobyxdd/quic-go 中 toby的 *-mod 分支, 里面会多一个 congestion 文件夹.
Index ¶
- Constants
- Variables
- func CloseConn(baseC any)
- func ListenInitialLayers(addr string, tlsConf tls.Config, useHysteria bool, hysteriaMaxByteCount int, ...) (newConnChan chan net.Conn, baseConn any)
- type BrutalSender
- func (b *BrutalSender) CanSend(bytesInFlight congestion.ByteCount) bool
- func (b *BrutalSender) GetCongestionWindow() congestion.ByteCount
- func (b *BrutalSender) HasPacingBudget() bool
- func (b *BrutalSender) InRecovery() bool
- func (b *BrutalSender) InSlowStart() bool
- func (b *BrutalSender) MaybeExitSlowStart()
- func (b *BrutalSender) OnPacketAcked(number congestion.PacketNumber, ackedBytes congestion.ByteCount, ...)
- func (b *BrutalSender) OnPacketLost(number congestion.PacketNumber, lostBytes congestion.ByteCount, ...)
- func (b *BrutalSender) OnPacketSent(sentTime time.Time, bytesInFlight congestion.ByteCount, ...)
- func (b *BrutalSender) OnRetransmissionTimeout(packetsRetransmitted bool)
- func (b *BrutalSender) SetMaxDatagramSize(size congestion.ByteCount)
- func (b *BrutalSender) SetRTTStatsProvider(rttStats congestion.RTTStatsProvider)
- func (b *BrutalSender) TimeUntilSend(bytesInFlight congestion.ByteCount) time.Time
- type BrutalSender_M
- func (b *BrutalSender_M) CanSend(bytesInFlight congestion.ByteCount) bool
- func (b *BrutalSender_M) GetCongestionWindow() congestion.ByteCount
- func (b *BrutalSender_M) HasPacingBudget() bool
- func (b *BrutalSender_M) InRecovery() bool
- func (b *BrutalSender_M) InSlowStart() bool
- func (b *BrutalSender_M) MaybeExitSlowStart()
- func (b *BrutalSender_M) OnPacketAcked(number congestion.PacketNumber, ackedBytes congestion.ByteCount, ...)
- func (b *BrutalSender_M) OnPacketLost(number congestion.PacketNumber, lostBytes congestion.ByteCount, ...)
- func (b *BrutalSender_M) OnPacketSent(sentTime time.Time, bytesInFlight congestion.ByteCount, ...)
- func (b *BrutalSender_M) OnRetransmissionTimeout(packetsRetransmitted bool)
- func (b *BrutalSender_M) SetMaxDatagramSize(size congestion.ByteCount)
- func (b *BrutalSender_M) SetRTTStatsProvider(rttStats congestion.RTTStatsProvider)
- func (b *BrutalSender_M) TimeUntilSend(bytesInFlight congestion.ByteCount) time.Time
- type Client
- type StreamConn
Constants ¶
View Source
const (
//100mbps
Default_hysteriaMaxByteCount = 1024 * 1024 / 8 * 100
)
Variables ¶
View Source
var (
AlpnList = []string{"h3"}
)
View Source
var TheCustomRate = 0.75
Functions ¶
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
}
func (*Client) DialCommonConn ¶
获取已拨号的连接,或者重新从底层拨号。返回一个可作 c.DialSubConn 参数 的值.
type StreamConn ¶
type StreamConn struct { quic.Stream // contains filtered or unexported fields }
给 quic.Stream 添加 方法使其满足 net.Conn. quic.Stream 唯独不支持 LocalAddr 和 RemoteAddr 方法. 因为它是通过 StreamID 来识别连接. 不过session是有的。
func (StreamConn) Close ¶
func (sc StreamConn) Close() error
这里必须要同时调用 CancelRead 和 CancelWrite 因为 quic-go这个设计的是双工的,调用Close实际上只是间接调用了 CancelWrite 看 quic-go包中的 quic.SendStream 的注释就知道了.
func (StreamConn) LocalAddr ¶
func (sc StreamConn) LocalAddr() net.Addr
func (StreamConn) RemoteAddr ¶
func (sc StreamConn) RemoteAddr() net.Addr
Click to show internal directories.
Click to hide internal directories.