]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/net/dial.go
net: mptcp: force using MPTCP with GODEBUG
[gostls13.git] / src / net / dial.go
index fd1da1ebef070002e3496e2d95e97cde1c4a4104..79bc4958bb291cf89aa98a198e449aed5fe5ff64 100644 (file)
@@ -6,6 +6,7 @@ package net
 
 import (
        "context"
+       "internal/godebug"
        "internal/nettrace"
        "syscall"
        "time"
@@ -21,6 +22,8 @@ const (
        defaultMPTCPEnabled = false
 )
 
+var multipathtcp = godebug.New("multipathtcp")
+
 // mptcpStatus is a tristate for Multipath TCP, see go.dev/issue/56539
 type mptcpStatus uint8
 
@@ -39,6 +42,13 @@ func (m *mptcpStatus) get() bool {
                return false
        }
 
+       // If MPTCP is forced via GODEBUG=multipathtcp=1
+       if multipathtcp.Value() == "1" {
+               multipathtcp.IncNonDefault()
+
+               return true
+       }
+
        return defaultMPTCPEnabled
 }
 
@@ -329,7 +339,7 @@ func (d *Dialer) MultipathTCP() bool {
 
 // SetMultipathTCP directs the Dial methods to use, or not use, MPTCP,
 // if supported by the operating system. This method overrides the
-// system default.
+// system default and the GODEBUG=multipathtcp=... setting if any.
 //
 // If MPTCP is not available on the host or not supported by the server,
 // the Dial methods will fall back to TCP.
@@ -690,7 +700,7 @@ func (lc *ListenConfig) MultipathTCP() bool {
 
 // SetMultipathTCP directs the Listen method to use, or not use, MPTCP,
 // if supported by the operating system. This method overrides the
-// system default.
+// system default and the GODEBUG=multipathtcp=... setting if any.
 //
 // If MPTCP is not available on the host or not supported by the client,
 // the Listen method will fall back to TCP.