Guest User

Untitled

a guest
Jun 6th, 2019
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. public IPAddress Address
  2. {
  3. get
  4. {
  5. try
  6. {
  7. if (address == null)
  8. {
  9. if (Utility.ValidateIPv4(ConVar.Server.ip) && !Utility.IsLocalIP(ConVar.Server.ip))
  10. {
  11. IPAddress.TryParse(ConVar.Server.ip, out address);
  12. Interface.uMod.LogInfo($"IP address from command-line: {address}");
  13. }
  14. else if (Steamworks.SteamServer.IsValid && Steamworks.SteamServer.PublicIp != null)
  15. {
  16. address = Steamworks.SteamServer.PublicIp;
  17. Interface.uMod.LogInfo($"IP address from Steam query: {address}");
  18. }
  19. else
  20. {
  21. WebClient webClient = new WebClient();
  22. IPAddress.TryParse(webClient.DownloadString("http://api.ipify.org"), out address);
  23. Interface.uMod.LogInfo($"IP address from external API: {address}");
  24. }
  25. }
  26.  
  27. return address;
  28. }
  29. catch (Exception ex)
  30. {
  31. RemoteLogger.Exception("Couldn't get server's public IP address", ex);
  32. return IPAddress.Any;
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment