lib/config, lib/connections: Configurables for KCP, disable by default
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4030
This commit is contained in:
committed by
Audrius Butkevicius
parent
0da0774ce4
commit
81af29e3e2
@@ -22,23 +22,6 @@ const (
|
||||
kcpNoFilterPriority = 100
|
||||
kcpConversationFilterPriority = 20
|
||||
kcpStunFilterPriority = 10
|
||||
|
||||
// KCP SetNoDelay options
|
||||
|
||||
// 0 - disabled (default)
|
||||
// 1 - enabled
|
||||
kcpNoDelay = 0
|
||||
kcpUpdateInterval = 100 // ms (default)
|
||||
// 0 - disable (default)
|
||||
// 1 - enabled
|
||||
kcpFastResend = 0
|
||||
// 0 - enabled (default)
|
||||
// 1 - disabled
|
||||
kcpCongestionControl = 0
|
||||
|
||||
// KCP window sizes
|
||||
kcpSendWindowSize = 128
|
||||
kcpReceiveWindowSize = 128
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -49,11 +49,13 @@ func (d *kcpDialer) Dial(id protocol.DeviceID, uri *url.URL) (internalConn, erro
|
||||
return internalConn{}, err
|
||||
}
|
||||
|
||||
opts := d.cfg.Options()
|
||||
|
||||
conn.SetKeepAlive(0) // yamux and stun service does keep-alives.
|
||||
conn.SetStreamMode(true)
|
||||
conn.SetACKNoDelay(false)
|
||||
conn.SetWindowSize(kcpSendWindowSize, kcpReceiveWindowSize)
|
||||
conn.SetNoDelay(kcpNoDelay, kcpUpdateInterval, kcpFastResend, kcpCongestionControl)
|
||||
conn.SetWindowSize(opts.KCPSendWindowSize, opts.KCPReceiveWindowSize)
|
||||
conn.SetNoDelay(boolInt(opts.KCPNoDelay), opts.KCPUpdateIntervalMs, boolInt(opts.KCPFastResend), boolInt(!opts.KCPCongestionControl))
|
||||
|
||||
ses, err := yamux.Client(conn, yamuxConfig)
|
||||
if err != nil {
|
||||
|
||||
@@ -107,12 +107,13 @@ func (t *kcpListener) Serve() {
|
||||
continue
|
||||
}
|
||||
|
||||
conn.SetStreamMode(true)
|
||||
conn.SetACKNoDelay(false)
|
||||
conn.SetWindowSize(kcpSendWindowSize, kcpReceiveWindowSize)
|
||||
conn.SetNoDelay(kcpNoDelay, kcpUpdateInterval, kcpFastResend, kcpCongestionControl)
|
||||
opts := t.cfg.Options()
|
||||
|
||||
conn.SetKeepAlive(0) // yamux and stun service does keep-alives.
|
||||
conn.SetStreamMode(true)
|
||||
conn.SetACKNoDelay(false)
|
||||
conn.SetWindowSize(opts.KCPSendWindowSize, opts.KCPReceiveWindowSize)
|
||||
conn.SetNoDelay(boolInt(opts.KCPNoDelay), opts.KCPUpdateIntervalMs, boolInt(opts.KCPFastResend), boolInt(!opts.KCPCongestionControl))
|
||||
|
||||
l.Debugln("connect from", conn.RemoteAddr())
|
||||
|
||||
|
||||
@@ -180,3 +180,10 @@ func (w *sessionClosingStream) Close() error {
|
||||
}
|
||||
return err2
|
||||
}
|
||||
|
||||
func boolInt(b bool) int {
|
||||
if b {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user