use of com.biglybt.plugin.upnp.UPnPMapping in project BiglyBT by BiglySoftware.
the class NetworkAdminProtocolImpl method test.
@Override
public InetAddress test(NetworkAdminNetworkInterfaceAddress address, boolean upnp_map, NetworkAdminProgressListener listener) throws NetworkAdminException {
InetAddress bind_ip = address == null ? null : address.getAddress();
NetworkAdminProtocolTester tester;
if (type == PT_HTTP) {
tester = new NetworkAdminHTTPTester(core, listener);
} else if (type == PT_TCP) {
tester = new NetworkAdminTCPTester(core, listener);
} else {
tester = new NetworkAdminUDPTester(core, listener);
}
InetAddress res;
if (port <= 0) {
res = tester.testOutbound(bind_ip, 0);
} else {
UPnPMapping new_mapping = null;
if (upnp_map) {
PluginInterface pi_upnp = core.getPluginManager().getPluginInterfaceByClass(UPnPPlugin.class);
if (pi_upnp != null) {
UPnPPlugin upnp = (UPnPPlugin) pi_upnp.getPlugin();
UPnPMapping mapping = upnp.getMapping(type != PT_UDP, port);
if (mapping == null) {
new_mapping = mapping = upnp.addMapping("NAT Tester", type != PT_UDP, port, true);
try {
Thread.sleep(500);
} catch (Throwable e) {
}
}
}
}
try {
res = tester.testInbound(bind_ip, port);
} finally {
if (new_mapping != null) {
new_mapping.destroy();
}
}
}
return (res);
}
use of com.biglybt.plugin.upnp.UPnPMapping in project BiglyBT by BiglySoftware.
the class DeviceInternetGatewayImpl method getRequiredMappings.
protected Set<mapping> getRequiredMappings() {
Set<mapping> res = new TreeSet<>();
UPnPMapping[] required_mappings = current_mappings;
if (required_mappings != null) {
for (UPnPMapping mapping : required_mappings) {
if (mapping.isEnabled()) {
res.add(new mapping(mapping));
}
}
}
return (res);
}
Aggregations