mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-18 11:05:14 +00:00
all: Remove or convert deprecated API usages (#8459)
This commit is contained in:
parent
7e26f74f38
commit
7bdb5faa9c
@ -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),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user