mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 22:55:06 +03:00
Merge 50f6327722
into 3c2e14801d
This commit is contained in:
commit
7e1f151048
8 changed files with 19 additions and 5 deletions
|
@ -80,6 +80,7 @@ type NodeConfig struct {
|
|||
SwitchOptions SwitchOptions `comment:"Advanced options for tuning the switch. Normally you will not need\nto edit these options."`
|
||||
NodeInfoPrivacy bool `comment:"By default, nodeinfo contains some defaults including the platform,\narchitecture and Yggdrasil version. These can help when surveying\nthe network and diagnosing network routing problems. Enabling\nnodeinfo privacy prevents this, so that only items specified in\n\"NodeInfo\" are sent back if specified."`
|
||||
NodeInfo map[string]interface{} `comment:"Optional node info. This must be a { \"key\": \"value\", ... } map\nor set as null. This is entirely optional but, if set, is visible\nto the whole network on request."`
|
||||
TCPCongestionControl string `json:",omitempty" comment:"Optional TCP congestion control algorithm used for connections. If not set, a system-wide setting is applied. Linux-only."`
|
||||
}
|
||||
|
||||
// SessionFirewall controls the session firewall configuration.
|
||||
|
@ -135,6 +136,7 @@ func GenerateConfig() *NodeConfig {
|
|||
cfg.SessionFirewall.AlwaysAllowOutbound = true
|
||||
cfg.SwitchOptions.MaxTotalQueueSize = 4 * 1024 * 1024
|
||||
cfg.NodeInfoPrivacy = false
|
||||
cfg.TCPCongestionControl = defaults.GetDefaults().DefaultTCPCongestionControl
|
||||
|
||||
return &cfg
|
||||
}
|
||||
|
|
|
@ -19,4 +19,5 @@ type platformDefaultParameters struct {
|
|||
MaximumIfMTU types.MTU
|
||||
DefaultIfMTU types.MTU
|
||||
DefaultIfName string
|
||||
DefaultTCPCongestionControl string
|
||||
}
|
||||
|
|
|
@ -22,5 +22,6 @@ func GetDefaults() platformDefaultParameters {
|
|||
MaximumIfMTU: 65535,
|
||||
DefaultIfMTU: 65535,
|
||||
DefaultIfName: "auto",
|
||||
DefaultTCPCongestionControl: "",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,5 +21,6 @@ func GetDefaults() platformDefaultParameters {
|
|||
MaximumIfMTU: 65535,
|
||||
DefaultIfMTU: 65535,
|
||||
DefaultIfName: "auto",
|
||||
DefaultTCPCongestionControl: "bbr",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,5 +21,6 @@ func GetDefaults() platformDefaultParameters {
|
|||
MaximumIfMTU: 16384,
|
||||
DefaultIfMTU: 16384,
|
||||
DefaultIfName: "tun0",
|
||||
DefaultTCPCongestionControl: "",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,5 +21,6 @@ func GetDefaults() platformDefaultParameters {
|
|||
MaximumIfMTU: 65535,
|
||||
DefaultIfMTU: 65535,
|
||||
DefaultIfName: "none",
|
||||
DefaultTCPCongestionControl: "",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,5 +21,6 @@ func GetDefaults() platformDefaultParameters {
|
|||
MaximumIfMTU: 65535,
|
||||
DefaultIfMTU: 65535,
|
||||
DefaultIfName: "Yggdrasil",
|
||||
DefaultTCPCongestionControl: "",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,19 +11,25 @@ import (
|
|||
// WARNING: This context is used both by net.Dialer and net.Listen in tcp.go
|
||||
|
||||
func (t *tcp) tcpContext(network, address string, c syscall.RawConn) error {
|
||||
var tcp_cca = t.links.core.config.Current.TCPCongestionControl
|
||||
var control error
|
||||
var bbr error
|
||||
var ret error
|
||||
|
||||
// do not change TCP congestion control algorithm so that a system-wide one is used
|
||||
if tcp_cca == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
control = c.Control(func(fd uintptr) {
|
||||
bbr = unix.SetsockoptString(int(fd), unix.IPPROTO_TCP, unix.TCP_CONGESTION, "bbr")
|
||||
ret = unix.SetsockoptString(int(fd), unix.IPPROTO_TCP, unix.TCP_CONGESTION, tcp_cca)
|
||||
})
|
||||
|
||||
// Log any errors
|
||||
if bbr != nil {
|
||||
t.links.core.log.Debugln("Failed to set tcp_congestion_control to bbr for socket, SetsockoptString error:", bbr)
|
||||
if ret != nil {
|
||||
t.links.core.log.Debugf("Failed to set tcp_congestion_control to %s for socket, SetsockoptString error: %s\n", tcp_cca, ret)
|
||||
}
|
||||
if control != nil {
|
||||
t.links.core.log.Debugln("Failed to set tcp_congestion_control to bbr for socket, Control error:", control)
|
||||
t.links.core.log.Debugf("Failed to set tcp_congestion_control to %s for socket, Control error:\n", tcp_cca, control)
|
||||
}
|
||||
|
||||
// Return nil because errors here are not considered fatal for the connection, it just means congestion control is suboptimal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue