mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
differentiate api call getLocalPort() from getConfigInt()
This commit is contained in:
parent
02afba730e
commit
a60b1fb6c2
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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://");
|
||||
|
|
|
@ -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://");
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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", ""));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user