public async Task InitializeAsync(string name = "AsyncFileServer") { if (IsInitialized) { return; } MyInfo.Name = name; MyInfo.Platform = Environment.OSVersion.Platform.ToServerPlatform(); MyInfo.TransferFolder = _settings.LocalServerFolderPath; MyInfo.PortNumber = _settings.LocalServerPortNumber; var getLocalIp = NetworkUtilities.GetLocalIPv4Address(_settings.LocalNetworkCidrIp); MyInfo.LocalIpAddress = getLocalIp.Success ? getLocalIp.Value : IPAddress.Loopback; var getPublicIp = await NetworkUtilities.GetPublicIPv4AddressAsync().ConfigureAwait(false); MyInfo.PublicIpAddress = getPublicIp.Success ? getPublicIp.Value : IPAddress.None; if (getLocalIp.Success) { MyInfo.SessionIpAddress = MyInfo.LocalIpAddress; } else if (getPublicIp.Success) { MyInfo.SessionIpAddress = MyInfo.PublicIpAddress; } IsInitialized = true; }