MCPcopy Create free account
hub / github.com/MeisApps/pcbu-desktop / GetSavedNetworkInterface

Method GetSavedNetworkInterface

common/src/platform/NetworkHelper.cpp:208–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208NetworkInterface NetworkHelper::GetSavedNetworkInterface() {
209 NetworkInterface result{};
210 auto localIfs = NetworkHelper::GetLocalNetInterfaces();
211 auto settings = AppSettings::Get();
212 auto found = false;
213 if(settings.serverIP == "auto") {
214 for(const auto &netIf : localIfs) {
215 if(netIf.macAddress == settings.serverMAC) {
216 result = netIf;
217 found = true;
218 break;
219 }
220 }
221 if(!found) {
222 if(!localIfs.empty())
223 result = localIfs[0];
224 else
225 spdlog::warn("Invalid server IP settings.");
226 }
227 } else {
228 result.ipAddress = settings.serverIP;
229 }
230 return result;
231}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected