Documentation ¶
Overview ¶
Package quic defines functions to listen and dial quic, with some customizable congestion settings.
quic的包装太简单了, 直接参考 https://github.com/lucas-clemente/quic-go/blob/master/example/echo/echo.go
Hysteria Brutal Congestion Control ¶
这里我们 还选择性 使用 hysteria的 brutal阻控. 见 https://github.com/tobyxdd/quic-go 中 toby的 *-mod 分支, 里面会多一个 congestion 文件夹.
我们这里利用其阻控,但是没有使用hysteria的通知速率和 auth的 数据头,也就是说我们这里是纯quic协议的情况下使用了hysteria的优点。
我们要是以后不使用hysteria的话,只需删掉 useHysteria 里的代码, 删掉 pacer.go/brutal.go, 并删掉 go.mod中的replace部分. 然后proxy.go里的 相关配置部分也要删掉 在 prepareTLS_for* 函数中 的相关配置 即可.
Imperfect Package ¶
引用的 lucas-clemente/quic-go 包 是不完美的,它对阻塞控制支持不好,而且cpu占用率高。以后有更好的包的话要及时切换到好包。
我在macm1里实测,内网单机极速测速的情况下,本来tcp的vlesss能达到3000mbps的速度,到了vless+quic就只能达到 1333mbps左右。
实际上就是因为quic-go包占用cpu太猛了,导致cpu占用率达到100%瓶颈,所以速度无法进一步提高。
Index ¶
- Constants
- Variables
- func CloseConn(conn any)
- func ListenInitialLayers(addr string, tlsConf tls.Config, arg arguments) (newConnChan chan net.Conn, returnCloser io.Closer)
- func SniffQUIC(b []byte) (sni string)
- 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 Creator
- func (Creator) CanHandleHeaders() bool
- func (Creator) GetDefaultAlpn() (alpn string, mustUse bool)
- func (Creator) IsMux() bool
- func (Creator) IsSuper() bool
- func (Creator) NewClientFromConf(conf *advLayer.Conf) (advLayer.Client, error)
- func (Creator) NewServerFromConf(conf *advLayer.Conf) (advLayer.Server, error)
- func (Creator) PackageID() string
- func (Creator) ProtocolName() string
- type Server
- type StreamConn
Constants ¶
const ( //100mbps Default_hysteriaMaxByteCount = 1024 * 1024 / 8 * 100 Default_Server_maxStreamCountInOneConn = 4 //一个 Connection 中 stream越多, 性能越低, 因此我们这里限制为4 )
Variables ¶
var ( //h3 DefaultAlpnList = []string{"h3"} )
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 { Creator // contains filtered or unexported fields }
implements advLayer.MuxClient
func (*Client) GetCommonConn ¶
获取已拨号的连接 / 重新从底层拨号。返回 可作 c.DialSubConn 参数 的值.
func (*Client) GetCreator ¶ added in v1.2.0
type Creator ¶
type Creator struct{}
func (Creator) CanHandleHeaders ¶ added in v1.2.0
func (Creator) GetDefaultAlpn ¶
func (Creator) NewClientFromConf ¶
func (Creator) NewServerFromConf ¶
func (Creator) ProtocolName ¶ added in v1.2.0
type Server ¶
type Server struct { Creator // contains filtered or unexported fields }
implements advLayer.SuperMuxServer
func (*Server) StartHandle ¶
func (s *Server) StartHandle(underlay net.Conn, newSubConnChan chan net.Conn, fallbackConnChan chan httpLayer.FallbackMeta)
非阻塞,不支持回落。
func (*Server) StartListen ¶
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) Reject ¶ added in v1.2.4
func (sc *StreamConn) Reject()
implements netLayer.RejectConn, placeholder
func (*StreamConn) RejectBehaviorDefined ¶ added in v1.2.4
func (sc *StreamConn) RejectBehaviorDefined() bool
implements netLayer.RejectConn, return false
func (*StreamConn) RemoteAddr ¶
func (sc *StreamConn) RemoteAddr() net.Addr