kaklakariada / portmapper

A tool for managing port forwardings via UPnP
GNU General Public License v3.0
685 stars 89 forks source link

Extra method to get ip. Using UDP datagram #54

Closed brunoais closed 4 years ago

brunoais commented 4 years ago

This method to try getting the local IP address seem to work correctly on linux and windows, even though for windows, the current method works just fine.

The way this code works depends on java's protected native void connect0(InetAddress address, int port) native C code java accessible through java.net.PlainDatagramSocketImpl. The best way I was able to find to use such method is by making a datagram (UDP packet) and send it to nowhere reachable.

kaklakariada commented 4 years ago

Thank you for your pull request, looks good!