diff --git a/cmd/strelaypoolsrv/stats.go b/cmd/strelaypoolsrv/stats.go index ae4a8a751..5c1ea171a 100644 --- a/cmd/strelaypoolsrv/stats.go +++ b/cmd/strelaypoolsrv/stats.go @@ -10,11 +10,12 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/collectors" "github.com/syncthing/syncthing/lib/sync" ) func init() { - processCollectorOpts := prometheus.ProcessCollectorOpts{ + processCollectorOpts := collectors.ProcessCollectorOpts{ Namespace: "syncthing_relaypoolsrv", PidFn: func() (int, error) { return os.Getpid(), nil @@ -22,7 +23,7 @@ func init() { } prometheus.MustRegister( - prometheus.NewProcessCollector(processCollectorOpts), + collectors.NewProcessCollector(processCollectorOpts), ) } diff --git a/cmd/strelaysrv/listener.go b/cmd/strelaysrv/listener.go index c0e033c2d..d1fa0d76d 100644 --- a/cmd/strelaysrv/listener.go +++ b/cmd/strelaysrv/listener.go @@ -76,7 +76,7 @@ func protocolConnectionHandler(tcpConn net.Conn, config *tls.Config) { } state := conn.ConnectionState() - if (!state.NegotiatedProtocolIsMutual || state.NegotiatedProtocol != protocol.ProtocolName) && debug { + if debug && state.NegotiatedProtocol != protocol.ProtocolName { log.Println("Protocol negotiation error") } diff --git a/lib/connections/service.go b/lib/connections/service.go index ace5dd0c4..3a5ee82eb 100644 --- a/lib/connections/service.go +++ b/lib/connections/service.go @@ -242,7 +242,7 @@ func (s *service) handleConns(ctx context.Context) error { // of the TLS handshake. Unfortunately this can't be a hard error, // because there are implementations out there that don't support // protocol negotiation (iOS for one...). - if !cs.NegotiatedProtocolIsMutual || cs.NegotiatedProtocol != s.bepProtocolName { + if cs.NegotiatedProtocol != s.bepProtocolName { l.Infof("Peer at %s did not negotiate bep/1.0", c) } diff --git a/lib/model/folder_sendrecv_test.go b/lib/model/folder_sendrecv_test.go index 608b5a87d..e51e35ed5 100644 --- a/lib/model/folder_sendrecv_test.go +++ b/lib/model/folder_sendrecv_test.go @@ -336,13 +336,13 @@ func TestWeakHash(t *testing.T) { // both are of the same length, for example: // File 1: abcdefgh // File 2: xyabcdef - f.Seek(0, os.SEEK_SET) + f.Seek(0, io.SeekStart) existing, err := scanner.Blocks(context.TODO(), f, protocol.MinBlockSize, size, nil, true) if err != nil { t.Error(err) } - f.Seek(0, os.SEEK_SET) + f.Seek(0, io.SeekStart) remainder := io.LimitReader(f, size-shift) prefix := io.LimitReader(rand.Reader, shift) nf := io.MultiReader(prefix, remainder) diff --git a/lib/relay/client/dynamic.go b/lib/relay/client/dynamic.go index 2d99c95e8..baef98df3 100644 --- a/lib/relay/client/dynamic.go +++ b/lib/relay/client/dynamic.go @@ -48,12 +48,11 @@ func (c *dynamicClient) serve(ctx context.Context) error { l.Debugln(c, "looking up dynamic relays") - req, err := http.NewRequest("GET", uri.String(), nil) + req, err := http.NewRequestWithContext(ctx, "GET", uri.String(), nil) if err != nil { l.Debugln(c, "failed to lookup dynamic relays", err) return err } - req.Cancel = ctx.Done() data, err := http.DefaultClient.Do(req) if err != nil { l.Debugln(c, "failed to lookup dynamic relays", err) diff --git a/lib/relay/client/static.go b/lib/relay/client/static.go index a49768b84..e9b78907b 100644 --- a/lib/relay/client/static.go +++ b/lib/relay/client/static.go @@ -204,7 +204,7 @@ func performHandshakeAndValidation(conn *tls.Conn, uri *url.URL) error { } cs := conn.ConnectionState() - if !cs.NegotiatedProtocolIsMutual || cs.NegotiatedProtocol != protocol.ProtocolName { + if cs.NegotiatedProtocol != protocol.ProtocolName { return errors.New("protocol negotiation error") } diff --git a/lib/upnp/upnp.go b/lib/upnp/upnp.go index ea4495cb8..8b2c8a17b 100644 --- a/lib/upnp/upnp.go +++ b/lib/upnp/upnp.go @@ -444,11 +444,10 @@ func soapRequest(ctx context.Context, url, service, function, message string) ([ body := fmt.Sprintf(tpl, message) - req, err := http.NewRequest("POST", url, strings.NewReader(body)) + req, err := http.NewRequestWithContext(ctx, "POST", url, strings.NewReader(body)) if err != nil { return resp, err } - req.Cancel = ctx.Done() req.Close = true req.Header.Set("Content-Type", `text/xml; charset="utf-8"`) req.Header.Set("User-Agent", "syncthing/1.0")