ipn/ipnlocal: rename/document peerapi stuff a bit, pass self identity

So handlers can vary based on whether owner of peer matches owner of
local node.

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2021-03-26 21:24:02 -07:00
parent 44d9929208
commit f26dfd054a
2 changed files with 25 additions and 12 deletions

View File

@@ -1448,6 +1448,10 @@ func (b *LocalBackend) initPeerAPIListener() {
}
b.peerAPIListeners = nil
if len(b.netMap.Addresses) == 0 || b.netMap.SelfNode == nil {
return
}
var tunName string
if ge, ok := b.e.(wgengine.InternalsGetter); ok {
tunDev, _ := ge.GetInternals()
@@ -1461,8 +1465,9 @@ func (b *LocalBackend) initPeerAPIListener() {
continue
}
pln := &peerAPIListener{
ln: ln,
lb: b,
ln: ln,
lb: b,
selfNode: b.netMap.SelfNode,
}
pln.urlStr = "http://" + net.JoinHostPort(a.IP.String(), strconv.Itoa(pln.Port()))