net/portmapper: add logs about obtained mapping(s)

This logs additional information about what mapping(s) are obtained
during the creation process, including whether we return an existing
cached mapping.

Updates #10597

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I9ff25071f064c91691db9ab0b9365ccc5f948d6e
This commit is contained in:
Andrew Dunham
2023-12-19 15:47:34 -05:00
parent f815d66a88
commit 3c333f6341
4 changed files with 69 additions and 1 deletions

View File

@@ -58,9 +58,16 @@ type pcpMapping struct {
// Doesn't seem to be used elsewhere, but can use it for validation at some point.
}
func (p *pcpMapping) MappingType() string { return "pcp" }
func (p *pcpMapping) GoodUntil() time.Time { return p.goodUntil }
func (p *pcpMapping) RenewAfter() time.Time { return p.renewAfter }
func (p *pcpMapping) External() netip.AddrPort { return p.external }
func (p *pcpMapping) MappingDebug() string {
return fmt.Sprintf("pcpMapping{gw:%v, external:%v, internal:%v, renewAfter:%d, goodUntil:%d}",
p.gw, p.external, p.internal,
p.renewAfter.Unix(), p.goodUntil.Unix())
}
func (p *pcpMapping) Release(ctx context.Context) {
uc, err := p.c.listenPacket(ctx, "udp4", ":0")
if err != nil {