Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public IPAddress Address
- {
- get
- {
- try
- {
- if (address == null)
- {
- if (Utility.ValidateIPv4(ConVar.Server.ip) && !Utility.IsLocalIP(ConVar.Server.ip))
- {
- IPAddress.TryParse(ConVar.Server.ip, out address);
- Interface.uMod.LogInfo($"IP address from command-line: {address}");
- }
- else if (Steamworks.SteamServer.IsValid && Steamworks.SteamServer.PublicIp != null)
- {
- address = Steamworks.SteamServer.PublicIp;
- Interface.uMod.LogInfo($"IP address from Steam query: {address}");
- }
- else
- {
- WebClient webClient = new WebClient();
- IPAddress.TryParse(webClient.DownloadString("http://api.ipify.org"), out address);
- Interface.uMod.LogInfo($"IP address from external API: {address}");
- }
- }
- return address;
- }
- catch (Exception ex)
- {
- RemoteLogger.Exception("Couldn't get server's public IP address", ex);
- return IPAddress.Any;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment