lib/relay/client: Stricter typing and remove unused code (#7819)

This commit is contained in:
greatroar
2021-07-21 09:49:09 +02:00
committed by GitHub
parent eb6cad7f93
commit dc38e6ae88
3 changed files with 18 additions and 70 deletions
+4 -11
View File
@@ -11,6 +11,7 @@ import (
"net/http"
"net/url"
"sort"
"sync"
"time"
"github.com/syncthing/syncthing/lib/osutil"
@@ -25,10 +26,11 @@ type dynamicClient struct {
certs []tls.Certificate
timeout time.Duration
client RelayClient
mut sync.RWMutex // Protects client.
client *staticClient
}
func newDynamicClient(uri *url.URL, certs []tls.Certificate, invitations chan protocol.SessionInvitation, timeout time.Duration) RelayClient {
func newDynamicClient(uri *url.URL, certs []tls.Certificate, invitations chan protocol.SessionInvitation, timeout time.Duration) *dynamicClient {
c := &dynamicClient{
pooladdr: uri,
certs: certs,
@@ -114,15 +116,6 @@ func (c *dynamicClient) Error() error {
return c.client.Error()
}
func (c *dynamicClient) Latency() time.Duration {
c.mut.RLock()
defer c.mut.RUnlock()
if c.client == nil {
return time.Hour
}
return c.client.Latency()
}
func (c *dynamicClient) String() string {
return fmt.Sprintf("DynamicClient:%p:%s@%s", c, c.URI(), c.pooladdr)
}