mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-21 17:41:28 -08:00
Filter out !isSiteLocalAddress from addresses (#847)
Co-authored-by: Uriel <[email protected]>
This commit is contained in:
1 parent
3f307605cc
commit
6a30da671d
2 files changed
+4
-4
No files matched your search
@@ -5,9 +5,9 @@ import java.net.NetworkInterface
|
||||
object RPCUtil {
|
||||
@JvmStatic
|
||||
fun getLocalIp(): String =
|
||||
NetworkInterface.getNetworkInterfaces().asSequence().first {
|
||||
it.isUp && !it.isLoopback && !it.isVirtual && it.interfaceAddresses.any { it.broadcast != null }
|
||||
NetworkInterface.getNetworkInterfaces().asSequence().first { netInt ->
|
||||
netInt.isUp && !netInt.isLoopback && !netInt.isVirtual && netInt.interfaceAddresses.any { it.broadcast != null }
|
||||
}.interfaceAddresses.first {
|
||||
it.broadcast != null
|
||||
it.address.isSiteLocalAddress && it.broadcast != null
|
||||
}.address.hostAddress
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
}.map {
|
||||
// This ignores IPv6 addresses
|
||||
it.broadcast
|
||||
}.filterNotNull().map { InetSocketAddress(it, this.port) }.toList()
|
||||
}.filter { it != null && it.isSiteLocalAddress }.map { InetSocketAddress(it, this.port) }.toList()
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("[TrackerServer] Can't enumerate network interfaces", e)
|
||||
emptyList()
|
||||
|
||||
Reference in new issue
Block a user