Tiarait / HTTP-FS-file-server

This is a http, webdav server for sharing files between users on a Wi-Fi network. The online file sharing application works like a local HTTP server.
https://tiarait.github.io/Http-FS-Intro/
Apache License 2.0
72 stars 9 forks source link

How to set IP address? #50

Open bluelavalamp opened 1 month ago

bluelavalamp commented 1 month ago

The IP address is being assigned and I can't figure out how to change it. Problem is my netmask is 255.225.0.0 with machines being on 10.0.X.X. But HTTP-FS is picking 10.12.125.48 as the IP address for the server. Is there a way to change it?

Tiarait commented 1 month ago

The application automatically selects the device's IP address. You can only choose between localhost, IPv4, IPv6 in "Settings - Server settings - IP" where "All" is automatic.

The method for determining the IP looks like this

val ipAddressInLocalNetwork: String
        get() {
            val networkInterfaces = NetworkInterface.getNetworkInterfaces().iterator().asSequence()
            val localAddresses = networkInterfaces.flatMap {
                it.inetAddresses.asSequence()
                    .filter { inetAddress ->
                        inetAddress.isSiteLocalAddress && inetAddress.hostAddress?.contains(":") == false &&
                                inetAddress.hostAddress != "127.0.0.1"
                    }
                    .map { inetAddress -> inetAddress.hostAddress }
            }
            return localAddresses.firstOrNull() ?: "127.0.0.1"
        }

In the next version I will experiment and try to give the user a list of all available IPs. (I don't know how successful this will be)

bluelavalamp commented 1 month ago

Would it be possible to use the IP address already assigned to the device for WIFI? Or add that selection as an option.