Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
add config value for ssl/https port (default=8443) adjust server routines to use config
regera71718a459a2
diff --git a/defaults/yacy.init b/defaults/yacy.initindex b499a6ca9..b3804ef7d 100644--- a/defaults/yacy.init+++ b/defaults/yacy.init@@ -10,6 +10,9 @@# port number where the server should bind toport = 8090+# optinal ssl port (https port) the server should bind to+port.ssl = 8443+# prefix for new default peer namespeernameprefix=_anon@@ -31,7 +34,7 @@ bindPort =## English speaking user read below:#-# With this you can access your peer using https://localhost:8090+# With this you can access your peer using https://localhost:8443## There are two possibilities to specify which certificate should# be used by YaCy.@@ -65,7 +68,7 @@ pkcs12ImportPwd =# the keyStore is only used, if server.https is set to true# if server.https=true, then the YaCy web interface is available at-# https://localhost:<port>/ and not at http://localhost:<port>/+# https://localhost:<port.ssl>/ and at http://localhost:<port>/server.https=false# property that collects the names of all servlets that had been used so fardiff --git a/source/net/yacy/http/Jetty8HttpServerImpl.java b/source/net/yacy/http/Jetty8HttpServerImpl.javaindex 35aedb6fc..47ebd07bf 100644--- a/source/net/yacy/http/Jetty8HttpServerImpl.java+++ b/source/net/yacy/http/Jetty8HttpServerImpl.java@@ -70,7 +70,6 @@ import org.eclipse.jetty.webapp.WebAppContext;public class Jetty8HttpServerImpl implements YaCyHttpServer {private final Server server;- private final int sslport = 8443; // the port to use for https/*** @param port TCP Port to listen for http requests@@ -90,6 +89,7 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer {final SslContextFactory sslContextFactory = new SslContextFactory();final SSLContext sslContext = initSslContext(sb);if (sslContext != null) {+ int sslport = sb.getConfigInt("port.ssl", 8443);sslContextFactory.setSslContext(sslContext);SslSelectChannelConnector sslconnector = new SslSelectChannelConnector(sslContextFactory);@@ -234,6 +234,9 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer {// TODO:}+ /**+ * @return true if ssl/https connector is available+ */@Overridepublic boolean withSSL() {Connector[] clist = server.getConnectors();@@ -242,16 +245,24 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer {}return false;}-++ /**+ * The port of actual running ssl connector+ * @return the ssl/https port or -1 if not active+ */@Overridepublic int getSslPort() {- return sslport;+ Connector[] clist = server.getConnectors();+ for (Connector c:clist) {+ if (c.getName().startsWith("ssl")) return c.getPort();+ }+ return -1;}/*** reconnect with new port settings (after waiting milsec) - routine returns* immediately- *+ * checks http and ssl connector for new port settings* @param milsec wait time*/@Override@@ -271,7 +282,9 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer {try { // reconnect with new settings (instead to stop/start server, just manipulate connectorsfinal Connector[] cons = server.getConnectors();final int port = Switchboard.getSwitchboard().getConfigInt("port", 8090);+ final int sslport = Switchboard.getSwitchboard().getConfigInt("port.ssl", 8443);for (Connector con : cons) {+ // check http connectorif (con.getName().startsWith("httpd") && con.getPort() != port) {con.close();con.stop();@@ -280,7 +293,19 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer {}con.setPort(port);con.start();- ConcurrentLog.fine("SERVER", "set new port for Jetty connector " + con.getName());+ ConcurrentLog.info("SERVER", "set new port for Jetty connector " + con.getName());+ continue;+ }+ // check https connector+ if (con.getName().startsWith("ssl") && con.getPort() != sslport) {+ con.close();+ con.stop();+ if (!con.isStopped()) {+ ConcurrentLog.warn("SERVER", "Reconnect: Jetty Connector failed to stop");+ }+ con.setPort(sslport);+ con.start();+ ConcurrentLog.info("SERVER", "set new port for Jetty connector " + con.getName());}}} catch (Exception ex) {