Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
add switchboardconstants for server ports config keys
regera2afb4bae0d9
diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.javaindex c16169a7a..2334ea074 100644--- a/htroot/ConfigBasic.java+++ b/htroot/ConfigBasic.java@@ -136,7 +136,7 @@ public class ConfigBasic {if (!(env.getLocalPort() == port) || env.getConfigBool("server.https", false) != ssl) {// validate portfinal YaCyHttpServer theServerCore = env.getHttpServer();- env.setConfig("port", port);+ env.setConfig(SwitchboardConstants.SERVER_PORT, port);env.setConfig("server.https", ssl);// redirect the browser to the new portdiff --git a/htroot/QuickCrawlLink_p.java b/htroot/QuickCrawlLink_p.javaindex aab340ea9..a59893947 100644--- a/htroot/QuickCrawlLink_p.java+++ b/htroot/QuickCrawlLink_p.java@@ -42,6 +42,7 @@ import net.yacy.cora.protocol.RequestHeader;import net.yacy.crawler.data.CrawlProfile;import net.yacy.crawler.retrieval.Request;import net.yacy.search.Switchboard;+import net.yacy.search.SwitchboardConstants;import net.yacy.search.index.Segment;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;@@ -67,7 +68,7 @@ public class QuickCrawlLink_p {if (header.containsKey(HeaderFramework.HOST)) {port = header.getServerPort();} else {- port = sb.getConfigInt("port", 8090);+ port = sb.getConfigInt(SwitchboardConstants.SERVER_PORT, 8090);}prop.put("mode_host", Domains.LOCALHOST);diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.javaindex 9e880558b..2ee5608bc 100644--- a/htroot/SettingsAck_p.java+++ b/htroot/SettingsAck_p.java@@ -200,11 +200,11 @@ public class SettingsAck_p {if (error == null) {serverCore.useStaticIP = true;sb.peers.mySeed().setIP(staticIP);- env.setConfig("staticIP", staticIP);+ env.setConfig(SwitchboardConstants.SERVER_STATICIP, staticIP);} else {serverCore.useStaticIP = false;sb.peers.mySeed().setIP("");- env.setConfig("staticIP", "");+ env.setConfig(SwitchboardConstants.SERVER_STATICIP, "");}// server access data@@ -538,8 +538,8 @@ public class SettingsAck_p {prop.put("needsRestart_referer", "Settings_p.html?page=ProxyAccess");int port = post.getInt("port.ssl", 8443);- if (port > 0 && port != env.getConfigInt("port.ssl", 8443)) {- env.setConfig("port.ssl", port);+ if (port > 0 && port != env.getConfigInt(SwitchboardConstants.SERVER_SSLPORT, 8443)) {+ env.setConfig(SwitchboardConstants.SERVER_SSLPORT, port);}prop.put("info_port.ssl", port);prop.put("info", "32");diff --git a/htroot/api/snapshot.java b/htroot/api/snapshot.javaindex 5c4ebcd78..5ddf7cfba 100644--- a/htroot/api/snapshot.java+++ b/htroot/api/snapshot.java@@ -259,10 +259,10 @@ public class snapshot {SolrDocument sd = sb.index.fulltext().getMetadata(durl.hash());boolean success = false;if (sd == null) {- success = Transactions.store(durl, new Date(), 99, false, true, sb.getConfigBool(SwitchboardConstants.PROXY_TRANSPARENT_PROXY, false) ? "http://127.0.0.1:" + sb.getConfigInt("port", 8090) : null, sb.getConfig("crawler.http.acceptLanguage", null));+ success = Transactions.store(durl, new Date(), 99, false, true, sb.getConfigBool(SwitchboardConstants.PROXY_TRANSPARENT_PROXY, false) ? "http://127.0.0.1:" + sb.getConfigInt(SwitchboardConstants.SERVER_PORT, 8090) : null, sb.getConfig("crawler.http.acceptLanguage", null));} else {SolrInputDocument sid = sb.index.fulltext().getDefaultConfiguration().toSolrInputDocument(sd);- success = Transactions.store(sid, false, true, true, sb.getConfigBool(SwitchboardConstants.PROXY_TRANSPARENT_PROXY, false) ? "http://127.0.0.1:" + sb.getConfigInt("port", 8090) : null, sb.getConfig("crawler.http.acceptLanguage", null));+ success = Transactions.store(sid, false, true, true, sb.getConfigBool(SwitchboardConstants.PROXY_TRANSPARENT_PROXY, false) ? "http://127.0.0.1:" + sb.getConfigInt(SwitchboardConstants.SERVER_PORT, 8090) : null, sb.getConfig("crawler.http.acceptLanguage", null));}if (success) {pdfSnapshots = Transactions.findPaths(durl, "pdf", Transactions.State.ANY);diff --git a/source/net/yacy/gui/Tray.java b/source/net/yacy/gui/Tray.javaindex 30904b54d..9ccfb760e 100644--- a/source/net/yacy/gui/Tray.java+++ b/source/net/yacy/gui/Tray.java@@ -273,7 +273,7 @@ public final class Tray {private void openBrowserPage(final String browserPopUpPage) {if(!menuEnabled) return;// no need for https, because we are on localhost- Browser.openBrowser("http://localhost:" + sb.getConfig("port", "8090") + "/" + browserPopUpPage);+ Browser.openBrowser("http://localhost:" + sb.getConfig(SwitchboardConstants.SERVER_PORT, "8090") + "/" + browserPopUpPage);}private PopupMenu getPopupMenu() {diff --git a/source/net/yacy/http/Jetty9HttpServerImpl.java b/source/net/yacy/http/Jetty9HttpServerImpl.javaindex bea74f68f..6c0fd67dc 100644--- a/source/net/yacy/http/Jetty9HttpServerImpl.java+++ b/source/net/yacy/http/Jetty9HttpServerImpl.java@@ -83,7 +83,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {final SSLContext sslContext = initSslContext(sb);if (sslContext != null) {- int sslport = sb.getConfigInt("port.ssl", 8443);+ int sslport = sb.getConfigInt(SwitchboardConstants.SERVER_SSLPORT, 8443);sslContextFactory.setSslContext(sslContext);// SSL HTTP Configuration@@ -298,7 +298,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {try { // reconnect with new settings (instead to stop/start server, just manipulate connectorsfinal Connector[] cons = server.getConnectors();final int port = Switchboard.getSwitchboard().getLocalPort();- final int sslport = Switchboard.getSwitchboard().getConfigInt("port.ssl", 8443);+ final int sslport = Switchboard.getSwitchboard().getConfigInt(SwitchboardConstants.SERVER_SSLPORT, 8443);for (Connector con : cons) {// check http connectorif (con.getName().startsWith("httpd") && ((ServerConnector)con).getPort() != port) {diff --git a/source/net/yacy/migration.java b/source/net/yacy/migration.javaindex fdc174904..e53e0c22f 100644--- a/source/net/yacy/migration.java+++ b/source/net/yacy/migration.java@@ -83,7 +83,7 @@ public class migration {if (sb.getConfigBool("server.https", false)) {int sslport = 8443;if (fromVer > SSLPORT_CFG) {- sslport = sb.getConfigInt("port.ssl", 8443);+ sslport = sb.getConfigInt(SwitchboardConstants.SERVER_SSLPORT, 8443);}if (TimeoutRequest.ping("127.0.0.1", sslport, 3000)) {sb.setConfig("server.https", false);diff --git a/source/net/yacy/peers/Network.java b/source/net/yacy/peers/Network.javaindex 79ba206b2..25f4c90fe 100644--- a/source/net/yacy/peers/Network.java+++ b/source/net/yacy/peers/Network.java@@ -99,7 +99,7 @@ public class Networkpeernews.addMessage(new RSSMessage("YaCy started", "", ""));// ensure that correct IP is used- final String staticIP = sb.getConfig("staticIP", "");+ final String staticIP = sb.getConfig(SwitchboardConstants.SERVER_STATICIP, "");if (staticIP.length() != 0 && Seed.isProperIP(staticIP)) {serverCore.useStaticIP = true;sb.peers.mySeed().setIP(staticIP);@@ -423,7 +423,7 @@ public class Networkif (this.sb.peers.mySeed().isProper(true) == null) return true;// still no success- final String ip = this.sb.getConfig("staticIP", "");+ final String ip = this.sb.getConfig(SwitchboardConstants.SERVER_STATICIP, "");if (Seed.isProperIP(ip)) {this.sb.peers.mySeed().setIP(ip);diff --git a/source/net/yacy/peers/Seed.java b/source/net/yacy/peers/Seed.javaindex c029c0d50..67657d681 100644--- a/source/net/yacy/peers/Seed.java+++ b/source/net/yacy/peers/Seed.java@@ -79,6 +79,7 @@ import net.yacy.kelondro.util.MapTools;import net.yacy.kelondro.util.OS;import net.yacy.peers.operation.yacyVersion;import net.yacy.search.Switchboard;+import net.yacy.search.SwitchboardConstants;import net.yacy.utils.Bitfield;import net.yacy.utils.crypt;@@ -1135,7 +1136,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>final Seed newSeed = new Seed(hashs);// now calculate other information about the host- final int port = Switchboard.getSwitchboard().getPublicPort("port", 8090); //get port from config+ final int port = Switchboard.getSwitchboard().getPublicPort(SwitchboardConstants.SERVER_PORT, 8090); //get port from confignewSeed.dna.put(Seed.NAME, defaultPeerName() );newSeed.dna.put(Seed.PORT, Integer.toString(port));return newSeed;diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.javaindex e0986331f..13fedf146 100644--- a/source/net/yacy/search/Switchboard.java+++ b/source/net/yacy/search/Switchboard.java@@ -2529,12 +2529,12 @@ public final class Switchboard extends serverSwitch {checkInterruption();// execute the (post-) processing steps for all entries that have a process tag assigned- Fulltext fulltext = index.fulltext();- CollectionConfiguration collection1Configuration = fulltext.getDefaultConfiguration();boolean allCrawlsFinished = this.crawler.allCrawlsFinished(this.crawlQueues);int proccount = 0;if (!this.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)) {+ Fulltext fulltext = index.fulltext();+ CollectionConfiguration collection1Configuration = fulltext.getDefaultConfiguration();boolean process_key_exist = collection1Configuration.contains(CollectionSchema.process_sxt);if (!process_key_exist) log.info("postprocessing deactivated: field process_sxt is not enabled");@@ -3016,7 +3016,7 @@ public final class Switchboard extends serverSwitch {searchEvent,sourceName,getConfigBool(SwitchboardConstants.DHT_ENABLED, false),- this.getConfigBool(SwitchboardConstants.PROXY_TRANSPARENT_PROXY, false) ? "http://127.0.0.1:" + sb.getConfigInt("port", 8090) : null,+ this.getConfigBool(SwitchboardConstants.PROXY_TRANSPARENT_PROXY, false) ? "http://127.0.0.1:" + sb.getConfigInt(SwitchboardConstants.SERVER_PORT, 8090) : null,this.getConfig("crawler.http.acceptLanguage", null));final RSSFeed feed =EventChannel.channels(queueEntry.initiator() == null@@ -3907,7 +3907,7 @@ public final class Switchboard extends serverSwitch {private static long indeSizeCache = 0;private static long indexSizeTime = 0;public void updateMySeed() {- this.peers.mySeed().put(Seed.PORT, Integer.toString(getPublicPort("port", 8090)));+ this.peers.mySeed().put(Seed.PORT, Integer.toString(getPublicPort(SwitchboardConstants.SERVER_PORT, 8090)));//the speed of indexing (pages/minute) of the peerfinal long uptime = (System.currentTimeMillis() - this.startupTime) / 1000;@@ -3935,10 +3935,10 @@ public final class Switchboard extends serverSwitch {mySeed.setFlagAcceptRemoteCrawl(getConfigBool(SwitchboardConstants.CRAWLJOB_REMOTE, false));mySeed.setFlagAcceptRemoteIndex(getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true));mySeed.setFlagSSLAvailable(this.getHttpServer() != null && this.getHttpServer().withSSL() && getConfigBool("server.https", false));- if (mySeed.getFlagSSLAvailable()) mySeed.put(Seed.PORTSSL, Integer.toString(getPublicPort("port.ssl", 8443)));+ if (mySeed.getFlagSSLAvailable()) mySeed.put(Seed.PORTSSL, Integer.toString(getPublicPort(SwitchboardConstants.SERVER_SSLPORT, 8443)));// set local ips- String staticIP = this.getConfig("staticIP", "");+ String staticIP = this.getConfig(SwitchboardConstants.SERVER_STATICIP, "");if (staticIP.length() > 0) mySeed.setIP(staticIP);Set<String> publicips = myPublicIPs();if (!mySeed.clash(publicips)) mySeed.setIPs(publicips);diff --git a/source/net/yacy/search/SwitchboardConstants.java b/source/net/yacy/search/SwitchboardConstants.javaindex 73bb0cde1..8e1892006 100644--- a/source/net/yacy/search/SwitchboardConstants.java+++ b/source/net/yacy/search/SwitchboardConstants.java@@ -43,7 +43,7 @@ public final class SwitchboardConstants {* With introduction of DIGEST authentication all passwords are MD5 encoded and calculatd as <code>username:adminrealm:password</code>* To differentiate old and new admin passwords, use the new calculated passwords a "MD5:" prefix.*/-+public static final String ADMIN_ACCOUNT = "adminAccount"; // not used anymore (did hold clear text username:pwd)// this holds the credential "MD5:" + Digest.encodeMD5Hex(adminAccountUserName + ":" + adminRealm + ":" + password)@@ -53,7 +53,12 @@ public final class SwitchboardConstants {public static final String ADMIN_ACCOUNT_FOR_LOCALHOST = "adminAccountForLocalhost";public static final String ADMIN_ACCOUNT_All_PAGES = "adminAccountAllPages";public static final String ADMIN_REALM = "adminRealm";-++ // server settings+ public static final String SERVER_PORT = "port"; // port for the http server+ public static final String SERVER_SSLPORT = "port.ssl"; // port for https+ public static final String SERVER_STATICIP = "staticIP"; // static IP of http server+public static final String PUBLIC_SEARCHPAGE = "publicSearchpage";public static final int CRAWLJOB_SYNC = 0;diff --git a/source/net/yacy/utils/upnp/UPnP.java b/source/net/yacy/utils/upnp/UPnP.javaindex 267a644a3..a1cca7a75 100644--- a/source/net/yacy/utils/upnp/UPnP.java+++ b/source/net/yacy/utils/upnp/UPnP.java@@ -32,6 +32,7 @@ import javax.xml.parsers.ParserConfigurationException;import net.yacy.cora.util.ConcurrentLog;import net.yacy.search.Switchboard;+import net.yacy.search.SwitchboardConstants;import org.bitlet.weupnp.GatewayDevice;import org.bitlet.weupnp.GatewayDiscover;@@ -53,9 +54,9 @@ public class UPnP {private static final Map<UPnPMappingType, UPnPMapping> MAPPINGS = new EnumMap<>(UPnPMappingType.class);static {- MAPPINGS.put(UPnPMappingType.HTTP, new UPnPMapping("port", null, "TCP",+ MAPPINGS.put(UPnPMappingType.HTTP, new UPnPMapping(SwitchboardConstants.SERVER_PORT, null, "TCP","YaCy HTTP"));- MAPPINGS.put(UPnPMappingType.HTTPS, new UPnPMapping("port.ssl",+ MAPPINGS.put(UPnPMappingType.HTTPS, new UPnPMapping(SwitchboardConstants.SERVER_SSLPORT,"server.https", "TCP", "YaCy HTTPS"));}diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.javaindex a01705563..dfba00ca0 100644--- a/source/net/yacy/yacy.java+++ b/source/net/yacy/yacy.java@@ -559,7 +559,7 @@ public final class yacy {final Properties config = configuration("COMMAND-STEERING", homePath);// read port- final int port = Integer.parseInt(config.getProperty("port", "8090"));+ final int port = Integer.parseInt(config.getProperty(SwitchboardConstants.SERVER_PORT, "8090"));// read passwordString encodedPassword = (String) config.get(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5);@@ -634,7 +634,7 @@ public final class yacy {// prevents also creation of a log file while just opening browserSystem.out.println("WARNING: the file " + lockFile + " exists, this usually means that a YaCy instance is still running. If you want to restart YaCy, try first ./stopYACY.sh, then ./startYACY.sh. If ./stopYACY.sh fails, try ./killYACY.sh");- int port = Integer.parseInt(p.getProperty("port", "8090"));+ int port = Integer.parseInt(p.getProperty(SwitchboardConstants.SERVER_PORT, "8090"));if (TimeoutRequest.ping("127.0.0.1", port, 1000)) {Browser.openBrowser("http://localhost:" + port + "/" + p.getProperty(SwitchboardConstants.BROWSER_POP_UP_PAGE, "index.html"));// Thats it; YaCy was running, the user is happy, we can stop now.