mirror of
https://github.com/syncthing/syncthing.git
synced 2025-12-23 22:18:14 -05:00
lib/connections: Add KCP support (fixes #804)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3489
This commit is contained in:
committed by
Jakob Borg
parent
151004d645
commit
0da0774ce4
@@ -36,19 +36,19 @@
|
||||
<disableTempIndexes>false</disableTempIndexes>
|
||||
</folder>
|
||||
<device id="EJHMPAQ-OGCVORE-ISB4IS3-SYYVJXF-TKJGLTU-66DIQPF-GJ5D2GX-GQ3OWQK" name="s4" compression="metadata" introducer="false">
|
||||
<address>tcp://127.0.0.1:22004</address>
|
||||
<address>kcp://127.0.0.1:22004</address>
|
||||
</device>
|
||||
<device id="I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU" name="s1" compression="metadata" introducer="false">
|
||||
<address>tcp://127.0.0.1:22001</address>
|
||||
<address>kcp://127.0.0.1:22001</address>
|
||||
</device>
|
||||
<device id="MRIW7OK-NETT3M4-N6SBWME-N25O76W-YJKVXPH-FUMQJ3S-P57B74J-GBITBAC" name="s2" compression="metadata" introducer="false">
|
||||
<address>tcp://127.0.0.1:22002</address>
|
||||
<address>kcp://127.0.0.1:22002</address>
|
||||
</device>
|
||||
<device id="373HSRP-QLPNLIE-JYKZVQF-P4PKZ63-R2ZE6K3-YD442U2-JHBGBQG-WWXAHAU" name="s3" compression="metadata" introducer="false">
|
||||
<address>tcp://127.0.0.1:22003</address>
|
||||
<address>kcp://127.0.0.1:22003</address>
|
||||
</device>
|
||||
<device id="7PBCTLL-JJRYBSA-MOWZRKL-MSDMN4N-4US4OMX-SYEXUS4-HSBGNRY-CZXRXAT" name="s4" compression="metadata" introducer="false">
|
||||
<address>tcp://127.0.0.1:22004</address>
|
||||
<address>kcp://127.0.0.1:22004</address>
|
||||
</device>
|
||||
<gui enabled="true" tls="false" debugging="true">
|
||||
<address>127.0.0.1:8081</address>
|
||||
@@ -58,8 +58,7 @@
|
||||
<theme>default</theme>
|
||||
</gui>
|
||||
<options>
|
||||
<listenAddress>dynamic+https://relays.syncthing.net/endpoint</listenAddress>
|
||||
<listenAddress>tcp://127.0.0.1:22001</listenAddress>
|
||||
<listenAddress>kcp://127.0.0.1:22001</listenAddress>
|
||||
<globalAnnounceServer>default</globalAnnounceServer>
|
||||
<globalAnnounceEnabled>false</globalAnnounceEnabled>
|
||||
<localAnnounceEnabled>true</localAnnounceEnabled>
|
||||
|
||||
@@ -55,13 +55,13 @@
|
||||
<disableWeakHash>false</disableWeakHash>
|
||||
</folder>
|
||||
<device id="I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU" name="s1" compression="metadata" introducer="false">
|
||||
<address>tcp://127.0.0.1:22001</address>
|
||||
<address>kcp://127.0.0.1:22001</address>
|
||||
</device>
|
||||
<device id="MRIW7OK-NETT3M4-N6SBWME-N25O76W-YJKVXPH-FUMQJ3S-P57B74J-GBITBAC" name="s2" compression="metadata" introducer="false">
|
||||
<address>tcp://127.0.0.1:22002</address>
|
||||
<address>kcp://127.0.0.1:22002</address>
|
||||
</device>
|
||||
<device id="373HSRP-QLPNLIE-JYKZVQF-P4PKZ63-R2ZE6K3-YD442U2-JHBGBQG-WWXAHAU" name="s3" compression="metadata" introducer="false">
|
||||
<address>tcp://127.0.0.1:22003</address>
|
||||
<address>kcp://127.0.0.1:22003</address>
|
||||
</device>
|
||||
<gui enabled="true" tls="false" debugging="true">
|
||||
<address>127.0.0.1:8082</address>
|
||||
@@ -70,7 +70,7 @@
|
||||
</gui>
|
||||
<options>
|
||||
<listenAddress>dynamic+https://relays.syncthing.net/endpoint</listenAddress>
|
||||
<listenAddress>tcp://127.0.0.1:22002</listenAddress>
|
||||
<listenAddress>kcp://127.0.0.1:22002</listenAddress>
|
||||
<globalAnnounceServer>default</globalAnnounceServer>
|
||||
<globalAnnounceEnabled>false</globalAnnounceEnabled>
|
||||
<localAnnounceEnabled>true</localAnnounceEnabled>
|
||||
|
||||
@@ -11,8 +11,6 @@ package integration
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -142,24 +140,6 @@ loop:
|
||||
log.Println("Result: Wall time:", t1.Sub(t0))
|
||||
log.Printf("Result: %.1f MiB/s synced", float64(total)/1024/1024/t1.Sub(t0).Seconds())
|
||||
|
||||
if rusage, ok := recvProc.SysUsage().(*syscall.Rusage); ok {
|
||||
log.Println("Receiver: Utime:", time.Duration(rusage.Utime.Nano()))
|
||||
log.Println("Receiver: Stime:", time.Duration(rusage.Stime.Nano()))
|
||||
if runtime.GOOS == "darwin" {
|
||||
// Darwin reports in bytes, Linux seems to report in KiB even
|
||||
// though the manpage says otherwise.
|
||||
rusage.Maxrss /= 1024
|
||||
}
|
||||
log.Println("Receiver: MaxRSS:", rusage.Maxrss, "KiB")
|
||||
}
|
||||
if rusage, ok := sendProc.SysUsage().(*syscall.Rusage); ok {
|
||||
log.Println("Sender: Utime:", time.Duration(rusage.Utime.Nano()))
|
||||
log.Println("Sender: Stime:", time.Duration(rusage.Stime.Nano()))
|
||||
if runtime.GOOS == "darwin" {
|
||||
// Darwin reports in bytes, Linux seems to report in KiB even
|
||||
// though the manpage says otherwise.
|
||||
rusage.Maxrss /= 1024
|
||||
}
|
||||
log.Println("Sender: MaxRSS:", rusage.Maxrss, "KiB")
|
||||
}
|
||||
printUsage("Receiver", recvProc)
|
||||
printUsage("Sender", sendProc)
|
||||
}
|
||||
|
||||
30
test/usage_unix.go
Normal file
30
test/usage_unix.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2014 The Syncthing Authors.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
// +build integration,benchmark,!windows
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
func printUsage(name string, proc *os.ProcessState) {
|
||||
if rusage, ok := proc.SysUsage().(*syscall.Rusage); ok {
|
||||
log.Printf("%s: Utime: %s", name, time.Duration(rusage.Utime.Nano()))
|
||||
log.Printf("%s: Stime: %s", name, time.Duration(rusage.Stime.Nano()))
|
||||
if runtime.GOOS == "darwin" {
|
||||
// Darwin reports in bytes, Linux seems to report in KiB even
|
||||
// though the manpage says otherwise.
|
||||
rusage.Maxrss /= 1024
|
||||
}
|
||||
log.Printf("%s: MaxRSS: %d KiB", name, rusage.Maxrss)
|
||||
}
|
||||
}
|
||||
28
test/usage_windows.go
Normal file
28
test/usage_windows.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2014 The Syncthing Authors.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
// +build integration,benchmark,windows
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ftToDuration(ft *syscall.Filetime) time.Duration {
|
||||
n := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime) // in 100-nanosecond intervals
|
||||
return time.Duration(n*100) * time.Nanosecond
|
||||
}
|
||||
|
||||
func printUsage(name string, proc *os.ProcessState) {
|
||||
if rusage, ok := proc.SysUsage().(*syscall.Rusage); ok {
|
||||
log.Printf("%s: Utime: %s", name, ftToDuration(&rusage.UserTime))
|
||||
log.Printf("%s: Stime: %s", name, ftToDuration(&rusage.KernelTime))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user