Signed-off-by: Jakob Borg <[email protected]>
This commit is contained in:
Jakob Borg committed 2026-11-19 14:16:40 +01:00
1 parent 975f2229b6
commit 449019fbf3
4 files changed
+13 -9

No files matched your search

+4 -4
View File
@@ -84,9 +84,9 @@ type Options struct {
}
type DHT struct {
host host.Host
ipfs *kad.IpfsDHT
dhtDiagnostics
host host.Host
ipfs *kad.IpfsDHT
dhtDiagnostics //nolint:embeddedstructfieldcheck
}
func NewSyncthingDHT(options Options) (*DHT, error) {
@@ -342,7 +342,7 @@ func (s *DHT) Announce(ctx context.Context, deviceID protocol.DeviceID, addresse
r := &discoproto.DHTPayload{
Certificate: certificate,
Addresses: addresses,
ExpiresUnix: uint64(now.Add(RecordLifetime).Unix()),
ExpiresUnix: uint64(now.Add(RecordLifetime).Unix()), //nolint:gosec // does not wrap
TimeValue: timeValue,
}
value, err := encodeRecord(r, privateKey)
+2 -3
View File
@@ -35,10 +35,9 @@ const (
dhtRecordNamespace = "device"
)
// discoveryTimeValue staggers daily rotation across devices. The addition
// intentionally wraps at 2^64 before division.
// discoveryTimeValue staggers daily rotation across devices.
func discoveryTimeValue(id protocol.DeviceID, now time.Time) uint64 {
return (uint64(now.Unix()) + binary.BigEndian.Uint64(id[:8])) / 86400
return (uint64(now.Unix()) + binary.BigEndian.Uint64(id[:8])) / 86400 //nolint:gosec // intentionally wraps
}
// dhtRecordKey hashes the seed, raw device ID and big-endian time value.
+6 -1
View File
@@ -7,11 +7,13 @@
package config
import (
"context"
"fmt"
"net"
"runtime"
"slices"
"strings"
"time"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/rand"
@@ -228,10 +230,13 @@ func (opts OptionsConfiguration) GlobalDiscoveryServers() []string {
}
func (opts OptionsConfiguration) P2PDiscoveryBootstrapPeers() []string {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
var peers []string
for _, address := range opts.RawP2PDiscoveryBootstrapPeers {
if address == "default" {
if records, err := net.LookupTXT(DefaultDHTBootstrapRecord); err != nil {
if records, err := net.DefaultResolver.LookupTXT(ctx, DefaultDHTBootstrapRecord); err != nil {
l.Debugln("Unable to resolve default DHT servers via DNS:", err)
} else {
peers = append(peers, records...)
+1 -1
View File
@@ -49,7 +49,7 @@ type P2PStats struct {
const (
globalCacheTime = 5 * time.Minute
globalNegCacheTime = time.Minute // usually overriden by the servers
globalNegCacheTime = time.Minute // usually overridden by the servers
p2pCacheTime = 10 * time.Minute
p2pNegCacheTime = 5 * time.Minute
)