lib/connections: Add KCP support (fixes #804)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3489
This commit is contained in:
Audrius Butkevicius
2017-03-07 12:44:16 +00:00
committed by Jakob Borg
parent 151004d645
commit 0da0774ce4
181 changed files with 30946 additions and 106 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/syncthing/syncthing/lib/events"
"github.com/syncthing/syncthing/lib/osutil"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/rand"
"github.com/syncthing/syncthing/lib/sync"
"github.com/syncthing/syncthing/lib/util"
)
@@ -404,3 +405,26 @@ func (w *Wrapper) RequiresRestart() bool {
func (w *Wrapper) setRequiresRestart() {
atomic.StoreUint32(&w.requiresRestart, 1)
}
func (w *Wrapper) StunServers() []string {
var addresses []string
for _, addr := range w.cfg.Options.StunServers {
switch addr {
case "default":
addresses = append(addresses, DefaultStunServers...)
default:
addresses = append(addresses, addr)
}
}
addresses = util.UniqueStrings(addresses)
// Shuffle
l := len(addresses)
for i := range addresses {
r := rand.Intn(l)
addresses[i], addresses[r] = addresses[r], addresses[i]
}
return addresses
}