Skip to content

Commit

Permalink
Update the behavior of ignore_client_bandwidth
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Jan 7, 2025
1 parent 06d01d2 commit da0a868
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions hysteria2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (s *serverSession[U]) ServeHTTP(w http.ResponseWriter, r *http.Request) {
protocol.AuthResponseToHeader(w.Header(), protocol.AuthResponse{
UDPEnabled: !s.udpDisabled,
Rx: s.receiveBPS,
RxAuto: s.ignoreClientBandwidth,
RxAuto: s.receiveBPS == 0 && s.ignoreClientBandwidth,
})
w.WriteHeader(protocol.StatusAuthOK)
return
Expand All @@ -201,7 +201,12 @@ func (s *serverSession[U]) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
s.authUser = user
s.authenticated = true
if !s.ignoreClientBandwidth && request.Rx > 0 {
var rxAuto bool
if s.receiveBPS > 0 && s.ignoreClientBandwidth && request.Rx == 0 {
s.logger.Debug("process connection from ", r.RemoteAddr, ": BBR disabled by server")
s.masqueradeHandler.ServeHTTP(w, r)
return
} else if !(s.receiveBPS == 0 && s.ignoreClientBandwidth) && request.Rx > 0 {
rx := request.Rx
if s.sendBPS > 0 && rx > s.sendBPS {
rx = s.sendBPS
Expand All @@ -217,11 +222,12 @@ func (s *serverSession[U]) ServeHTTP(w http.ResponseWriter, r *http.Request) {
congestion.ByteCount(s.quicConn.Config().InitialPacketSize),
congestion.ByteCount(congestion_meta1.InitialCongestionWindow),
))
rxAuto = true
}
protocol.AuthResponseToHeader(w.Header(), protocol.AuthResponse{
UDPEnabled: !s.udpDisabled,
Rx: s.receiveBPS,
RxAuto: s.ignoreClientBandwidth,
RxAuto: rxAuto,
})
w.WriteHeader(protocol.StatusAuthOK)
if s.ctx.Done() != nil {
Expand Down

0 comments on commit da0a868

Please sign in to comment.