slight upnp improvements/rewrite
This commit is contained in:
parent
6ae445a9e0
commit
9ef1586150
|
|
@ -15,7 +15,8 @@ public static class UPnP
|
|||
{
|
||||
public static void InitUPnP(EventHandler<DeviceEventArgs> DeviceFound, EventHandler<DeviceEventArgs> DeviceLost)
|
||||
{
|
||||
if (GlobalVars.UPnP == true) {
|
||||
if (GlobalVars.UPnP == true)
|
||||
{
|
||||
NatUtility.DeviceFound += DeviceFound;
|
||||
NatUtility.DeviceLost += DeviceLost;
|
||||
NatUtility.StartDiscovery();
|
||||
|
|
@ -24,22 +25,34 @@ public static class UPnP
|
|||
|
||||
public static void StartUPnP(INatDevice device, Protocol protocol, int port)
|
||||
{
|
||||
if (GlobalVars.UPnP == true) {
|
||||
int map = device.GetSpecificMapping(protocol, port).PublicPort;
|
||||
|
||||
if (map == -1) {
|
||||
device.CreatePortMap(new Mapping(protocol, port, port));
|
||||
if (GlobalVars.UPnP == true)
|
||||
{
|
||||
Mapping checker = device.GetSpecificMapping(protocol, port);
|
||||
int mapPublic = checker.PublicPort;
|
||||
int mapPrivate = checker.PrivatePort;
|
||||
|
||||
if (mapPublic == -1 && mapPrivate == -1)
|
||||
{
|
||||
Mapping portmap = new Mapping(protocol, port, port);
|
||||
portmap.Description = "Novetus";
|
||||
device.CreatePortMap(portmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopUPnP(INatDevice device, Protocol protocol, int port)
|
||||
{
|
||||
if (GlobalVars.UPnP == true) {
|
||||
int map = device.GetSpecificMapping(protocol, port).PublicPort;
|
||||
|
||||
if (map != -1) {
|
||||
device.DeletePortMap(new Mapping(protocol, port, port));
|
||||
if (GlobalVars.UPnP == true)
|
||||
{
|
||||
Mapping checker = device.GetSpecificMapping(protocol, port);
|
||||
int mapPublic = checker.PublicPort;
|
||||
int mapPrivate = checker.PrivatePort;
|
||||
|
||||
if (mapPublic != -1 && mapPrivate != -1)
|
||||
{
|
||||
Mapping portmap = new Mapping(protocol, port, port);
|
||||
portmap.Description = "Novetus";
|
||||
device.DeletePortMap(portmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1660,7 +1660,7 @@ namespace NovetusLauncher
|
|||
|
||||
void CheckBox4Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Please restart the Novetus launcher for this option to take effect.","Novetus - UPnP", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
MessageBox.Show("Please restart the Novetus launcher for this option to take effect." + Environment.NewLine + "Make sure to check if your router has UPnP functionality enabled. Please note that some routers may not support UPnP, and some ISPs will block the UPnP protocol. This may not work for all users.","Novetus - UPnP", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
void Button24Click(object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -1633,9 +1633,9 @@ namespace NovetusLauncher
|
|||
|
||||
void CheckBox4Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Please restart the Novetus launcher for this option to take effect.","Novetus - UPnP", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
MessageBox.Show("Please restart the Novetus launcher for this option to take effect." + Environment.NewLine + "Make sure to check if your router has UPnP functionality enabled. Please note that some routers may not support UPnP, and some ISPs will block the UPnP protocol. This may not work for all users.", "Novetus - UPnP", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
|
||||
void Button24Click(object sender, EventArgs e)
|
||||
{
|
||||
treeView1.Nodes.Clear();
|
||||
|
|
|
|||
Loading…
Reference in New Issue