Update BBR and Hysteria congestion control & Migrate legacy Hysteria protocol to library

This commit is contained in:
世界
2023-10-21 12:00:00 +08:00
parent 3b161ab30c
commit 31c294d998
17 changed files with 214 additions and 1402 deletions

View File

@@ -0,0 +1,41 @@
package v2rayquic
import (
"net"
"github.com/sagernet/quic-go"
"github.com/sagernet/sing/common/baderror"
)
type StreamWrapper struct {
Conn quic.Connection
quic.Stream
}
func (s *StreamWrapper) Read(p []byte) (n int, err error) {
n, err = s.Stream.Read(p)
return n, baderror.WrapQUIC(err)
}
func (s *StreamWrapper) Write(p []byte) (n int, err error) {
n, err = s.Stream.Write(p)
return n, baderror.WrapQUIC(err)
}
func (s *StreamWrapper) LocalAddr() net.Addr {
return s.Conn.LocalAddr()
}
func (s *StreamWrapper) RemoteAddr() net.Addr {
return s.Conn.RemoteAddr()
}
func (s *StreamWrapper) Upstream() any {
return s.Stream
}
func (s *StreamWrapper) Close() error {
s.CancelRead(0)
s.Stream.Close()
return nil
}