don't crash if the router does not want to talk to us

This commit is contained in:
Matthias Mailänder
2013-04-07 15:44:01 +02:00
parent 3272b6725e
commit 273a9869bf

View File

@@ -311,14 +311,26 @@ namespace OpenRA
natDevice = args.Device;
Log.Write("server", "NAT device discovered.");
Log.Write("server", "Type: {0}", natDevice.GetType());
Log.Write("server", "Your external IP is: {0}", natDevice.GetExternalIP());
foreach (var mp in natDevice.GetAllMappings())
Log.Write("server", "Existing port mapping: protocol={0}, public={1}, private={2}", mp.Protocol, mp.PublicPort, mp.PrivatePort);
Settings.Server.NatDeviceAvailable = true;
Settings.Server.AllowUPnP = true;
try
{
Log.Write("server", "Type: {0}", natDevice.GetType());
Log.Write("server", "Your external IP is: {0}", natDevice.GetExternalIP());
foreach (var mp in natDevice.GetAllMappings())
Log.Write("server", "Existing port mapping: protocol={0}, public={1}, private={2}",
mp.Protocol, mp.PublicPort, mp.PrivatePort);
}
catch (Exception e)
{
Log.Write("server", "Can't fetch information from NAT device: {0}", e);
Settings.Server.NatDeviceAvailable = false;
Settings.Server.AllowUPnP = false;
}
}
public static void DeviceLost(object sender, DeviceEventArgs args)