diff options
| author | Matthieu Baerts <matthieu.baerts@tessares.net> | 2023-03-20 10:35:51 +0100 |
|---|---|---|
| committer | Emmanuel Odeke <emmanuel@orijtech.com> | 2023-03-24 10:41:21 +0000 |
| commit | e4abe90bf8bee451971c4b23d4418a9fc021c4a8 (patch) | |
| tree | bf1777a05355aa2390da193e6fffdafe8b2e78e1 | |
| parent | 7ec2e8442415bd7d15819cf2aeba3a678223c81c (diff) | |
| download | go-e4abe90bf8bee451971c4b23d4418a9fc021c4a8.tar.xz | |
net: add mptcpStatus type
This new type will be used in the following commits.
The goal is to have a tristate, an enum with three values:
- system default (0)
- enabled
- disabled
The system default value is linked to defaultMPTCPEnabled: disabled by
default for the moment. Users will be able to force enabling/disabling
MPTCP or use the default behaviour.
This work has been co-developped by Gregory Detal
<gregory.detal@tessares.net>.
Updates #56539
Change-Id: I8fa0cad7a18ca967508799fc828ef060b27683d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/477735
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
| -rw-r--r-- | src/net/dial.go | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/net/dial.go b/src/net/dial.go index 85ec557575..35c2761d29 100644 --- a/src/net/dial.go +++ b/src/net/dial.go @@ -11,12 +11,45 @@ import ( "time" ) -// defaultTCPKeepAlive is a default constant value for TCPKeepAlive times -// See golang.org/issue/31510 const ( + // defaultTCPKeepAlive is a default constant value for TCPKeepAlive times + // See go.dev/issue/31510 defaultTCPKeepAlive = 15 * time.Second + + // For the moment, MultiPath TCP is not used by default + // See go.dev/issue/56539 + defaultMPTCPEnabled = false ) +// mptcpStatus is a tristate for Multipath TCP, see go.dev/issue/56539 +type mptcpStatus uint8 + +const ( + // The value 0 is the system default, linked to defaultMPTCPEnabled + mptcpUseDefault mptcpStatus = iota + mptcpEnabled + mptcpDisabled +) + +func (m *mptcpStatus) get() bool { + switch *m { + case mptcpEnabled: + return true + case mptcpDisabled: + return false + } + + return defaultMPTCPEnabled +} + +func (m *mptcpStatus) set(use bool) { + if use { + *m = mptcpEnabled + } else { + *m = mptcpDisabled + } +} + // A Dialer contains options for connecting to an address. // // The zero value for each field is equivalent to dialing |
