chore: trivial fixes (#10650)
... which keep getting filed by AI agents. Closes #10649, closes #10486, closes #10648, closes #10499, closes #10647, closes #10635, closes #10636, closes #10607. --------- Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
@@ -1054,7 +1054,7 @@ func (m migratingAPI) Serve(ctx context.Context) error {
|
||||
srv := &http.Server{
|
||||
Addr: m.addr,
|
||||
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
w.Write([]byte("*** Database migration in progress ***\n\n"))
|
||||
for _, line := range slogutil.GlobalRecorder.Since(time.Time{}) {
|
||||
_, _ = line.WriteTo(w, slogutil.DefaultLineFormat)
|
||||
|
||||
+1
-1
@@ -8,4 +8,4 @@ package pmp
|
||||
|
||||
import "github.com/syncthing/syncthing/internal/slogutil"
|
||||
|
||||
var l = slogutil.NewAdapter("NAT-PMP discovery and port mapping")
|
||||
func init() { slogutil.RegisterPackage("NAT-PMP discovery and port mapping") }
|
||||
|
||||
+6
-10
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
natpmp "github.com/jackpal/go-nat-pmp"
|
||||
|
||||
"github.com/syncthing/syncthing/internal/slogutil"
|
||||
"github.com/syncthing/syncthing/lib/nat"
|
||||
"github.com/syncthing/syncthing/lib/netutil"
|
||||
"github.com/syncthing/syncthing/lib/osutil"
|
||||
@@ -34,14 +35,14 @@ func Discover(ctx context.Context, renewal, timeout time.Duration) []nat.Device
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
l.Debugln("Failed to discover gateway", err)
|
||||
slog.DebugContext(ctx, "Failed to discover gateway", slogutil.Error(err))
|
||||
return nil
|
||||
}
|
||||
if ip == nil || ip.IsUnspecified() {
|
||||
return nil
|
||||
}
|
||||
|
||||
l.Debugln("Discovered gateway at", ip)
|
||||
slog.DebugContext(ctx, "Discovered gateway", "ip", ip)
|
||||
|
||||
c := natpmp.NewClientWithTimeout(ip, timeout)
|
||||
// Try contacting the gateway, if it does not respond, assume it does not
|
||||
@@ -51,13 +52,8 @@ func Discover(ctx context.Context, renewal, timeout time.Duration) []nat.Device
|
||||
return ierr
|
||||
})
|
||||
if err != nil {
|
||||
if errors.Is(err, context.Canceled) {
|
||||
return nil
|
||||
}
|
||||
if strings.Contains(err.Error(), "Timed out") {
|
||||
slog.Debug("Timeout trying to get external address, assume no NAT-PMP available")
|
||||
return nil
|
||||
}
|
||||
slog.DebugContext(ctx, "Failed to get external address", slogutil.Error(err))
|
||||
return nil
|
||||
}
|
||||
|
||||
var localIP net.IP
|
||||
@@ -69,7 +65,7 @@ func Discover(ctx context.Context, renewal, timeout time.Duration) []nat.Device
|
||||
conn.Close()
|
||||
localIP, err = osutil.IPFromAddr(conn.LocalAddr())
|
||||
if localIP == nil {
|
||||
l.Debugln("Failed to lookup local IP", err)
|
||||
slog.DebugContext(ctx, "Failed to lookup local IP", slogutil.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ func FetchLatestReleases(releasesURL, current string) []Release {
|
||||
slog.Warn("Failed to fetch latest release information", slogutil.Error(err))
|
||||
return nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode > 299 {
|
||||
slog.Warn("Failed to fetch latest release information", slogutil.Error(resp.Status))
|
||||
return nil
|
||||
@@ -111,7 +112,6 @@ func FetchLatestReleases(releasesURL, current string) []Release {
|
||||
if err != nil {
|
||||
slog.Warn("Failed to decode latest release information", slogutil.Error(err))
|
||||
}
|
||||
resp.Body.Close()
|
||||
|
||||
return rels
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user