Merge branch 'main' into libp2p

* main:
  refactor(discover): simplify cache handling by moving to the cachedFinder (#10956)
  chore(gui, man, authors): update docs, translations, and contributors
This commit is contained in:
Jakob Borg committed 2026-11-19 11:53:01 +01:00
commit c8e1c7fe94
5 files changed
+83 -71

No files matched your search

+6 -6
View File
@@ -45,7 +45,7 @@
"Auto Accept": "پذیرش خودکار",
"Automatic Crash Reporting": "گزارش‌دهی خودکار خرابی",
"Automatic upgrade now offers the choice between stable releases and release candidates.": "ارتقای خودکار اکنون امکان انتخاب بین نسخه‌های پایدار و نسخه‌های نامزد انتشار را فراهم می‌کند.",
"Automatic upgrades": "ارتقاهای خودکار",
"Automatic upgrades": "بروزرسانی خودکار",
"Automatic upgrades are always enabled for candidate releases.": "ارتقاهای خودکار برای نسخه‌های نامزد انتشار همیشه فعال است.",
"Automatically create or share folders that this device advertises at the default path.": "پوشه‌هایی را که این دستگاه در مسیر پیش‌فرض معرفی می‌کند، به‌صورت خودکار ایجاد یا به اشتراک بگذار.",
"Available debug logging facilities:": "قابلیت‌های ثبت گزارش اشکال‌زدایی موجود:",
@@ -190,7 +190,7 @@
"GUI Authentication Password": "رمز عبور احراز هویت رابط کاربری",
"GUI Authentication User": "نام کاربری احراز هویت رابط کاربری",
"GUI Authentication: Set User and Password": "احراز هویت رابط کاربری: تنظیم نام کاربری و رمز عبور",
"GUI Listen Address": "نشانی گوش‌دادن رابط کاربری",
"GUI Listen Address": "آدرس اتصال رابط کاربری",
"GUI Override Directory": "پوشهٔ بازنویسی رابط کاربری",
"GUI Theme": "پوستهٔ رابط کاربری",
"General": "عمومی",
@@ -277,7 +277,7 @@
"No File Versioning": "بدون نسخه‌بندی فایل",
"No files will be deleted as a result of this operation.": "هیچ فایلی در نتیجهٔ این عملیات حذف نخواهد شد.",
"No rules set": "هیچ قاعده‌ای تنظیم نشده است",
"No upgrades": "بدون ارتقا",
"No upgrades": "بروزرسانی نشود",
"Not shared": "به اشتراک گذاشته نشده",
"Notice": "توجه",
"Number of Connections": "تعداد اتصالات",
@@ -390,9 +390,9 @@
"Smallest First": "کوچک‌ترین ابتدا",
"Some discovery methods could not be established for finding other devices or announcing this device:": "برخی روش‌های کشف برای یافتن دستگاه‌های دیگر یا معرفی این دستگاه برقرار نشدند:",
"Some items could not be restored:": "برخی موارد بازیابی نشدند:",
"Some listening addresses could not be enabled to accept connections:": "برخی نشانی‌های گوش‌دادن برای پذیرش اتصالات فعال نشدند:",
"Some listening addresses could not be enabled to accept connections:": "برخی از آدرس‌های پذیرش اتصال نتوانستند برای پذیرش اتصال‌ها فعال شوند:",
"Source Code": "کد منبع",
"Stable releases and release candidates": "نسخه‌های پایدار و نامزد انتشار",
"Stable releases and release candidates": "نسخه‌های پایدار و آزمایشی",
"Stable releases are delayed by about two weeks. During this time they go through testing as release candidates.": "نسخه‌های پایدار حدود دو هفته به تأخیر می‌افتند. در این مدت، آن‌ها به‌عنوان نسخه‌های نامزد انتشار آزمایش می‌شوند.",
"Stable releases only": "فقط نسخه‌های پایدار",
"Staggered": "پله‌ای",
@@ -408,7 +408,7 @@
"Support Bundle": "بستهٔ پشتیبانی",
"Sync Extended Attributes": "همگام‌سازی ویژگی‌های توسعه‌یافته",
"Sync Ownership": "همگام‌سازی مالکیت",
"Sync Protocol Listen Addresses": "نشانی‌های گوش‌دادن پروتکل همگام‌سازی",
"Sync Protocol Listen Addresses": "آدرس‌های پذیرش اتصال برای پروتکل همگام‌سازی",
"Sync Status": "وضعیت همگام‌سازی",
"Syncing": "در حال همگام‌سازی",
"Syncthing device ID for \"{%devicename%}\"": "شناسهٔ دستگاه Syncthing برای «{{devicename}}»",
+24 -13
View File
@@ -180,7 +180,7 @@
"Global Discovery": "Găsire Globală",
"Global Discovery Servers": "Global Discovery Servers",
"Global State": "Status Global",
"Help": "Help",
"Help": "Ajutor",
"Home page": "Home page",
"However, your current settings indicate you might not want it enabled. We have disabled automatic crash reporting for you.": "However, your current settings indicate you might not want it enabled. We have disabled automatic crash reporting for you.",
"Identification": "Identification",
@@ -189,31 +189,42 @@
"Ignore": "Ignoră",
"Ignore Patterns": "Reguli de excludere",
"Ignore Permissions": "Ignoră Permisiuni",
"Ignored Devices": "Ignored Devices",
"Ignored Folders": "Ignored Folders",
"Ignored at": "Ignored at",
"Ignored Devices": "Dispozitive ignorate",
"Ignored Folders": "Foldere Ignorate",
"Ignored at": "Ignorat la",
"Included Software": "Software inclus",
"Incoming Rate Limit (KiB/s)": "Limită Viteză de Download (KB/s)",
"Incorrect configuration may damage your folder contents and render Syncthing inoperable.": "Incorrect configuration may damage your folder contents and render Syncthing inoperable.",
"Incorrect user name or password.": "Nume de utilizator sau Parolă incorectă.",
"Info": "Informații",
"Internally used paths:": "Căi folosite intern:",
"Introduced By": "Introduced By",
"Introducer": "Dispozitiv Inițiator",
"Inversion of the given condition (i.e. do not exclude)": "Inversarea condiției (de ex., nu exclude)",
"Keep Versions": "Păstrează Versiuni",
"LDAP": "LDAP",
"Largest First": "Largest First",
"Last Scan": "Last Scan",
"Last seen": "Ultima vizionare",
"Latest Change": "Latest Change",
"Learn more": "Learn more",
"Limit": "Limit",
"Largest First": "Cele mai mari primele",
"Last 30 Days": "Ultimele 30 de zile",
"Last 7 Days": "Ultimele 7 zile",
"Last Month": "Luna trecută",
"Last Scan": "Ultima Scanare",
"Last seen": "Ultima dată văzut",
"Latest Change": "Ultima schimbare",
"Learn more": "Află mai multe",
"Learn more at {%url%}": "Află mai multe la {{url}}",
"Limit": "Limită",
"Limit Bandwidth in LAN": "Limitează lățimea de bandă în LAN",
"Listeners": "Listeners",
"Loading data...": "Loading data...",
"Loading...": "Loading...",
"Loading data...": "Se încarcă datele...",
"Loading...": "Se încarcă...",
"Local Additions": "Local Additions",
"Local Discovery": "Găsire Locală",
"Local State": "Status Local",
"Local State (Total)": "Local State (Total)",
"Local State (Total)": "Status Local (Total)",
"Locally Changed Items": "Locally Changed Items",
"Log": "Log",
"Log In": "Autentifică-te",
"Log Out": "Deloghează-te",
"Log tailing paused. Scroll to the bottom to continue.": "Log tailing paused. Scroll to the bottom to continue.",
"Logs": "Logs",
"Major Upgrade": "Major Upgrade",
+1 -1
View File
@@ -482,7 +482,7 @@
"Trash Can File Versioning": "回收站文件版本控制",
"Type": "类型",
"UNIX Permissions": "UNIX 权限",
"Unavailable": "无效",
"Unavailable": "不可用",
"Unavailable/Disabled by administrator or maintainer": "无效/禁用(由管理员或维护者)",
"Undecided (will prompt)": "未决定(将提示)",
"Unexpected Items": "意外项目",
+45 -2
View File
@@ -7,12 +7,13 @@
package discover
import (
"context"
"log/slog"
"maps"
"sync"
"time"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/thejerf/suture/v4"
)
// A cachedFinder is a Finder with associated cache timeouts.
@@ -22,7 +23,6 @@ type cachedFinder struct {
cacheTime time.Duration
negCacheTime time.Duration
cache *cache
token *suture.ServiceToken
}
// An error may implement cachedError, in which case it will be interrogated
@@ -32,6 +32,49 @@ type cachedError interface {
CacheFor() time.Duration
}
func (f *cachedFinder) Lookup(ctx context.Context, deviceID protocol.DeviceID) ([]string, error) {
if cacheEntry, ok := f.cache.Get(deviceID); ok {
// We have a cache entry. Lets see what it says.
if cacheEntry.found && time.Since(cacheEntry.when) < f.cacheTime {
// It's a positive, valid entry. Use it.
slog.DebugContext(ctx, "Found cached discovery entry", "device", deviceID, "finder", f, "entry", cacheEntry)
return cacheEntry.Addresses, nil
}
valid := time.Now().Before(cacheEntry.validUntil) || time.Since(cacheEntry.when) < f.negCacheTime
if !cacheEntry.found && valid {
// It's a negative, valid entry. We should not make another
// attempt right now.
slog.DebugContext(ctx, "Negative cache entry", "device", deviceID, "finder", f, "until1", cacheEntry.when.Add(f.negCacheTime), "until2", cacheEntry.validUntil)
return nil, nil
}
}
// Perform the actual lookup and cache the result.
addrs, err := f.Finder.Lookup(ctx, deviceID)
if err == nil {
slog.DebugContext(ctx, "Got finder result", "device", deviceID, "finder", f, "address", addrs)
f.cache.Set(deviceID, CacheEntry{
Addresses: addrs,
when: time.Now(),
found: len(addrs) > 0,
})
} else {
// Lookup returned error, add a negative cache entry.
entry := CacheEntry{
when: time.Now(),
found: false,
}
if err, ok := err.(cachedError); ok {
entry.validUntil = time.Now().Add(err.CacheFor())
}
f.cache.Set(deviceID, entry)
}
return addrs, err
}
// A cache can be embedded wherever useful
type cache struct {
+7 -49
View File
@@ -66,6 +66,7 @@ type manager struct {
mut sync.RWMutex
finders map[string]cachedFinder
tokens map[string]suture.ServiceToken
}
func NewManager(myID protocol.DeviceID, cfg config.Wrapper, cert tls.Certificate, evLogger events.Logger, lister AddressLister, registry *registry.Registry, kv db.KV) Manager {
@@ -79,6 +80,7 @@ func NewManager(myID protocol.DeviceID, cfg config.Wrapper, cert tls.Certificate
registry: registry,
kv: kv,
finders: make(map[string]cachedFinder),
tokens: make(map[string]suture.ServiceToken),
}
m.Add(svcutil.AsService(m.serve, m.String()))
return m
@@ -93,33 +95,27 @@ func (m *manager) serve(ctx context.Context) error {
}
func (m *manager) addLocked(identity string, finder Finder, cacheTime, negCacheTime time.Duration) {
entry := cachedFinder{
m.finders[identity] = cachedFinder{
Finder: finder,
cacheTime: cacheTime,
negCacheTime: negCacheTime,
cache: newCache(),
token: nil,
}
if service, ok := finder.(suture.Service); ok {
token := m.Supervisor.Add(service)
entry.token = &token
m.tokens[identity] = token
}
m.finders[identity] = entry
slog.Info("Using discovery mechanism", "identity", identity)
}
func (m *manager) removeLocked(identity string) {
entry, ok := m.finders[identity]
if !ok {
return
}
if entry.token != nil {
err := m.Supervisor.Remove(*entry.token)
if err != nil {
if token, ok := m.tokens[identity]; ok {
if err := m.Supervisor.Remove(token); err != nil {
slog.Warn("Failed to remove discovery mechanism", slog.String("identity", identity), slogutil.Error(err))
}
}
delete(m.finders, identity)
delete(m.tokens, identity)
slog.Info("Stopped using discovery mechanism", "identity", identity)
}
@@ -128,46 +124,8 @@ func (m *manager) removeLocked(identity string) {
func (m *manager) Lookup(ctx context.Context, deviceID protocol.DeviceID) (addresses []string, err error) {
m.mut.RLock()
for _, finder := range m.finders {
if cacheEntry, ok := finder.cache.Get(deviceID); ok {
// We have a cache entry. Lets see what it says.
if cacheEntry.found && time.Since(cacheEntry.when) < finder.cacheTime {
// It's a positive, valid entry. Use it.
slog.DebugContext(ctx, "Found cached discovery entry", "device", deviceID, "finder", finder, "entry", cacheEntry)
addresses = append(addresses, cacheEntry.Addresses...)
continue
}
valid := time.Now().Before(cacheEntry.validUntil) || time.Since(cacheEntry.when) < finder.negCacheTime
if !cacheEntry.found && valid {
// It's a negative, valid entry. We should not make another
// attempt right now.
slog.DebugContext(ctx, "Negative cache entry", "device", deviceID, "finder", finder, "until1", cacheEntry.when.Add(finder.negCacheTime), "until2", cacheEntry.validUntil)
continue
}
// It's expired. Ignore and continue.
}
// Perform the actual lookup and cache the result.
if addrs, err := finder.Lookup(ctx, deviceID); err == nil {
slog.DebugContext(ctx, "Got finder result", "device", deviceID, "finder", finder, "address", addrs)
addresses = append(addresses, addrs...)
finder.cache.Set(deviceID, CacheEntry{
Addresses: addrs,
when: time.Now(),
found: len(addrs) > 0,
})
} else {
// Lookup returned error, add a negative cache entry.
entry := CacheEntry{
when: time.Now(),
found: false,
}
if err, ok := err.(cachedError); ok {
entry.validUntil = time.Now().Add(err.CacheFor())
}
finder.cache.Set(deviceID, entry)
}
}
m.mut.RUnlock()