/*** Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: AuNetSrvInterfaces.cpp Date: 2022-11-14 Author: Reece ***/ #include "Networking.hpp" #include "AuNetSrvInterfaces.hpp" #include "AuNetAdapter.hpp" namespace Aurora::IO::Net { const AuString &NetSrvInterfaces::GetHostname() { AU_LOCK_GUARD(this->lock); if (this->bShouldUpdateCache) { UpdateCache(); } return hostname; } void NetSrvInterfaces::ResetAdapterCache() { AU_LOCK_GUARD(this->lock); this->bShouldUpdateCache = true; } void NetSrvInterfaces::UpdateCache() { this->hostname = NetAdapter::GetHostname(); auto ipv4s = NetAdapter::GetIPv4s(); auto ipv6s = NetAdapter::GetIPv6s(); this->adapters.clear(); this->adapters.insert(this->adapters.end(), ipv4s.begin(), ipv4s.end()); this->adapters.insert(this->adapters.end(), ipv6s.begin(), ipv6s.end()); } AuList> NetSrvInterfaces::GetAdapters() { AU_LOCK_GUARD(this->lock); if (this->bShouldUpdateCache) { UpdateCache(); } return this->adapters; } bool NetSrvInterfaces::IsSupportedOnOS() { #if defined(AURORA_PLATFORM_WIN32) return true; #endif #if defined(AURORA_PLATFORM_LINUX) return true; #endif return false; } }