alanmcgovern / Mono.Nat

UPNP and NAT-PMP port forwarding for .NET
https://github.com/mono/Mono.Nat
MIT License
160 stars 156 forks source link

Router as mesh repeater returns empty external IP #35

Closed PhilKlae closed 3 weeks ago

PhilKlae commented 3 years ago

I use a router to expand my mesh, like a switch, and GetExternalIPAsync did throw "System.FormatException: An invalid IP address was specified". The string provided by the router was empty like this: ` uPnP Response: , <?xml version="1.0" encoding="utf-8"?>

</u:GetExternalIPAddressResponse> </s:Body> </s:Envelope> ` I caught the exception so no big deal, was unsure if this is expected behavior though.

Great piece of code!

alanmcgovern commented 3 years ago

Hrm, i suspect this is because upnp is still enabled on the router and it's returning an empty IP address because it doesn't have an actual WAN connection. Can you check if that is the case? If so, the best solution would be to disable upnp on this, or put it in bridge mode if it supports that concept. I suspect any ports forwarded on this device would not be helpful as this device is not connected to your WAN.

Apart from that, i can probably handle this edge case a bit better. I could probably raise a different exception type or something.