Skip to content

Commit

Permalink
Added second port option
Browse files Browse the repository at this point in the history
  • Loading branch information
smithy212000 committed May 6, 2019
1 parent 5904bb3 commit c1af9f5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/com/lnicf/PortMiner/PortManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class PortManager {
// Initialise PortMapping and UpnpService variables.
private static PortMapping mapping = null;
private static UpnpService upnpService = null;
private static UpnpService upnpServicePlugin = null;

public static void openPort(String internalIP, int port, String name, String protocol) {
// Create mapping, then use it.
Expand All @@ -22,9 +23,27 @@ public static void openPort(String internalIP, int port, String name, String pro
upnpService = new UpnpServiceImpl(new PortMappingListener(mapping));
upnpService.getControlPoint().search();
}

public static void openPortPlugin(String internalIP, int port, String name, String protocol) {
// Create mapping, then use it.
if (protocol == "TCP") {
mapping = new PortMapping(port, internalIP, PortMapping.Protocol.TCP, name);
} else if (protocol == "UDP") {
mapping = new PortMapping(port, internalIP, PortMapping.Protocol.UDP, name);
} else {
mapping = new PortMapping(port, internalIP, PortMapping.Protocol.TCP, name);
}
upnpServicePlugin = new UpnpServiceImpl(new PortMappingListener(mapping));
upnpServicePlugin.getControlPoint().search();
}

public static void closePort() {
// Stop the UPnP service, closing the port.
upnpService.shutdown();
}

public static void closePortPlugin() {
// Stop the UPnP service, closing the port.
upnpServicePlugin.shutdown();
}
}

0 comments on commit c1af9f5

Please sign in to comment.