From 273a9869bfaa8c207606ae5e32a27a3906349714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 7 Apr 2013 15:44:01 +0200 Subject: [PATCH] don't crash if the router does not want to talk to us --- OpenRA.Game/Game.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 57bc24b722..e134e464ab 100755 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -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)