mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-14 06:57:31 +00:00
drive,ipn/ipnlocal: calculate peer taildrive URLs on-demand
Instead of calculating the PeerAPI URL at the time that we add the peer, we now calculate it on every access to the peer. This way, if we initially did not have a shared address family with the peer, but later do, this allows us to access the peer at that point. This follows the pattern from other places where we access the peer API, which also calculate the URL on an as-needed basis. Additionally, we now show peers as not Available when we can't get a peer API URL. Lastly, this moves some of the more frequent verbose Taildrive logging from [v1] to [v2] level. Updates #29702 Signed-off-by: Percy Wegmann <percy@tailscale.com>
This commit is contained in:

committed by
Percy Wegmann

parent
6a9bf9172b
commit
454d856be8
@@ -524,7 +524,7 @@ func (s *system) addRemote(name string) string {
|
||||
for name, r := range s.remotes {
|
||||
remotes = append(remotes, &drive.Remote{
|
||||
Name: name,
|
||||
URL: fmt.Sprintf("http://%s", r.l.Addr()),
|
||||
URL: func() string { return fmt.Sprintf("http://%s", r.l.Addr()) },
|
||||
})
|
||||
}
|
||||
s.local.fs.SetRemotes(
|
||||
|
@@ -81,7 +81,7 @@ func (s *FileSystemForLocal) SetRemotes(domain string, remotes []*drive.Remote,
|
||||
Name: remote.Name,
|
||||
Available: remote.Available,
|
||||
},
|
||||
BaseURL: func() (string, error) { return remote.URL, nil },
|
||||
BaseURL: func() (string, error) { return remote.URL(), nil },
|
||||
Transport: transport,
|
||||
})
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ import (
|
||||
// Remote represents a remote Taildrive node.
|
||||
type Remote struct {
|
||||
Name string
|
||||
URL string
|
||||
URL func() string
|
||||
Available func() bool
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user