mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
*) Automatic redirection of browser if user changes port settings in ConfigBasic
See: http://www.yacy-forum.de/viewtopic.php?t=2415 *) If ssl is available, the browser conntects to yacy via https on yacy startup See: http://www.yacy-forum.de/viewtopic.php?p=21649#21649 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2127 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
955462d6b8
commit
8b7626f8d1
|
@ -11,6 +11,8 @@ document.getElementById("value").value=element.value;
|
|||
}
|
||||
-->
|
||||
</script>
|
||||
<!-- redirecting browser if port was changed -->
|
||||
#(reconnect)#::<meta http-equiv="refresh" content="10; URL=#(sslSupport)#http::https#(/sslSupport)#://#[host]#:#[port]#/ConfigBasic.html">#(/reconnect)#
|
||||
</head>
|
||||
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
|
||||
#%env/templates/header.template%#
|
||||
|
@ -39,7 +41,7 @@ Your YaCy Peer needs some basic information to operate properly
|
|||
</form>
|
||||
|
||||
<p><b>What you should do next:</b><br>
|
||||
#(nextStep)#
|
||||
#(nextStep)#<!-- [0] -->
|
||||
Your basic configuration is complete! You can now (for example):
|
||||
<ul>
|
||||
<li><a href="index.html">start an uncensored search</a>;</li>
|
||||
|
@ -47,9 +49,14 @@ Your basic configuration is complete! You can now (for example):
|
|||
<li><a href="ConfigProfile_p.html">set a personal peer profile</a> (optional settings);</li>
|
||||
<li>just <a href="Network.html">monitor at the network page</a> what the other peers are doing</li>
|
||||
</ul>::
|
||||
<!-- [1]: password not proper -->
|
||||
You did not set a user name and/or a password. Some pages are protected by passwords. You should set a password here to secure your YaCy peer.::
|
||||
<!-- [2]: peername not proper -->
|
||||
Your Peer name is a default name; please set another peer name. If this does not work, the name is probably taken by someone else. Please try to choose another one.::
|
||||
You did not open a port in your firewall or your router does not forward the server port to your peer. This is needed if you want to fully participate in the YaCy network. You can also use your peer without opening it, but this is not recomended.
|
||||
<!-- [3]: port not proper -->
|
||||
You did not open a port in your firewall or your router does not forward the server port to your peer. This is needed if you want to fully participate in the YaCy network. You can also use your peer without opening it, but this is not recomended.::
|
||||
<!-- [4]: reconnect to different port -->
|
||||
The peer port was changed successfully. Your browser will be redirected to the new <a href="#(sslSupport)#http::https#(/sslSupport)#://#[host]#:#[port]#/ConfigBasic.html">location</a> in 10 seconds.
|
||||
#(/nextStep)#
|
||||
#%env/templates/footer.template%#
|
||||
</body>
|
||||
|
|
|
@ -62,6 +62,12 @@ import de.anomic.yacy.yacyCore;
|
|||
import de.anomic.yacy.yacySeed;
|
||||
|
||||
public class ConfigBasic {
|
||||
private static final int NEXTSTEP_FINISHED = 0;
|
||||
private static final int NEXTSTEP_PWD = 1;
|
||||
private static final int NEXTSTEP_PEERNAME = 2;
|
||||
private static final int NEXTSTEP_PEERPORT = 3;
|
||||
private static final int NEXTSTEP_RECONNECT = 4;
|
||||
|
||||
|
||||
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
|
||||
// return variable that accumulates replacements
|
||||
|
@ -121,11 +127,26 @@ public class ConfigBasic {
|
|||
}
|
||||
|
||||
// check port
|
||||
boolean reconnect = false;
|
||||
if (!env.getConfig("port", port).equals(port)) {
|
||||
// validate port
|
||||
serverCore theServerCore = (serverCore) env.getThread("10_httpd");
|
||||
env.setConfig("port", port);
|
||||
theServerCore.reconnect();
|
||||
|
||||
// redirect the browser to the new port
|
||||
reconnect = true;
|
||||
prop.put("reconnect", 1);
|
||||
prop.put("reconnect_host", serverCore.publicLocalIP().getHostAddress());
|
||||
prop.put("nextStep_host", serverCore.publicLocalIP().getHostAddress());
|
||||
prop.put("reconnect_port", port);
|
||||
prop.put("nextStep_port", port);
|
||||
prop.put("reconnect_sslSupport", theServerCore.withSSL() ? 1:0);
|
||||
prop.put("nextStep_sslSupport", theServerCore.withSSL() ? 1:0);
|
||||
|
||||
// force reconnection in 7 seconds
|
||||
theServerCore.reconnect(7000);
|
||||
} else {
|
||||
prop.put("reconnect", 0);
|
||||
}
|
||||
|
||||
// check if values are proper
|
||||
|
@ -140,18 +161,16 @@ public class ConfigBasic {
|
|||
prop.put("statusName", (properName) ? 1 : 0);
|
||||
prop.put("statusPassword", (properPW) ? 1 : 0);
|
||||
prop.put("statusPort", (properPort) ? 1 : 0);
|
||||
if (properPW) {
|
||||
if (properName) {
|
||||
if (properPort) {
|
||||
prop.put("nextStep", 0);
|
||||
if (reconnect) {
|
||||
prop.put("nextStep", NEXTSTEP_RECONNECT);
|
||||
} else if (!properPW) {
|
||||
prop.put("nextStep", NEXTSTEP_PWD);
|
||||
} else if (!properName) {
|
||||
prop.put("nextStep", NEXTSTEP_PEERNAME);
|
||||
} else if (!properPort) {
|
||||
prop.put("nextStep", NEXTSTEP_PEERPORT);
|
||||
} else {
|
||||
prop.put("nextStep", 3);
|
||||
}
|
||||
} else {
|
||||
prop.put("nextStep", 2);
|
||||
}
|
||||
} else {
|
||||
prop.put("nextStep", 1);
|
||||
prop.put("nextStep", NEXTSTEP_FINISHED);
|
||||
}
|
||||
|
||||
// set default values
|
||||
|
|
|
@ -64,6 +64,8 @@ import java.net.URL;
|
|||
import java.net.UnknownHostException;
|
||||
import java.nio.channels.ClosedByInterruptException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.PublicKey;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
|
@ -71,6 +73,7 @@ import javax.net.ssl.HandshakeCompletedEvent;
|
|||
import javax.net.ssl.HandshakeCompletedListener;
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
|
@ -203,6 +206,10 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
init();
|
||||
}
|
||||
|
||||
public boolean withSSL() {
|
||||
return this.sslSocketFactory != null;
|
||||
}
|
||||
|
||||
public synchronized void init() {
|
||||
this.log.logInfo("Initializing serverCore ...");
|
||||
|
||||
|
@ -1291,8 +1298,10 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
if (currentThread.isInterrupted()) throw new InterruptedException();
|
||||
if ((currentThread instanceof serverCore.Session) && ((serverCore.Session)currentThread).isStopped()) throw new InterruptedException();
|
||||
}
|
||||
|
||||
public void reconnect() {
|
||||
this.reconnect(5000);
|
||||
}
|
||||
public void reconnect(int delay) {
|
||||
Thread restart = new Restarter();
|
||||
restart.start();
|
||||
}
|
||||
|
@ -1300,10 +1309,11 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
// restarting the serverCore
|
||||
public class Restarter extends Thread {
|
||||
public serverCore theServerCore = null;
|
||||
public int delay = 5000;
|
||||
public void run() {
|
||||
// waiting for a while
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
Thread.sleep(delay);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -384,7 +384,7 @@ public final class yacy {
|
|||
boolean properPW = (sb.getConfig("adminAccount", "").length() == 0) && (sb.getConfig("adminAccountBase64MD5", "").length() > 0);
|
||||
if (!properPW) browserPopUpPage = "ConfigBasic.html";
|
||||
final String browserPopUpApplication = sb.getConfig("browserPopUpApplication", "netscape");
|
||||
serverSystem.openBrowser("http://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage, browserPopUpApplication);
|
||||
serverSystem.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage, browserPopUpApplication);
|
||||
}
|
||||
|
||||
//Copy the shipped locales into DATA
|
||||
|
@ -460,7 +460,7 @@ public final class yacy {
|
|||
server.terminate(false);
|
||||
server.interrupt();
|
||||
if (server.isAlive()) try {
|
||||
URL u = new URL("http://localhost:" + serverCore.getPortNr(port));
|
||||
URL u = new URL((server.withSSL()?"https":"http")+"://localhost:" + serverCore.getPortNr(port));
|
||||
httpc.wget(u, u.getHost(), 1000, null, null, null); // kick server
|
||||
serverLog.logConfig("SHUTDOWN", "sent termination signal to server socket");
|
||||
} catch (IOException ee) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user