mirror of https://github.com/quasar/Quasar.git
Close port on exit (UPnP)
This commit is contained in:
parent
34e0cfd9b5
commit
cc825fabb2
|
@ -34,12 +34,25 @@ public static void ForwardPort(ushort port)
|
|||
|
||||
try
|
||||
{
|
||||
UPnPNAT upnpNat = new UPnPNAT();
|
||||
IStaticPortMappingCollection portMap = upnpNat.StaticPortMappingCollection;
|
||||
portMap.Add(port, "TCP", port, ipAddr, true, "xRAT 2.0.0.0 UPnP");
|
||||
IStaticPortMappingCollection portMap = new UPnPNAT().StaticPortMappingCollection;
|
||||
if (portMap != null)
|
||||
portMap.Add(port, "TCP", port, ipAddr, true, "xRAT 2.0 UPnP");
|
||||
}
|
||||
catch { return; }
|
||||
catch
|
||||
{ }
|
||||
}).Start();
|
||||
}
|
||||
|
||||
public static void RemovePort(ushort port)
|
||||
{
|
||||
try
|
||||
{
|
||||
IStaticPortMappingCollection portMap = new UPnPNAT().StaticPortMappingCollection;
|
||||
if (portMap != null)
|
||||
portMap.Remove(port, "TCP");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,6 +125,9 @@ private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
|
|||
if (listenServer.Listening)
|
||||
listenServer.Disconnect();
|
||||
|
||||
if (XMLSettings.UseUPnP)
|
||||
UPnP.RemovePort(ushort.Parse(XMLSettings.ListenPort.ToString()));
|
||||
|
||||
nIcon.Visible = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue