diff --git a/lib/config/config.go b/lib/config/config.go index bc4c8611..71e30d3e 100644 --- a/lib/config/config.go +++ b/lib/config/config.go @@ -53,16 +53,14 @@ var ( // DefaultDiscoveryServersV4 should be substituted when the configuration // contains default-v4. DefaultDiscoveryServersV4 = []string{ - "https://discovery-v4-2.syncthing.net/v2/?id=DVU36WY-H3LVZHW-E6LLFRE-YAFN5EL-HILWRYP-OC2M47J-Z4PE62Y-ADIBDQC", // 45.55.230.38, USA - "https://discovery-v4-3.syncthing.net/v2/?id=VK6HNJ3-VVMM66S-HRVWSCR-IXEHL2H-U4AQ4MW-UCPQBWX-J2L2UBK-NVZRDQZ", // 128.199.95.124, Singapore - "https://discovery-v4-4.syncthing.net/v2/?id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW", // 95.85.19.244, NL + "https://discovery.syncthing.net/v2/?noannounce&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW", + "https://discovery-v4.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW", } // DefaultDiscoveryServersV6 should be substituted when the configuration // contains default-v6. DefaultDiscoveryServersV6 = []string{ - "https://discovery-v6-2.syncthing.net/v2/?id=DVU36WY-H3LVZHW-E6LLFRE-YAFN5EL-HILWRYP-OC2M47J-Z4PE62Y-ADIBDQC", // 2604:a880:800:10::182:a001, USA - "https://discovery-v6-3.syncthing.net/v2/?id=VK6HNJ3-VVMM66S-HRVWSCR-IXEHL2H-U4AQ4MW-UCPQBWX-J2L2UBK-NVZRDQZ", // 2400:6180:0:d0::d9:d001, Singapore - "https://discovery-v6-4.syncthing.net/v2/?id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW", // 2a03:b0c0:0:1010::4ed:3001, NL + "https://discovery.syncthing.net/v2/?noannounce&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW", + "https://discovery-v6.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW", } // DefaultDiscoveryServers should be substituted when the configuration // contains default. diff --git a/lib/discover/global.go b/lib/discover/global.go index b38cc2f1..cf59472d 100644 --- a/lib/discover/global.go +++ b/lib/discover/global.go @@ -30,6 +30,7 @@ type globalClient struct { announceClient httpClient queryClient httpClient noAnnounce bool + noLookup bool stop chan struct{} errorHolder } @@ -52,6 +53,7 @@ type announcement struct { type serverOptions struct { insecure bool // don't check certificate noAnnounce bool // don't announce + noLookup bool // don't use for lookups id string // expected server device ID } @@ -119,15 +121,26 @@ func NewGlobal(server string, cert tls.Certificate, addrList AddressLister) (Fin announceClient: announceClient, queryClient: queryClient, noAnnounce: opts.noAnnounce, + noLookup: opts.noLookup, stop: make(chan struct{}), } - cl.setError(errors.New("not announced")) + if !opts.noAnnounce { + // If we are supposed to annonce, it's an error until we've done so. + cl.setError(errors.New("not announced")) + } return cl, nil } // Lookup returns the list of addresses where the given device is available func (c *globalClient) Lookup(device protocol.DeviceID) (addresses []string, err error) { + if c.noLookup { + return nil, lookupError{ + error: errors.New("lookups not supported"), + cacheFor: time.Hour, + } + } + qURL, err := url.Parse(c.server) if err != nil { return nil, err @@ -201,7 +214,6 @@ func (c *globalClient) Serve() { } func (c *globalClient) sendAnnouncement(timer *time.Timer) { - var ann announcement if c.addrList != nil { ann.Addresses = c.addrList.ExternalAddresses() @@ -287,6 +299,7 @@ func parseOptions(dsn string) (server string, opts serverOptions, err error) { opts.id = q.Get("id") opts.insecure = opts.id != "" || queryBool(q, "insecure") opts.noAnnounce = queryBool(q, "noannounce") + opts.noLookup = queryBool(q, "nolookup") // Check for disallowed combinations if p.Scheme == "http" {