Skip to content

Commit 04f423c

Browse files
committed
Add support for Multipath TCP
1 parent e5e8c84 commit 04f423c

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

src/core/link_tcp.go

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func (l *links) newLinkTCP() *linkTCP {
2727
_listeners: map[*Listener]context.CancelFunc{},
2828
}
2929
lt.listenconfig.Control = lt.tcpContext
30+
setMPTCPForListener(lt.listenconfig)
3031
return lt
3132
}
3233

@@ -112,6 +113,7 @@ func (l *linkTCP) dialerFor(dst *net.TCPAddr, sintf string) (*net.Dialer, error)
112113
KeepAlive: -1,
113114
Control: l.tcpContext,
114115
}
116+
setMPTCPForDialer(dialer)
115117
if sintf != "" {
116118
dialer.Control = l.getControl(sintf)
117119
ief, err := net.InterfaceByName(sintf)

src/core/link_tcp_mptcp_go121.go

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//go:build go1.21
2+
// +build go1.21
3+
4+
package core
5+
6+
import "net"
7+
8+
func setMPTCPForDialer(d *net.Dialer) {
9+
d.SetMultipathTCP(true)
10+
}
11+
12+
func setMPTCPForListener(lc *net.ListenConfig) {
13+
lc.SetMultipathTCP(true)
14+
}

src/core/link_tcp_mptcp_other.go

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//go:build !go1.21
2+
// +build !go1.21
3+
4+
package core
5+
6+
import "net"
7+
8+
func setMPTCPForDialer(d *net.Dialer) {
9+
// Not supported on versions under Go 1.21
10+
}
11+
12+
func setMPTCPForListener(lc *net.ListenConfig) {
13+
// Not supported on versions under Go 1.21
14+
}

src/core/link_tls.go

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func (l *links) newLinkTLS(tcp *linkTCP) *linkTLS {
3030
config: l.core.config.tls.Clone(),
3131
_listeners: map[*Listener]context.CancelFunc{},
3232
}
33+
setMPTCPForListener(lt.listener)
3334
return lt
3435
}
3536

0 commit comments

Comments
 (0)