Forráskód Böngészése

all: Remove or convert deprecated API usages (#8459)

Jakob Borg 3 éve
szülő
commit
7bdb5faa9c

+ 3 - 2
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),
 	)
 }
 

+ 1 - 1
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")
 	}
 

+ 1 - 1
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)
 		}
 

+ 2 - 2
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)

+ 1 - 2
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)

+ 1 - 1
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")
 	}
 

+ 1 - 2
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")