add switchboardconstants for server ports config keys

pull/114/head
reger 8 years ago
parent e0c5b28331
commit a2afb4bae0

@ -136,7 +136,7 @@ public class ConfigBasic {
if (!(env.getLocalPort() == port) || env.getConfigBool("server.https", false) != ssl) { if (!(env.getLocalPort() == port) || env.getConfigBool("server.https", false) != ssl) {
// validate port // validate port
final YaCyHttpServer theServerCore = env.getHttpServer(); final YaCyHttpServer theServerCore = env.getHttpServer();
env.setConfig("port", port); env.setConfig(SwitchboardConstants.SERVER_PORT, port);
env.setConfig("server.https", ssl); env.setConfig("server.https", ssl);
// redirect the browser to the new port // redirect the browser to the new port

@ -42,6 +42,7 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.crawler.data.CrawlProfile; import net.yacy.crawler.data.CrawlProfile;
import net.yacy.crawler.retrieval.Request; import net.yacy.crawler.retrieval.Request;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.search.index.Segment; import net.yacy.search.index.Segment;
import net.yacy.server.serverObjects; import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch; import net.yacy.server.serverSwitch;
@ -67,7 +68,7 @@ public class QuickCrawlLink_p {
if (header.containsKey(HeaderFramework.HOST)) { if (header.containsKey(HeaderFramework.HOST)) {
port = header.getServerPort(); port = header.getServerPort();
} else { } else {
port = sb.getConfigInt("port", 8090); port = sb.getConfigInt(SwitchboardConstants.SERVER_PORT, 8090);
} }
prop.put("mode_host", Domains.LOCALHOST); prop.put("mode_host", Domains.LOCALHOST);

@ -200,11 +200,11 @@ public class SettingsAck_p {
if (error == null) { if (error == null) {
serverCore.useStaticIP = true; serverCore.useStaticIP = true;
sb.peers.mySeed().setIP(staticIP); sb.peers.mySeed().setIP(staticIP);
env.setConfig("staticIP", staticIP); env.setConfig(SwitchboardConstants.SERVER_STATICIP, staticIP);
} else { } else {
serverCore.useStaticIP = false; serverCore.useStaticIP = false;
sb.peers.mySeed().setIP(""); sb.peers.mySeed().setIP("");
env.setConfig("staticIP", ""); env.setConfig(SwitchboardConstants.SERVER_STATICIP, "");
} }
// server access data // server access data
@ -538,8 +538,8 @@ public class SettingsAck_p {
prop.put("needsRestart_referer", "Settings_p.html?page=ProxyAccess"); prop.put("needsRestart_referer", "Settings_p.html?page=ProxyAccess");
int port = post.getInt("port.ssl", 8443); int port = post.getInt("port.ssl", 8443);
if (port > 0 && port != env.getConfigInt("port.ssl", 8443)) { if (port > 0 && port != env.getConfigInt(SwitchboardConstants.SERVER_SSLPORT, 8443)) {
env.setConfig("port.ssl", port); env.setConfig(SwitchboardConstants.SERVER_SSLPORT, port);
} }
prop.put("info_port.ssl", port); prop.put("info_port.ssl", port);
prop.put("info", "32"); prop.put("info", "32");

@ -259,10 +259,10 @@ public class snapshot {
SolrDocument sd = sb.index.fulltext().getMetadata(durl.hash()); SolrDocument sd = sb.index.fulltext().getMetadata(durl.hash());
boolean success = false; boolean success = false;
if (sd == null) { 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 { } else {
SolrInputDocument sid = sb.index.fulltext().getDefaultConfiguration().toSolrInputDocument(sd); 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) { if (success) {
pdfSnapshots = Transactions.findPaths(durl, "pdf", Transactions.State.ANY); pdfSnapshots = Transactions.findPaths(durl, "pdf", Transactions.State.ANY);

@ -273,7 +273,7 @@ public final class Tray {
private void openBrowserPage(final String browserPopUpPage) { private void openBrowserPage(final String browserPopUpPage) {
if(!menuEnabled) return; if(!menuEnabled) return;
// no need for https, because we are on localhost // 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() { private PopupMenu getPopupMenu() {

@ -83,7 +83,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
final SSLContext sslContext = initSslContext(sb); final SSLContext sslContext = initSslContext(sb);
if (sslContext != null) { if (sslContext != null) {
int sslport = sb.getConfigInt("port.ssl", 8443); int sslport = sb.getConfigInt(SwitchboardConstants.SERVER_SSLPORT, 8443);
sslContextFactory.setSslContext(sslContext); sslContextFactory.setSslContext(sslContext);
// SSL HTTP Configuration // SSL HTTP Configuration
@ -298,7 +298,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
try { // reconnect with new settings (instead to stop/start server, just manipulate connectors try { // reconnect with new settings (instead to stop/start server, just manipulate connectors
final Connector[] cons = server.getConnectors(); final Connector[] cons = server.getConnectors();
final int port = Switchboard.getSwitchboard().getLocalPort(); 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) { for (Connector con : cons) {
// check http connector // check http connector
if (con.getName().startsWith("httpd") && ((ServerConnector)con).getPort() != port) { if (con.getName().startsWith("httpd") && ((ServerConnector)con).getPort() != port) {

@ -83,7 +83,7 @@ public class migration {
if (sb.getConfigBool("server.https", false)) { if (sb.getConfigBool("server.https", false)) {
int sslport = 8443; int sslport = 8443;
if (fromVer > SSLPORT_CFG) { 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)) { if (TimeoutRequest.ping("127.0.0.1", sslport, 3000)) {
sb.setConfig("server.https", false); sb.setConfig("server.https", false);

@ -99,7 +99,7 @@ public class Network
peernews.addMessage(new RSSMessage("YaCy started", "", "")); peernews.addMessage(new RSSMessage("YaCy started", "", ""));
// ensure that correct IP is used // 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)) { if (staticIP.length() != 0 && Seed.isProperIP(staticIP)) {
serverCore.useStaticIP = true; serverCore.useStaticIP = true;
sb.peers.mySeed().setIP(staticIP); sb.peers.mySeed().setIP(staticIP);
@ -423,7 +423,7 @@ public class Network
if (this.sb.peers.mySeed().isProper(true) == null) return true; if (this.sb.peers.mySeed().isProper(true) == null) return true;
// still no success // still no success
final String ip = this.sb.getConfig("staticIP", ""); final String ip = this.sb.getConfig(SwitchboardConstants.SERVER_STATICIP, "");
if (Seed.isProperIP(ip)) { if (Seed.isProperIP(ip)) {
this.sb.peers.mySeed().setIP(ip); this.sb.peers.mySeed().setIP(ip);

@ -79,6 +79,7 @@ import net.yacy.kelondro.util.MapTools;
import net.yacy.kelondro.util.OS; import net.yacy.kelondro.util.OS;
import net.yacy.peers.operation.yacyVersion; import net.yacy.peers.operation.yacyVersion;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.utils.Bitfield; import net.yacy.utils.Bitfield;
import net.yacy.utils.crypt; import net.yacy.utils.crypt;
@ -1135,7 +1136,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
final Seed newSeed = new Seed(hashs); final Seed newSeed = new Seed(hashs);
// now calculate other information about the host // 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 config
newSeed.dna.put(Seed.NAME, defaultPeerName() ); newSeed.dna.put(Seed.NAME, defaultPeerName() );
newSeed.dna.put(Seed.PORT, Integer.toString(port)); newSeed.dna.put(Seed.PORT, Integer.toString(port));
return newSeed; return newSeed;

@ -2529,12 +2529,12 @@ public final class Switchboard extends serverSwitch {
checkInterruption(); checkInterruption();
// execute the (post-) processing steps for all entries that have a process tag assigned // 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); boolean allCrawlsFinished = this.crawler.allCrawlsFinished(this.crawlQueues);
int proccount = 0; int proccount = 0;
if (!this.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)) { if (!this.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)) {
Fulltext fulltext = index.fulltext();
CollectionConfiguration collection1Configuration = fulltext.getDefaultConfiguration();
boolean process_key_exist = collection1Configuration.contains(CollectionSchema.process_sxt); boolean process_key_exist = collection1Configuration.contains(CollectionSchema.process_sxt);
if (!process_key_exist) log.info("postprocessing deactivated: field process_sxt is not enabled"); 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, searchEvent,
sourceName, sourceName,
getConfigBool(SwitchboardConstants.DHT_ENABLED, false), 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)); this.getConfig("crawler.http.acceptLanguage", null));
final RSSFeed feed = final RSSFeed feed =
EventChannel.channels(queueEntry.initiator() == null EventChannel.channels(queueEntry.initiator() == null
@ -3907,7 +3907,7 @@ public final class Switchboard extends serverSwitch {
private static long indeSizeCache = 0; private static long indeSizeCache = 0;
private static long indexSizeTime = 0; private static long indexSizeTime = 0;
public void updateMySeed() { 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 peer //the speed of indexing (pages/minute) of the peer
final long uptime = (System.currentTimeMillis() - this.startupTime) / 1000; final 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.setFlagAcceptRemoteCrawl(getConfigBool(SwitchboardConstants.CRAWLJOB_REMOTE, false));
mySeed.setFlagAcceptRemoteIndex(getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true)); mySeed.setFlagAcceptRemoteIndex(getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true));
mySeed.setFlagSSLAvailable(this.getHttpServer() != null && this.getHttpServer().withSSL() && getConfigBool("server.https", false)); 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 // set local ips
String staticIP = this.getConfig("staticIP", ""); String staticIP = this.getConfig(SwitchboardConstants.SERVER_STATICIP, "");
if (staticIP.length() > 0) mySeed.setIP(staticIP); if (staticIP.length() > 0) mySeed.setIP(staticIP);
Set<String> publicips = myPublicIPs(); Set<String> publicips = myPublicIPs();
if (!mySeed.clash(publicips)) mySeed.setIPs(publicips); if (!mySeed.clash(publicips)) mySeed.setIPs(publicips);

@ -54,6 +54,11 @@ public final class SwitchboardConstants {
public static final String ADMIN_ACCOUNT_All_PAGES = "adminAccountAllPages"; public static final String ADMIN_ACCOUNT_All_PAGES = "adminAccountAllPages";
public static final String ADMIN_REALM = "adminRealm"; 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 String PUBLIC_SEARCHPAGE = "publicSearchpage";
public static final int CRAWLJOB_SYNC = 0; public static final int CRAWLJOB_SYNC = 0;

@ -32,6 +32,7 @@ import javax.xml.parsers.ParserConfigurationException;
import net.yacy.cora.util.ConcurrentLog; import net.yacy.cora.util.ConcurrentLog;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import org.bitlet.weupnp.GatewayDevice; import org.bitlet.weupnp.GatewayDevice;
import org.bitlet.weupnp.GatewayDiscover; import org.bitlet.weupnp.GatewayDiscover;
@ -53,9 +54,9 @@ public class UPnP {
private static final Map<UPnPMappingType, UPnPMapping> MAPPINGS = new EnumMap<>( private static final Map<UPnPMappingType, UPnPMapping> MAPPINGS = new EnumMap<>(
UPnPMappingType.class); UPnPMappingType.class);
static { static {
MAPPINGS.put(UPnPMappingType.HTTP, new UPnPMapping("port", null, "TCP", MAPPINGS.put(UPnPMappingType.HTTP, new UPnPMapping(SwitchboardConstants.SERVER_PORT, null, "TCP",
"YaCy HTTP")); "YaCy HTTP"));
MAPPINGS.put(UPnPMappingType.HTTPS, new UPnPMapping("port.ssl", MAPPINGS.put(UPnPMappingType.HTTPS, new UPnPMapping(SwitchboardConstants.SERVER_SSLPORT,
"server.https", "TCP", "YaCy HTTPS")); "server.https", "TCP", "YaCy HTTPS"));
} }

@ -559,7 +559,7 @@ public final class yacy {
final Properties config = configuration("COMMAND-STEERING", homePath); final Properties config = configuration("COMMAND-STEERING", homePath);
// read port // read port
final int port = Integer.parseInt(config.getProperty("port", "8090")); final int port = Integer.parseInt(config.getProperty(SwitchboardConstants.SERVER_PORT, "8090"));
// read password // read password
String encodedPassword = (String) config.get(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5); String 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 browser // prevents also creation of a log file while just opening browser
System.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"); System.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)) { if (TimeoutRequest.ping("127.0.0.1", port, 1000)) {
Browser.openBrowser("http://localhost:" + port + "/" + p.getProperty(SwitchboardConstants.BROWSER_POP_UP_PAGE, "index.html")); 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. // Thats it; YaCy was running, the user is happy, we can stop now.

Loading…
Cancel
Save