Skip to content

Commit

Permalink
re-instate port forward and firewall opening commands
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbenson committed Sep 16, 2011
1 parent 5194b3f commit ed8880e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Source/YAMS-Library/Functions/Networking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public static bool CloseFirewallPort(int intPortNumber)
public static bool OpenUPnP(int intPortNumber, string strFriendlyName)
{
//First check if there is a upnp device to talk to
if (SharpUPnP.SharpUPnP.Discover())
if (UPnP.Discover())
{
try {
SharpUPnP.SharpUPnP.ForwardPort(intPortNumber, System.Net.Sockets.ProtocolType.Tcp, strFriendlyName);
UPnP.CreateForwardingRule(intPortNumber, System.Net.Sockets.ProtocolType.Tcp, strFriendlyName);
Database.AddLog("Forwarded port " + intPortNumber + " for " + strFriendlyName, "networking");
return true;
}
Expand All @@ -107,11 +107,11 @@ public static bool OpenUPnP(int intPortNumber, string strFriendlyName)
public static bool CloseUPnP(int intPortNumber)
{
//First check if there is a upnp device to talk to
if (SharpUPnP.SharpUPnP.Discover())
if (UPnP.Discover())
{
try
{
SharpUPnP.SharpUPnP.DeleteForwardingRule(intPortNumber, System.Net.Sockets.ProtocolType.Tcp);
UPnP.DeleteForwardingRule(intPortNumber, System.Net.Sockets.ProtocolType.Tcp);
Database.AddLog("Un-forwarded port " + intPortNumber, "networking");
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions Source/YAMS-Library/Objects/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ public void Start()
Database.AddLog("Server Started: " + strArgs, "server", "info", false, this.ServerID);

//Try and open the firewall port
//Networking.OpenFirewallPort(this.Port, this.ServerTitle);
//Networking.OpenUPnP(this.Port, this.ServerTitle);
Networking.OpenFirewallPort(this.Port, this.ServerTitle);
Networking.OpenUPnP(this.Port, this.ServerTitle);

//Save the process ID so we can kill if there is a crash
this.PID = this.prcMinecraft.Id;
Expand All @@ -201,8 +201,8 @@ public void Stop()
{
if (!Running) return;
//Close firewall
//Networking.CloseFirewallPort(this.Port);
//Networking.CloseUPnP(this.Port);
Networking.CloseFirewallPort(this.Port);
Networking.CloseUPnP(this.Port);

this.SafeStop = true;
this.Send("stop");
Expand Down
16 changes: 8 additions & 8 deletions Source/YAMS-Library/Web/WebServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public static void Init()
publicServerThread.Start();

//Open firewall ports and forward via UPnP
//Networking.OpenFirewallPort(Convert.ToInt32(YAMS.Database.GetSetting("AdminListenPort", "YAMS")), "YAMS - Admin website");
//Networking.OpenFirewallPort(Convert.ToInt32(YAMS.Database.GetSetting("PublicListenPort", "YAMS")), "YAMS - Public website");
//Networking.OpenUPnP(Convert.ToInt32(YAMS.Database.GetSetting("AdminListenPort", "YAMS")), "YAMS - Admin website");
//Networking.OpenUPnP(Convert.ToInt32(YAMS.Database.GetSetting("PublicListenPort", "YAMS")), "YAMS - Public website");
Networking.OpenFirewallPort(Convert.ToInt32(YAMS.Database.GetSetting("AdminListenPort", "YAMS")), "YAMS - Admin website");
Networking.OpenFirewallPort(Convert.ToInt32(YAMS.Database.GetSetting("PublicListenPort", "YAMS")), "YAMS - Public website");
Networking.OpenUPnP(Convert.ToInt32(YAMS.Database.GetSetting("AdminListenPort", "YAMS")), "YAMS - Admin website");
Networking.OpenUPnP(Convert.ToInt32(YAMS.Database.GetSetting("PublicListenPort", "YAMS")), "YAMS - Public website");
}

static void myServer_ErrorPageRequested(object sender, ErrorPageEventArgs e)
Expand Down Expand Up @@ -154,10 +154,10 @@ public static void StartPublic()
public static void Stop()
{
//Close firewall ports and forward via UPnP
//Networking.CloseFirewallPort(Convert.ToInt32(YAMS.Database.GetSetting("AdminListenPort", "YAMS")));
//Networking.CloseFirewallPort(Convert.ToInt32(YAMS.Database.GetSetting("PublicListenPort", "YAMS")));
//Networking.CloseUPnP(Convert.ToInt32(YAMS.Database.GetSetting("AdminListenPort", "YAMS")));
//Networking.CloseUPnP(Convert.ToInt32(YAMS.Database.GetSetting("PublicListenPort", "YAMS")));
Networking.CloseFirewallPort(Convert.ToInt32(YAMS.Database.GetSetting("AdminListenPort", "YAMS")));
Networking.CloseFirewallPort(Convert.ToInt32(YAMS.Database.GetSetting("PublicListenPort", "YAMS")));
Networking.CloseUPnP(Convert.ToInt32(YAMS.Database.GetSetting("AdminListenPort", "YAMS")));
Networking.CloseUPnP(Convert.ToInt32(YAMS.Database.GetSetting("PublicListenPort", "YAMS")));

adminServerThread.Abort();
publicServerThread.Abort();
Expand Down

0 comments on commit ed8880e

Please sign in to comment.