docs: public static InetAddress guessPrimaryNetworkAddress(boolean preferIPv4) throws SocketException {
          final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
  
          if (interfaces != null) {
              for (NetworkInterface interf : Collections.list(interfaces)) {
                  if (!interf.isLoopback() && interf.isUp()) {
                      // Interface is not loopback and up. Try to get the first address.
                      for (InetAddress addr : Collections.list(interf.getInetAddresses())) {
                          if (preferIPv4 && addr instanceof Inet4Address) {
                              return addr;
                          }
                          if (!preferIPv4 && addr instanceof Inet6Address) {
                              return addr;
                          }
                      }
                  }
              }
          }
  
          return InetAddress.getLoopbackAddress();
      }