mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-19 21:23:58 +00:00
net/portmapper: silently handle PCP NOT_AUTHORIZED responses.
Fixes #1525. Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
4145bb7148
commit
6fb5d4080c
@ -492,8 +492,9 @@ func (c *Client) Probe(ctx context.Context) (res ProbeResult, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]byte, 1500)
|
buf := make([]byte, 1500)
|
||||||
|
pcpHeard := false // true when we get any PCP response
|
||||||
for {
|
for {
|
||||||
if res.PCP && res.PMP && res.UPnP {
|
if pcpHeard && res.PMP && res.UPnP {
|
||||||
// Nothing more to discover.
|
// Nothing more to discover.
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
@ -515,13 +516,24 @@ func (c *Client) Probe(ctx context.Context) (res ProbeResult, err error) {
|
|||||||
}
|
}
|
||||||
case pcpPort: // same as pmpPort
|
case pcpPort: // same as pmpPort
|
||||||
if pres, ok := parsePCPResponse(buf[:n]); ok {
|
if pres, ok := parsePCPResponse(buf[:n]); ok {
|
||||||
if pres.OpCode == pcpOpReply|pcpOpAnnounce && pres.ResultCode == pcpCodeOK {
|
if pres.OpCode == pcpOpReply|pcpOpAnnounce {
|
||||||
c.logf("Got PCP response: epoch: %v", pres.Epoch)
|
pcpHeard = true
|
||||||
res.PCP = true
|
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
c.pcpSawTime = time.Now()
|
c.pcpSawTime = time.Now()
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
|
switch pres.ResultCode {
|
||||||
|
case pcpCodeOK:
|
||||||
|
c.logf("Got PCP response: epoch: %v", pres.Epoch)
|
||||||
|
res.PCP = true
|
||||||
continue
|
continue
|
||||||
|
case pcpCodeNotAuthorized:
|
||||||
|
// A PCP service is running, but refuses to
|
||||||
|
// provide port mapping services.
|
||||||
|
res.PCP = false
|
||||||
|
continue
|
||||||
|
default:
|
||||||
|
// Fall through to unexpected log line.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.logf("unexpected PCP probe response: %+v", pres)
|
c.logf("unexpected PCP probe response: %+v", pres)
|
||||||
}
|
}
|
||||||
@ -547,6 +559,7 @@ const (
|
|||||||
pcpPort = 5351
|
pcpPort = 5351
|
||||||
|
|
||||||
pcpCodeOK = 0
|
pcpCodeOK = 0
|
||||||
|
pcpCodeNotAuthorized = 2
|
||||||
|
|
||||||
pcpOpReply = 0x80 // OR'd into request's op code on response
|
pcpOpReply = 0x80 // OR'd into request's op code on response
|
||||||
pcpOpAnnounce = 0
|
pcpOpAnnounce = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user