Permalink
Browse files

add switchboardconstants for server ports config keys

  • Loading branch information...
reger24 committed Mar 18, 2017
1 parent e0c5b28 commit a2afb4bae0d977162a306633db61bb067806fe5b
@@ -136,7 +136,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
if (!(env.getLocalPort() == port) || env.getConfigBool("server.https", false) != ssl) {
// validate port
final 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 port
@@ -42,6 +42,7 @@
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 static serverObjects respond(final RequestHeader header, final serverObje
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);
@@ -200,11 +200,11 @@ else if (!filter.equals("*")){
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 @@ else if (!filter.equals("*")){
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");
@@ -259,10 +259,10 @@ public static Object respond(final RequestHeader header, serverObjects post, fin
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);
@@ -273,7 +273,7 @@ private void doubleClickAction() {
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() {
@@ -83,7 +83,7 @@ public Jetty9HttpServerImpl(int port) {
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 void run() {
try { // reconnect with new settings (instead to stop/start server, just manipulate connectors
final 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 connector
if (con.getName().startsWith("httpd") && ((ServerConnector)con).getPort() != port) {
@@ -83,7 +83,7 @@ public static void migrate(final Switchboard sb, final double fromVer, final dou
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);
@@ -99,7 +99,7 @@ public Network(final Switchboard sb) {
peernews.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 @@ private boolean publishMySeed() {
if (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);
@@ -79,6 +79,7 @@
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 static Seed genLocalSeed(final SeedDB db) {
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 config
newSeed.dna.put(Seed.NAME, defaultPeerName() );
newSeed.dna.put(Seed.PORT, Integer.toString(port));
return newSeed;
@@ -2529,12 +2529,12 @@ public boolean cleanupJob() {
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 @@ private void storeDocumentIndex(
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 float averageQPMPublicLocal() {
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 peer
final long uptime = (System.currentTimeMillis() - this.startupTime) / 1000;
@@ -3935,10 +3935,10 @@ public void updateMySeed() {
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);
@@ -43,7 +43,7 @@
* 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 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;
@@ -32,6 +32,7 @@
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 @@
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"));
}
@@ -559,7 +559,7 @@ private static void submitURL(final File homePath, final String path, final Stri
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 password
String encodedPassword = (String) config.get(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5);
@@ -634,7 +634,7 @@ static private void preReadSavedConfigandInit(File dataHome) {
// 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");
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.

0 comments on commit a2afb4b

Please sign in to comment.