Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Android LAN Discovery fix - same as on develop branch #361

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,31 @@ private static IPAddress[] GetLocalIPs() {
List<IPAddress> ipList = new List<IPAddress>();

foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) {

#if UNITY_ANDROID
switch (nic.Name)
{
case "lo": // Localhost
case "wlan0": // Wifi
break;
default:
continue;
}

switch (nic.OperationalStatus)
{
case OperationalStatus.Up:
case OperationalStatus.Testing:
case OperationalStatus.Unknown:
case OperationalStatus.Dormant:
break;
case OperationalStatus.Down:
case OperationalStatus.NotPresent:
case OperationalStatus.LowerLayerDown:
default:
continue;
}
#else
switch (nic.NetworkInterfaceType) {
case NetworkInterfaceType.Wireless80211:
case NetworkInterfaceType.Ethernet:
Expand All @@ -1121,7 +1146,7 @@ private static IPAddress[] GetLocalIPs() {
}

if (nic.OperationalStatus != OperationalStatus.Up) continue;

#endif
foreach (UnicastIPAddressInformation ip in nic.GetIPProperties().UnicastAddresses) {
if (ip.Address.AddressFamily == AddressFamily.InterNetwork) {
ipList.Add(ip.Address);
Expand Down