more checks for NRE and setting to disable NAT discovery

This commit is contained in:
Matthias Mailänder
2013-04-09 13:03:37 +02:00
parent 1603485b33
commit 3abe58c4ae
2 changed files with 49 additions and 30 deletions

View File

@@ -265,6 +265,8 @@ namespace OpenRA
Log.AddChannel("sync", "syncreport.log"); Log.AddChannel("sync", "syncreport.log");
Log.AddChannel("server", "server.log"); Log.AddChannel("server", "server.log");
if (Settings.Server.DiscoverNatDevices)
{
try try
{ {
NatUtility.Logger = Log.Channels["server"].Writer; NatUtility.Logger = Log.Channels["server"].Writer;
@@ -281,6 +283,12 @@ namespace OpenRA
Settings.Server.NatDeviceAvailable = false; Settings.Server.NatDeviceAvailable = false;
Settings.Server.AllowUPnP = false; Settings.Server.AllowUPnP = false;
} }
}
else
{
Settings.Server.NatDeviceAvailable = false;
Settings.Server.AllowUPnP = false;
}
FileSystem.Mount("."); // Needed to access shaders FileSystem.Mount("."); // Needed to access shaders
Renderer.Initialize( Game.Settings.Graphics.Mode ); Renderer.Initialize( Game.Settings.Graphics.Mode );
@@ -293,6 +301,8 @@ namespace OpenRA
Sound.Create(Settings.Sound.Engine); Sound.Create(Settings.Sound.Engine);
InitializeWithMods(Settings.Game.Mods); InitializeWithMods(Settings.Game.Mods);
if (Settings.Server.DiscoverNatDevices)
{
RunAfterDelay(Settings.Server.NatDiscoveryTimeout, () => RunAfterDelay(Settings.Server.NatDiscoveryTimeout, () =>
{ {
Log.Write("server", "Stopping NAT discovery."); Log.Write("server", "Stopping NAT discovery.");
@@ -316,9 +326,13 @@ namespace OpenRA
} }
}); });
} }
}
public static void DeviceFound(object sender, DeviceEventArgs args) public static void DeviceFound(object sender, DeviceEventArgs args)
{ {
if (args.Device == null)
return;
Log.Write("server", "NAT device discovered."); Log.Write("server", "NAT device discovered.");
Settings.Server.NatDeviceAvailable = true; Settings.Server.NatDeviceAvailable = true;
@@ -347,6 +361,9 @@ namespace OpenRA
{ {
Log.Write("server", "NAT device lost."); Log.Write("server", "NAT device lost.");
if (args.Device == null)
return;
try try
{ {
natDevice = args.Device; natDevice = args.Device;

View File

@@ -29,7 +29,8 @@ namespace OpenRA.GameRules
public int ExternalPort = 1234; public int ExternalPort = 1234;
public bool AdvertiseOnline = true; public bool AdvertiseOnline = true;
public string MasterServer = "http://master.open-ra.org/"; public string MasterServer = "http://master.open-ra.org/";
public bool AllowUPnP = true; // let the user disable it public bool DiscoverNatDevices = true; // Allow users to disable NAT discovery if problems occur
public bool AllowUPnP = true; // let the user disable it even if compatible devices are found
public bool NatDeviceAvailable = false; // internal check if discovery succeeded public bool NatDeviceAvailable = false; // internal check if discovery succeeded
public int NatDiscoveryTimeout = 1000; // ms to search for UPnP enabled NATs public int NatDiscoveryTimeout = 1000; // ms to search for UPnP enabled NATs
public bool VerboseNatDiscovery = false; // print very detailed logs for debugging public bool VerboseNatDiscovery = false; // print very detailed logs for debugging
@@ -51,6 +52,7 @@ namespace OpenRA.GameRules
ExternalPort = other.ExternalPort; ExternalPort = other.ExternalPort;
AdvertiseOnline = other.AdvertiseOnline; AdvertiseOnline = other.AdvertiseOnline;
MasterServer = other.MasterServer; MasterServer = other.MasterServer;
DiscoverNatDevices = other.DiscoverNatDevices;
AllowUPnP = other.AllowUPnP; AllowUPnP = other.AllowUPnP;
NatDeviceAvailable = other.NatDeviceAvailable; NatDeviceAvailable = other.NatDeviceAvailable;
NatDiscoveryTimeout = other.NatDiscoveryTimeout; NatDiscoveryTimeout = other.NatDiscoveryTimeout;