Add fallback for local socket address

Same problem and same solution as https://github.com/brunodev85/winlator/pull/48

To be more clear: getLocalHost might fail (as it does on my device, where I have a nethunter chroot which sets kali as hostname and getLocalHost can't resolve it)
getLoopbackAddress would be a more elegant solution if it would get the loopback ipv4, but it might return an ipv6 (again, in my case it does) which doesn't actually connect to the server
This commit is contained in:
Riccardo Nava 2024-01-26 18:28:48 +01:00 committed by GitHub
parent e6dd7a5976
commit 6f552dd66a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -254,7 +254,11 @@ public class WinHandler {
try {
localhost = InetAddress.getLocalHost();
}
catch (UnknownHostException e) {}
catch (UnknownHostException e) {
try {
localhost = InetAddress.getByName("127.0.0.1");
} catch (UnknownHostException ex) {}
}
running = true;
startSendThread();