fix not return err

This commit is contained in:
xmdhs
2024-01-24 03:05:43 +08:00
parent fcc45b4ff0
commit b16821e2d2

View File

@@ -32,11 +32,11 @@ func getPubulicPort(ctx context.Context, stunAddr string, host string, port uint
err := upnp.AddPortMapping(ctx, "", port, upnpP, port, host, true, "github.com/xmdhs/natupnp", 0)
if err != nil {
return netip.AddrPort{}, nil
return netip.AddrPort{}, fmt.Errorf("getPubulicPort: %w", err)
}
stunConn, err := reuse.DialContext(ctx, dialP, "0.0.0.0:"+strconv.Itoa(int(port)), stunAddr)
if err != nil {
return netip.AddrPort{}, nil
return netip.AddrPort{}, fmt.Errorf("getPubulicPort: %w", err)
}
defer stunConn.Close()
mapAddr, err := stun.GetMappedAddress(ctx, stunConn)