Skip to content

Commit

Permalink
Merge branch 'v0.38.1-mod' into fix-gso
Browse files Browse the repository at this point in the history
# Conflicts:
#	internal/ackhandler/sent_packet_handler.go
#	internal/mocks/ackhandler/sent_packet_handler.go
#	mock_quic_conn_test.go
  • Loading branch information
tobyxdd committed Sep 15, 2023
2 parents ab1c1be + 3c64636 commit 7f6f257
Show file tree
Hide file tree
Showing 24 changed files with 1,329 additions and 126 deletions.
93 changes: 93 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,96 @@ fuzzing/*/suppressions
fuzzing/*/corpus/

gomock_reflect_*/

# Created by https://www.toptal.com/developers/gitignore/api/goland+all
# Edit at https://www.toptal.com/developers/gitignore?templates=goland+all

### GoLand+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### GoLand+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

!.idea/codeStyles
!.idea/runConfigurations

# End of https://www.toptal.com/developers/gitignore/api/goland+all
42 changes: 42 additions & 0 deletions congestion/interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package congestion

import (
"time"

"github.com/quic-go/quic-go/internal/protocol"
)

type (
ByteCount protocol.ByteCount
PacketNumber protocol.PacketNumber
)

type CongestionControl interface {
SetRTTStatsProvider(provider RTTStatsProvider)
TimeUntilSend(bytesInFlight ByteCount) time.Time
HasPacingBudget(now time.Time) bool
OnPacketSent(sentTime time.Time, bytesInFlight ByteCount, packetNumber PacketNumber, bytes ByteCount, isRetransmittable bool)
CanSend(bytesInFlight ByteCount) bool
MaybeExitSlowStart()
OnPacketAcked(number PacketNumber, ackedBytes ByteCount, priorInFlight ByteCount, eventTime time.Time)
OnPacketLost(number PacketNumber, lostBytes ByteCount, priorInFlight ByteCount)
OnRetransmissionTimeout(packetsRetransmitted bool)
SetMaxDatagramSize(size ByteCount)
InSlowStart() bool
InRecovery() bool
GetCongestionWindow() ByteCount
}

type RTTStatsProvider interface {
MinRTT() time.Duration
LatestRTT() time.Duration
SmoothedRTT() time.Duration
MeanDeviation() time.Duration
MaxAckDelay() time.Duration
PTO(includeMaxAckDelay bool) time.Duration
UpdateRTT(sendDelta, ackDelay time.Duration, now time.Time)
SetMaxAckDelay(mad time.Duration)
SetInitialRTT(t time.Duration)
OnConnectionMigration()
ExpireSmoothedMetrics()
}
23 changes: 21 additions & 2 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"sync/atomic"
"time"

"github.com/quic-go/quic-go/congestion"
"github.com/quic-go/quic-go/internal/ackhandler"
"github.com/quic-go/quic-go/internal/flowcontrol"
"github.com/quic-go/quic-go/internal/handshake"
Expand Down Expand Up @@ -864,6 +865,13 @@ func (s *connection) handlePacketImpl(rp receivedPacket) bool {
}
}

// Hysteria connection migration
// Set remote address to the address of the last received valid packet
if s.perspective == protocol.PerspectiveServer && processed {
// Connection migration
s.conn.SetRemoteAddr(rp.remoteAddr)
}

p.buffer.MaybeRelease()
return processed
}
Expand Down Expand Up @@ -2341,14 +2349,21 @@ func (s *connection) onStreamCompleted(id protocol.StreamID) {
}
}

type ErrMessageTooLarge int

func (e ErrMessageTooLarge) Error() string {
return fmt.Sprintf("message too large (maximum: %d bytes)", e)
}

func (s *connection) SendMessage(p []byte) error {
if !s.supportsDatagrams() {
return errors.New("datagram support disabled")
}

f := &wire.DatagramFrame{DataLenPresent: true}
if protocol.ByteCount(len(p)) > f.MaxDataLen(s.peerParams.MaxDatagramFrameSize, s.version) {
return errors.New("message too large")
maxDataLen := f.MaxDataLen(s.peerParams.MaxDatagramFrameSize, s.version)
if protocol.ByteCount(len(p)) > maxDataLen {
return ErrMessageTooLarge(maxDataLen)
}
f.Data = make([]byte, len(p))
copy(f.Data, p)
Expand Down Expand Up @@ -2383,3 +2398,7 @@ func (s *connection) NextConnection() Connection {
s.streamsMap.UseResetMaps()
return s
}

func (s *connection) SetCongestionControl(cc congestion.CongestionControl) {
s.sentPacketHandler.SetCongestionControl(cc)
}
Loading

0 comments on commit 7f6f257

Please sign in to comment.