Skip to content

Commit

Permalink
Add support for Multipath TCP
Browse files Browse the repository at this point in the history
  • Loading branch information
neilalexander committed Aug 12, 2023
1 parent 5b203ad commit 3e33512
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/link_tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (l *links) newLinkTCP() *linkTCP {
_listeners: map[*Listener]context.CancelFunc{},
}
lt.listenconfig.Control = lt.tcpContext
setMPTCPForListener(lt.listenconfig)
return lt
}

Expand Down Expand Up @@ -118,6 +119,7 @@ func (l *linkTCP) dialerFor(dst *net.TCPAddr, sintf string) (*net.Dialer, error)
KeepAlive: -1,
Control: l.tcpContext,
}
setMPTCPForDialer(dialer)
if sintf != "" {
dialer.Control = l.getControl(sintf)
ief, err := net.InterfaceByName(sintf)
Expand Down
14 changes: 14 additions & 0 deletions src/core/link_tcp_mptcp_go121.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//go:build go1.21
// +build go1.21

package core

import "net"

func setMPTCPForDialer(d *net.Dialer) {
d.SetMultipathTCP(true)
}

func setMPTCPForListener(lc *net.ListenConfig) {
lc.SetMultipathTCP(true)
}
14 changes: 14 additions & 0 deletions src/core/link_tcp_mptcp_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//go:build !go1.21
// +build !go1.21

package core

import "net"

func setMPTCPForDialer(d *net.Dialer) {
// Not supported on versions under Go 1.21
}

func setMPTCPForListener(lc *net.ListenConfig) {
// Not supported on versions under Go 1.21
}
1 change: 1 addition & 0 deletions src/core/link_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (l *links) newLinkTLS(tcp *linkTCP) *linkTLS {
config: l.core.config.tls.Clone(),
_listeners: map[*Listener]context.CancelFunc{},
}
setMPTCPForListener(lt.listener)
return lt
}

Expand Down

0 comments on commit 3e33512

Please sign in to comment.