Merge branch 'main' into v2
* main: fix(gui): fix previous commit fix(gui): mark unseen disconnected devices as inactive (#10048) fix(strings): differentiate setup(n) and set(v) up (#10024) chore(fs): changes to allow Filesystem to be implemented externally (#10040) chore(config): resolve primary STUN servers via SRV record (fixes #10029) (#10031) build: push artifacts to Azure (#10044) chore(gui, man, authors): update docs, translations, and contributors
This commit is contained in:
@@ -68,13 +68,9 @@ var (
|
||||
DefaultTheme = "default"
|
||||
// Default stun servers should be substituted when the configuration
|
||||
// contains <stunServer>default</stunServer>.
|
||||
|
||||
// DefaultPrimaryStunServers are servers provided by us (to avoid causing the public servers burden)
|
||||
DefaultPrimaryStunServers = []string{
|
||||
// Discontinued because of misuse. See https://forum.syncthing.net/t/stun-server-misuse/23319
|
||||
//"stun.syncthing.net:3478",
|
||||
}
|
||||
DefaultSecondaryStunServers = []string{
|
||||
// The primary stun servers are provided by us and are resolved via an SRV record
|
||||
// The fallback stun servers are used if the primary ones can't be resolved or are down.
|
||||
DefaultFallbackStunServers = []string{
|
||||
"stun.counterpath.com:3478",
|
||||
"stun.counterpath.net:3478",
|
||||
"stun.ekiga.net:3478",
|
||||
|
||||
@@ -8,8 +8,10 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
"github.com/syncthing/syncthing/lib/rand"
|
||||
@@ -183,15 +185,22 @@ func (opts OptionsConfiguration) StunServers() []string {
|
||||
for _, addr := range opts.RawStunServers {
|
||||
switch addr {
|
||||
case "default":
|
||||
defaultPrimaryAddresses := make([]string, len(DefaultPrimaryStunServers))
|
||||
copy(defaultPrimaryAddresses, DefaultPrimaryStunServers)
|
||||
rand.Shuffle(defaultPrimaryAddresses)
|
||||
addresses = append(addresses, defaultPrimaryAddresses...)
|
||||
_, records, err := net.LookupSRV("stun", "udp", "syncthing.net")
|
||||
if err != nil {
|
||||
l.Warnln("Unable to resolve primary STUN servers via DNS:", err)
|
||||
}
|
||||
|
||||
defaultSecondaryAddresses := make([]string, len(DefaultSecondaryStunServers))
|
||||
copy(defaultSecondaryAddresses, DefaultSecondaryStunServers)
|
||||
rand.Shuffle(defaultSecondaryAddresses)
|
||||
addresses = append(addresses, defaultSecondaryAddresses...)
|
||||
for _, record := range records {
|
||||
priority := record.Priority
|
||||
target := strings.TrimSuffix(record.Target, ".")
|
||||
address := fmt.Sprintf("%s:%d", target, record.Port)
|
||||
l.Debugf("Resolved primary STUN server %s with priority %d", address, priority)
|
||||
addresses = append(addresses, address)
|
||||
}
|
||||
|
||||
fallbackAddresses := slices.Clone(DefaultFallbackStunServers)
|
||||
rand.Shuffle(fallbackAddresses)
|
||||
addresses = append(addresses, fallbackAddresses...)
|
||||
default:
|
||||
addresses = append(addresses, addr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user