catch MappingExceptions in NatDevice.GetExternalIP

This commit is contained in:
Matthias Mailänder
2015-11-22 11:37:58 +01:00
parent bacac082cc
commit 86a2a54640
2 changed files with 19 additions and 3 deletions

View File

@@ -9,7 +9,7 @@
#endregion
using System;
using System.Net;
using Mono.Nat;
namespace OpenRA.Network
@@ -116,5 +116,21 @@ namespace OpenRA.Network
Game.Settings.Server.AllowPortForward = false;
}
}
public static IPAddress GetExternalIP()
{
if (NatDevice == null)
return null;
try
{
return NatDevice.GetExternalIP();
}
catch (Exception e)
{
Log.Write("server", "Failed to get the external IP from NAT device: {0}", e);
return null;
}
}
}
}