use of com.predic8.membrane.core.transport.http.IpPort in project service-proxy by membrane.
the class RuleManager method openPorts.
public synchronized void openPorts() throws IOException {
HashMap<IpPort, SSLProvider> sslProviders;
try {
HashMap<IpPort, SSLContextCollection.Builder> sslContexts = new HashMap<IpPort, SSLContextCollection.Builder>();
for (Rule rule : rules) {
SSLContext sslContext = rule.getSslInboundContext();
if (sslContext != null) {
IpPort ipPort = new IpPort(rule.getKey().getIp(), rule.getKey().getPort());
SSLContextCollection.Builder builder = sslContexts.get(ipPort);
if (builder == null) {
builder = new SSLContextCollection.Builder();
sslContexts.put(ipPort, builder);
}
builder.add(sslContext);
}
}
sslProviders = new HashMap<IpPort, SSLProvider>();
for (Map.Entry<IpPort, SSLContextCollection.Builder> entry : sslContexts.entrySet()) sslProviders.put(entry.getKey(), entry.getValue().build());
} catch (ConfigurationException e) {
throw new IOException(e);
}
for (Rule rule : rules) {
IpPort ipPort = new IpPort(rule.getKey().getIp(), rule.getKey().getPort());
router.getTransport().openPort(rule.getKey().getIp(), rule.getKey().getPort(), sslProviders.get(ipPort));
}
}
use of com.predic8.membrane.core.transport.http.IpPort in project service-proxy by membrane.
the class HttpTransport method openPort.
/**
* @param port
* @throws IOException
*/
@Override
public synchronized void openPort(String ip, int port, SSLProvider sslProvider) throws IOException {
if (isAnyThreadListeningAt(ip, port)) {
return;
}
if (port == -1)
throw new RuntimeException("The port-attribute is missing (probably on a <serviceProxy> element).");
HttpEndpointListener portListenerThread = new HttpEndpointListener(ip, port, this, sslProvider);
portListenerMapping.put(new IpPort(ip, port), portListenerThread);
portListenerThread.start();
for (IPortChangeListener listener : menuListeners) {
listener.addPort(port);
}
}
use of com.predic8.membrane.core.transport.http.IpPort in project service-proxy by membrane.
the class HttpTransport method closePort.
/**
* Closes the corresponding server port. Note that connections might still be open and exchanges still running after
* this method completes.
*/
public synchronized void closePort(String ip, int port) throws IOException {
IpPort p = new IpPort(ip, port);
log.debug("Closing server port: " + p);
HttpEndpointListener plt = portListenerMapping.get(p);
if (plt == null)
return;
plt.closePort();
try {
plt.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
portListenerMapping.remove(p);
stillRunning.add(new WeakReference<HttpEndpointListener>(plt));
for (IPortChangeListener listener : menuListeners) {
listener.removePort(port);
}
}
Aggregations