Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

differentiate api call getLocalPort() from getConfigInt()

regera60b1fb6c2eb
diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java
index 0e2d5a6fc..5027819b0 100644
--- a/htroot/ConfigBasic.java
+++ b/htroot/ConfigBasic.java
@@ -100,7 +100,7 @@ public class ConfigBasic {
port = post.getLong("port", 8090);
ssl = post.getBoolean("withssl");
} else {
- port = env.getLocalPort("port", 8090); //this allows a low port, but it will only get one, if the user edits the config himself.
+ port = env.getLocalPort(); //this allows a low port, but it will only get one, if the user edits the config himself.
ssl = env.getConfigBool("server.https", false);
}
if (ssl) prop.put("withsslenabled_sslport",env.getHttpServer().getSslPort());
@@ -266,7 +266,7 @@ public class ConfigBasic {
// set default values
prop.putHTML("defaultName", sb.peers.mySeed().getName());
- prop.put("defaultPort", env.getLocalPort("port", 8090));
+ prop.put("defaultPort", env.getLocalPort());
prop.put("withsslenabled", env.getConfigBool("server.https", false) ? 1 : 0);
lang = env.getConfig("locale.language", "default"); // re-assign lang, may have changed
prop.put("lang_de", "0");
diff --git a/htroot/ConfigPortal.java b/htroot/ConfigPortal.java
index 3aa5627b3..2205e2fa9 100644
--- a/htroot/ConfigPortal.java
+++ b/htroot/ConfigPortal.java
@@ -224,7 +224,7 @@ public class ConfigPortal {
String myaddress = (sb.peers == null) || sb.peers.mySeed() == null || sb.peers.mySeed().getIP() == null ? null : sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
if (myaddress == null) {
- myaddress = "localhost:" + sb.getLocalPort("port", 8090);
+ myaddress = "localhost:" + sb.getLocalPort();
}
prop.put("myaddress", myaddress);
return prop;
diff --git a/htroot/ConfigSearchBox.java b/htroot/ConfigSearchBox.java
index c64bf7293..eb9d953e9 100644
--- a/htroot/ConfigSearchBox.java
+++ b/htroot/ConfigSearchBox.java
@@ -35,7 +35,7 @@ public class ConfigSearchBox {
final Switchboard sb = (Switchboard) env;
String myaddress = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
- if (myaddress == null) myaddress = "localhost:" + sb.getLocalPort("port", 8090);
+ if (myaddress == null) myaddress = "localhost:" + sb.getLocalPort();
prop.put("myaddress", myaddress);
return prop;
}
diff --git a/htroot/CrawlStartScanner_p.java b/htroot/CrawlStartScanner_p.java
index ed5386376..1b93abb4a 100644
--- a/htroot/CrawlStartScanner_p.java
+++ b/htroot/CrawlStartScanner_p.java
@@ -214,7 +214,7 @@ public class CrawlStartScanner_p
path += "&crawlingURL=" + url.toNormalform(true);
WorkTables.execAPICall(
Domains.LOCALHOST,
- sb.getLocalPort("port", 8090),
+ sb.getLocalPort(),
path,
pk,
sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"),
@@ -261,7 +261,7 @@ public class CrawlStartScanner_p
path += "&crawlingURL=" + urlString;
WorkTables.execAPICall(
Domains.LOCALHOST,
- sb.getLocalPort("port", 8090),
+ sb.getLocalPort(),
path,
u.hash(),
sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"),
diff --git a/htroot/Load_MediawikiWiki.java b/htroot/Load_MediawikiWiki.java
index bb18ba755..5260a68d6 100644
--- a/htroot/Load_MediawikiWiki.java
+++ b/htroot/Load_MediawikiWiki.java
@@ -39,7 +39,7 @@ public class Load_MediawikiWiki {
// define visible variables
String a = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
- if (a == null) a = "localhost:" + sb.getLocalPort("port", 8090);
+ if (a == null) a = "localhost:" + sb.getLocalPort();
final boolean intranet = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "").equals("intranet");
final String repository = "http://" + a + "/repository/";
prop.put("starturl", (intranet) ? repository : "http://");
diff --git a/htroot/Load_PHPBB3.java b/htroot/Load_PHPBB3.java
index bc9b3d9f0..e7d03398f 100644
--- a/htroot/Load_PHPBB3.java
+++ b/htroot/Load_PHPBB3.java
@@ -39,7 +39,7 @@ public class Load_PHPBB3 {
// define visible variables
String a = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
- if (a == null) a = "localhost:" + sb.getLocalPort("port", 8090);
+ if (a == null) a = "localhost:" + sb.getLocalPort();
final boolean intranet = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "").equals("intranet");
final String repository = "http://" + a + "/repository/";
prop.put("starturl", (intranet) ? repository : "http://");
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 601ab2cbf..f5ed41553 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -99,7 +99,7 @@ public class SettingsAck_p {
/*
* display port info
*/
- prop.put("info_port", env.getLocalPort("port", 8090));
+ prop.put("info_port", env.getLocalPort());
prop.put("info_restart", "0");
// read and process data
diff --git a/htroot/Settings_p.java b/htroot/Settings_p.java
index af1a7c0ac..0c03defbb 100644
--- a/htroot/Settings_p.java
+++ b/htroot/Settings_p.java
@@ -73,7 +73,7 @@ public final class Settings_p {
prop.put("settingsTables", "");
}
- prop.put("port", env.getLocalPort("port", 8090));
+ prop.put("port", env.getLocalPort());
prop.putHTML("peerName", sb.peers.mySeed().getName());
prop.putHTML("staticIP", env.getConfig("staticIP", ""));
diff --git a/htroot/Table_API_p.java b/htroot/Table_API_p.java
index 513bb46ae..117cf30b4 100644
--- a/htroot/Table_API_p.java
+++ b/htroot/Table_API_p.java
@@ -208,7 +208,7 @@ public class Table_API_p {
}
// now call the api URLs and store the result status
- final Map<String, Integer> l = sb.tables.execAPICalls(Domains.LOCALHOST, sb.getLocalPort("port", 8090), pks, sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"), sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""));
+ final Map<String, Integer> l = sb.tables.execAPICalls(Domains.LOCALHOST, sb.getLocalPort(), pks, sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"), sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""));
// construct result table
prop.put("showexec", l.isEmpty() ? 0 : 1);
diff --git a/htroot/api/push_p.java b/htroot/api/push_p.java
index 84689af62..912586220 100644
--- a/htroot/api/push_p.java
+++ b/htroot/api/push_p.java
@@ -126,7 +126,7 @@ public class push_p {
Set<String> ips = Domains.myPublicIPs();
String address = ips.size() == 0 ? "127.0.0.1" : ips.iterator().next();
if (address == null) address = "127.0.0.1";
- prop.put("mode_results_" + i + "_success_message", "http://" + address + ":" + sb.getLocalPort("port", 8090) + "/solr/select?q=sku:%22" + u + "%22");
+ prop.put("mode_results_" + i + "_success_message", "http://" + address + ":" + sb.getLocalPort() + "/solr/select?q=sku:%22" + u + "%22");
countsuccess++;
} catch (MalformedURLException e) {
e.printStackTrace();
diff --git a/htroot/opensearchdescription.java b/htroot/opensearchdescription.java
index baa39ad2c..de72ff1c1 100644
--- a/htroot/opensearchdescription.java
+++ b/htroot/opensearchdescription.java
@@ -40,7 +40,7 @@ public class opensearchdescription {
if (env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", "");
String thisaddress = header.get("Host", Domains.LOCALHOST);
- if (thisaddress.indexOf(':',0) == -1) thisaddress += ":" + env.getLocalPort("port", 8090);
+ if (thisaddress.indexOf(':',0) == -1) thisaddress += ":" + env.getLocalPort();
String thisprotocol = env.getConfigBool("server.https", false) ? "https" : "http";
final serverObjects prop = new serverObjects();
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index fee284c8d..0aea12e23 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -149,7 +149,7 @@ public class yacysearch {
// adding some additional properties needed for the rss feed
String hostName = header.get("Host", Domains.LOCALHOST);
if ( hostName.indexOf(':', 0) == -1 ) {
- hostName += ":" + env.getLocalPort("port", 8090);
+ hostName += ":" + env.getLocalPort();
}
prop.put("searchBaseURL", "http://" + hostName + "/yacysearch.html");
prop.put("rssYacyImageURL", "http://" + hostName + "/env/grafics/yacy.png");
@@ -900,7 +900,7 @@ public class yacysearch {
// hostname and port (assume locahost if nothing helps)
final String hostIP = sb.peers.mySeed().getIP();
prop.put("myhost", hostIP != null ? hostIP : Domains.LOCALHOST);
- prop.put("myport", Domains.LOCALHOST.equals(hostIP) ? sb.getLocalPort("port", 8090) : sb.getPublicPort("port", 8090));
+ prop.put("myport", Domains.LOCALHOST.equals(hostIP) ? sb.getLocalPort() : sb.getPublicPort("port", 8090));
// return rewrite properties
return prop;
diff --git a/htroot/yacysearch_location.java b/htroot/yacysearch_location.java
index f4203772f..febe02816 100644
--- a/htroot/yacysearch_location.java
+++ b/htroot/yacysearch_location.java
@@ -96,7 +96,7 @@ public class yacysearch_location {
if (query.length() > 0 && (metatag || search_title || search_publisher || search_creator || search_subject)) try {
// get a queue of search results
- final String rssSearchServiceURL = "http://127.0.0.1:" + sb.getLocalPort("port", 8090) + "/yacysearch.rss";
+ final String rssSearchServiceURL = "http://127.0.0.1:" + sb.getLocalPort() + "/yacysearch.rss";
final BlockingQueue<RSSMessage> results = new LinkedBlockingQueue<RSSMessage>();
SRURSSConnector.searchSRURSS(results, rssSearchServiceURL, lon == 0.0d && lat == 0.0d ? query : query + " /radius/" + lat + "/" + lon + "/" + radius, maximumTime, Integer.MAX_VALUE, null, false, ClientIdentification.yacyInternetCrawlerAgent);
@@ -129,7 +129,7 @@ public class yacysearch_location {
String promoteSearchPageGreeting = env.getConfig(SwitchboardConstants.GREETING, "");
if (env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", "");
String hostName = header.get("Host", Domains.LOCALHOST);
- if (hostName.indexOf(':',0) == -1) hostName += ":" + env.getLocalPort("port", 8090);
+ if (hostName.indexOf(':',0) == -1) hostName += ":" + env.getLocalPort();
final String originalquerystring = (post == null) ? "" : post.get("query", post.get("search", "")).trim(); // SRU compliance
final boolean global = post.get("kml_resource", "local").equals("global");
diff --git a/source/net/yacy/gui/Tray.java b/source/net/yacy/gui/Tray.java
index 8de4d0b6d..9a61251a7 100644
--- a/source/net/yacy/gui/Tray.java
+++ b/source/net/yacy/gui/Tray.java
@@ -239,8 +239,8 @@ public final class Tray {
}
private String readyMessage() {
- if (deutsch) return "YaCy laeuft unter http://localhost:" + sb.getLocalPort("port", 8090);
- return "YaCy is running at http://localhost:" + sb.getLocalPort("port", 8090);
+ if (deutsch) return "YaCy laeuft unter http://localhost:" + sb.getLocalPort();
+ return "YaCy is running at http://localhost:" + sb.getLocalPort();
}
private String shutdownMessage() {
diff --git a/source/net/yacy/http/Jetty9HttpServerImpl.java b/source/net/yacy/http/Jetty9HttpServerImpl.java
index cf4123640..431a41325 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.getLocalPort("port.ssl", 8443);
+ int sslport = sb.getConfigInt("port.ssl", 8443);
sslContextFactory.setSslContext(sslContext);
// SSL HTTP Configuration
@@ -289,8 +289,8 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
}
try { // reconnect with new settings (instead to stop/start server, just manipulate connectors
final Connector[] cons = server.getConnectors();
- final int port = Switchboard.getSwitchboard().getLocalPort("port", 8090);
- final int sslport = Switchboard.getSwitchboard().getLocalPort("port.ssl", 8443);
+ final int port = Switchboard.getSwitchboard().getLocalPort();
+ final int sslport = Switchboard.getSwitchboard().getConfigInt("port.ssl", 8443);
for (Connector con : cons) {
// check http connector
if (con.getName().startsWith("httpd") && ((ServerConnector)con).getPort() != port) {
diff --git a/source/net/yacy/peers/SeedDB.java b/source/net/yacy/peers/SeedDB.java
index 533715e77..f4869638b 100644
--- a/source/net/yacy/peers/SeedDB.java
+++ b/source/net/yacy/peers/SeedDB.java
@@ -959,7 +959,7 @@ public final class SeedDB implements AlternativeDomainNames {
if (this.mySeed == null) initMySeed();
if (seed == this.mySeed && !(seed.isOnline())) {
// take local ip instead of external
- return Switchboard.getSwitchboard().myPublicIP() + ":" + Switchboard.getSwitchboard().getLocalPort("port", 8090) + ((subdom == null) ? "" : ("/" + subdom));
+ return Switchboard.getSwitchboard().myPublicIP() + ":" + Switchboard.getSwitchboard().getLocalPort() + ((subdom == null) ? "" : ("/" + subdom));
}
return seed.getPublicAddress(seed.getIP()) + ((subdom == null) ? "" : ("/" + subdom));
} else {
diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java
index 1ecbffa5e..9597b9438 100644
--- a/source/net/yacy/search/Switchboard.java
+++ b/source/net/yacy/search/Switchboard.java
@@ -304,7 +304,7 @@ public final class Switchboard extends serverSwitch {
super(dataPath, appPath, initPath, configPath);
sb = this;
// check if port is already occupied
- final int port = getLocalPort("port", 8090);
+ final int port = getLocalPort();
if (TimeoutRequest.ping(Domains.LOCALHOST, port, 500)) {
throw new RuntimeException(
"a server is already running on the YaCy port "
@@ -2200,7 +2200,7 @@ public final class Switchboard extends serverSwitch {
startupAction = false;
// execute api calls
- final Map<String, Integer> callResult = this.tables.execAPICalls("localhost", getLocalPort("port", 8090), pks, getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"), getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""));
+ final Map<String, Integer> callResult = this.tables.execAPICalls("localhost", getLocalPort(), pks, getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"), getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""));
for ( final Map.Entry<String, Integer> call : callResult.entrySet() ) {
this.log.info("Scheduler executed api call, response " + call.getValue() + ": " + call.getKey());
}
diff --git a/source/net/yacy/server/serverSwitch.java b/source/net/yacy/server/serverSwitch.java
index a63fb760e..02fe4443e 100644
--- a/source/net/yacy/server/serverSwitch.java
+++ b/source/net/yacy/server/serverSwitch.java
@@ -222,16 +222,14 @@ public class serverSwitch {
* Wrapper for {@link #getConfigInt(String, int)} to have a more consistent
* API.
*
- * @param key
- * original key from config (for example "port" or "port.ssl")
- * @param dflt
- * default value which will be used if no value is found
+ * Default value 8090 will be used if no value is found
+ *
* @return the local port of this system
* @see #getPublicPort(String, int)
*/
- public int getLocalPort(final String key, final int dflt) {
+ public int getLocalPort() {
- return getConfigInt(key, dflt);
+ return getConfigInt("port", 8090);
}
// a logger for this switchboard
diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java
index 4726fde80..4d2edc64f 100644
--- a/source/net/yacy/yacy.java
+++ b/source/net/yacy/yacy.java
@@ -218,7 +218,7 @@ public final class yacy {
sb.setConfig("memoryTotalAfterStartup", startupMemTotal);
// start gui if wanted
- if (gui) YaCyApp.start("localhost", sb.getLocalPort("port", 8090));
+ if (gui) YaCyApp.start("localhost", sb.getLocalPort());
// hardcoded, forced, temporary value-migration
sb.setConfig("htTemplatePath", "htroot/env/templates");
@@ -293,7 +293,7 @@ public final class yacy {
HTTPClient.setDefaultUserAgent(ClientIdentification.yacyInternetCrawlerAgent.userAgent);
// start main threads
- final int port = sb.getLocalPort("port", 8090);
+ final int port = sb.getLocalPort();
try {
// start http server
YaCyHttpServer httpServer;