mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
*) Bugfix for SSL/NIO Bug
See: http://www.yacy-forum.de/viewtopic.php?t=516 - removing NIO from server/serverCore.java because of massive problems with socket close issues *) Adding support for remote port forwarding via sch @Orbiter: Please take a look into - hello.java - server/serverCore.java.publicIP() - yacy/yacyClient.java.publishMySeed(...) *) Making startup loading of additional content parsers more failsafe git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@281 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
a1ffc27041
commit
9a98988c3c
49
build.xml
49
build.xml
|
@ -128,7 +128,7 @@
|
|||
|
||||
<!-- compiling the main sources -->
|
||||
<javac srcdir="${src}/" destdir="${build}"
|
||||
excludes="de/anomic/plasma/parser/*/*,de/anomic/yacy/seedUpload/**,de/anomic/soap/**,yacy.java"
|
||||
excludes="de/anomic/plasma/parser/*/*,de/anomic/yacy/seedUpload/**,de/anomic/soap/**,yacy.java,de/anomic/server/serverPortForwardingSch.java"
|
||||
debug="true" debuglevel="lines,vars,source"
|
||||
source="${javacSource}" target="${javacTarget}">
|
||||
<classpath refid="project.class.path"/>
|
||||
|
@ -142,7 +142,7 @@
|
|||
<include name="de/anomic/yacy/seedUpload/yacySeedUploadFile.java" />
|
||||
<include name="de/anomic/yacy/seedUpload/yacySeedUploadFtp.java"/>
|
||||
</javac>
|
||||
|
||||
|
||||
<!-- compiling htroot, htroot/yacy and htroot/htdocsdefault -->
|
||||
<javac srcdir="${htroot}/"
|
||||
classpathref="project.class.path"
|
||||
|
@ -199,8 +199,33 @@
|
|||
<fileset dir="${src}/" includes="de/anomic/soap/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
|
||||
|
||||
<target name="portForwarding" depends="compile" description="Compiling and zipping additional port forwarder">
|
||||
<javac srcdir="${src}/de/anomic/server/" destdir="${build}" source="${javacSource}" target="${javacTarget}" debug="true" debuglevel="lines,vars,source">
|
||||
<include name="serverPortForwardingSch.java"/>
|
||||
<classpath>
|
||||
<pathelement location="${build}" />
|
||||
|
||||
<!-- main lib needed to parse rss/atom feed files -->
|
||||
<pathelement location="${libx}/jsch-0.1.19.jar" />
|
||||
</classpath>
|
||||
</javac>
|
||||
<copy todir="${release}/libx/">
|
||||
<fileset dir="${libx}" includes="jsch-0.1.19.*"/>
|
||||
</copy>
|
||||
<copy todir="${release}/source/de/anomic/server/">
|
||||
<fileset dir="${src}/de/anomic/server/">
|
||||
<include name="serverPortForwardingSch.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${release}/classes/de/anomic/server/">
|
||||
<fileset dir="${build}/de/anomic/server/">
|
||||
<include name="serverPortForwardingSch.class"/>
|
||||
<include name="serverPortForwardingSch$MyUserInfo.class"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="singleExtensionFile" if="singleExtFile">
|
||||
<tar destfile="${release}/${extensionFile}" compression="gzip" defaultexcludes="yes" longfile="gnu">
|
||||
<tarfileset dir="${release}" prefix="${releaseDir}/" dirmode="${accessRightsDir}" mode="${accessRightsFile}" >
|
||||
|
@ -216,21 +241,27 @@
|
|||
</target>
|
||||
|
||||
<!-- making a release file for yacy -->
|
||||
<target name="dist" depends="all,parsers,seedUploaders,yacySOAP,singleExtensionFile" description="Compiling sources and make a release file ...">
|
||||
<target name="dist" depends="all,parsers,seedUploaders,yacySOAP,portForwarding,singleExtensionFile" description="Compiling sources and make a release file ...">
|
||||
|
||||
<tar destfile="${release}/${releaseFile}" compression="gzip" defaultexcludes="yes" longfile="gnu">
|
||||
|
||||
<!-- copy class files -->
|
||||
<tarfileset dir="${build}" prefix="${releaseDir}/classes" dirmode="${accessRightsDir}" mode="${accessRightsFile}" >
|
||||
<include name="**/*.*"/>
|
||||
<!-- excluding all additional content parsers -->
|
||||
<exclude name="de/anomic/plasma/parser/*/*"/>
|
||||
<!-- excluding all additional seed uploaders -->
|
||||
<exclude name="de/anomic/yacy/seedUpload/**"/>
|
||||
<!-- excluding the soap handler -->
|
||||
<exclude name="de/anomic/soap/**"/>
|
||||
<!-- excluding the port forwarder -->
|
||||
<exclude name="de/anomic/server/serverPortForwardingSch.class"/>
|
||||
<exclude name="de/anomic/server/serverPortForwardingSch$MyUserInfo.class"/>
|
||||
</tarfileset>
|
||||
<tarfileset dir="${build}" prefix="${releaseDir}/classes" dirmode="${accessRightsDir}" mode="${accessRightsFile}" >
|
||||
<include name="de/anomic/yacy/seedUpload/yacySeedUploadFile.class"/>
|
||||
<include name="de/anomic/yacy/seedUpload/yacySeedUploadFtp.class"/>
|
||||
</tarfileset>
|
||||
<tarfileset dir="${build}" prefix="${releaseDir}/classes" dirmode="${accessRightsDir}" mode="${accessRightsFile}" >
|
||||
<include name="de/anomic/yacy/seedUpload/yacySeedUploadFile.class"/>
|
||||
<include name="de/anomic/yacy/seedUpload/yacySeedUploadFtp.class"/>
|
||||
</tarfileset>
|
||||
|
||||
<!-- copy libs -->
|
||||
<tarfileset dir="${lib}" includes="**/*" prefix="${releaseDir}/lib" dirmode="${accessRightsDir}" mode="${accessRightsFile}"/>
|
||||
|
|
|
@ -10,67 +10,69 @@
|
|||
<h2>Settings Receipt:</h2>
|
||||
|
||||
<p>
|
||||
#(info)#
|
||||
#(info)#<!-- 0 -->
|
||||
<b>No information has been submitted</b><br>
|
||||
Nothing changed
|
||||
::
|
||||
::<!-- 1 -->
|
||||
<b>Error with submitted information.</b><br>
|
||||
Nothing changed.
|
||||
::
|
||||
::<!-- 2 -->
|
||||
<b>The user name must be given.</b><br>
|
||||
Your request cannot be processed.<br>Nothing changed.
|
||||
::
|
||||
::<!-- 3 -->
|
||||
<b>The password redundancy check failed. You have probably misstyped your password.</b><br>
|
||||
Your request cannot be processed.<br>Nothing changed.
|
||||
::
|
||||
::<!-- 4 -->
|
||||
<b>Shutting down.</b><br>Application will terminate after working off all crawling tasks.
|
||||
::
|
||||
::<!-- 5 -->
|
||||
<b>Your administration account setting has been made.</b><br>
|
||||
Your new administration account name is #[user]#. The password has been accepted.<br>If you go back to the Settings page, you must log-in again.
|
||||
::
|
||||
::<!-- 6 -->
|
||||
<b>Your proxy access setting has been changed.<br>
|
||||
Your proxy account check has been disabled, since you did not supply a password.</b><br>
|
||||
The new proxy IP filter is set to #[filter]#<p>
|
||||
Your proxy account check has been disabled, since you did not supply a password.</b><p>
|
||||
The new proxy IP filter is set to #[filter]#<br>
|
||||
The proxy port is: <font color="#556699">#[port]#</font><br>
|
||||
<u>if you changed the Port, you need to restart YaCy.</u>
|
||||
::
|
||||
Port Forwarding is: <font color="#556699">#[portForwardingEnabled]#</font><p>
|
||||
<u>if you changed the Port or Port Forwarding Settings, you need to restart YaCy.</u>
|
||||
::<!-- 7 -->
|
||||
<b>Your proxy access setting has been changed.</b><br>
|
||||
Your new proxy account name is #[user]#. The password has been accepted.<br>
|
||||
If you open any public web page through the proxy, you must log-in then.<br>
|
||||
The new proxy IP filter is set to #[filter]#.<p>
|
||||
If you open any public web page through the proxy, you must log-in then.<p>
|
||||
The new proxy IP filter is set to #[filter]#.<br>
|
||||
The proxy port is: <font color="#556699">#[port]#</font><br>
|
||||
<u>if you changed the Port, you need to restart YaCy.</u>
|
||||
::
|
||||
Port Forwarding is: <font color="#556699">#[portForwardingEnabled]#</font><p>
|
||||
<u>if you changed the Port or Port Forwarding Settings, you need to restart YaCy.</u>
|
||||
::<!-- 8 -->
|
||||
<b>Your server access filter is now set to #[filter]#</b><br>
|
||||
<!--Your new server account name is #[user]#. The password has been accepted.<br>
|
||||
If you go back to the Settings page, you must log-in again.-->
|
||||
::
|
||||
::<!-- 9 -->
|
||||
Auto pop-up of the Status page is now <b>disabled</b><br>
|
||||
::
|
||||
::<!-- 10 -->
|
||||
Auto pop-up of the Status page is now <b>enabled</b><br>
|
||||
::
|
||||
::<!-- 11 -->
|
||||
You are now permanently <b>online</b>. After a short while you should see the effect on the <a href="Status.html">status</a> page.<br>
|
||||
::
|
||||
::<!-- 12 -->
|
||||
<b>The Peer Name is: <font color="#556699">#[peerName]#</font><br>
|
||||
<!--Your Peer Language is: <font color="#556699">#[peerLang]#</font><br>-->
|
||||
::
|
||||
::<!-- 13 -->
|
||||
<b>Seed Settings changed.#(success)#::You are now a principal peer.#(/success)#<br>
|
||||
::
|
||||
::<!-- 14 -->
|
||||
<p><b>Seed Settings changed, but something is wrong.</b></p>
|
||||
<p><font color="red">#[errormsg]#</font></p>
|
||||
Seed Uploading was deactivated automatically.
|
||||
Please return to the settings page and modify the data.<br>
|
||||
::
|
||||
::<!-- 15 -->
|
||||
<b>The remote-proxy setting has been changed</b><br>
|
||||
The new setting is effective immediately, you don't need to re-start.
|
||||
::
|
||||
::<!-- 16 -->
|
||||
<b>The submitted peer name is already used by another peer. Please choose a different name.</b> The Peer name has not been changed.<br>
|
||||
Your Peer Language is: <font color="#556699">#[peerLang]#</font><br>
|
||||
::
|
||||
::<!-- 17 -->
|
||||
<b>The submitted peer name is not well-formed. Please choose a different name.</b> The Peer name has not been changed.<br>
|
||||
Peer names must not contain characters other than (a-z, A-Z, 0-9, '-', '_') and must not be longer than 80 characters.
|
||||
Your Peer Language is: <font color="#556699">#[peerLang]#</font><br>
|
||||
::
|
||||
::<!-- 18 -->
|
||||
The new parser settings where changed successfully.<br>
|
||||
Parsing of the following mime-types was enabled:<br>
|
||||
<ul>
|
||||
|
|
|
@ -130,6 +130,14 @@ public class SettingsAck_p {
|
|||
String port = (String) post.get("port");
|
||||
env.setConfig("port", port);
|
||||
prop.put("info_port", port);
|
||||
|
||||
// port forwarding configuration
|
||||
env.setConfig("portForwardingEnabled", post.containsKey("portForwardingEnabled")?"true":"false");
|
||||
env.setConfig("portForwardingHost", (String)post.get("portForwardingHost"));
|
||||
env.setConfig("portForwardingPort", (String)post.get("portForwardingPort"));
|
||||
env.setConfig("portForwardingUser", (String)post.get("portForwardingUser"));
|
||||
env.setConfig("portForwardingPwd", (String)post.get("portForwardingPwd"));
|
||||
prop.put("info_portForwardingEnabled",post.containsKey("portForwardingEnabled")?"on":"off");
|
||||
|
||||
// read and process data
|
||||
String filter = (String) post.get("proxyfilter");
|
||||
|
|
|
@ -61,6 +61,7 @@ delete the file 'DATA/SETTINGS/httpProxy.conf' in the YaCy application root fold
|
|||
|
||||
<p><form action="SettingsAck_p.html" method="post" enctype="multipart/form-data">
|
||||
<fieldset><legend>Proxy Access Settings</legend>
|
||||
<br><b>Proxy Port Configuration</b><br><br>
|
||||
<table border="0" cellspacing="5">
|
||||
<tr valign="top">
|
||||
<td>Proxy and Administration Port:</td>
|
||||
|
@ -69,7 +70,38 @@ delete the file 'DATA/SETTINGS/httpProxy.conf' in the YaCy application root fold
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<p>You can restrict the access to this proxy using a two-stage security barrier:
|
||||
|
||||
<p><b>Proxy Port Forwarding</b><br><br>
|
||||
<table border="0" cellspacing="5">
|
||||
<tr valign="top">
|
||||
<td>Enable port forwarding:</td>
|
||||
<td><input type="checkbox" name="portForwardingEnabled" align="top" #(portForwardingEnabled)#::checked#(/portForwardingEnabled)#></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Forwarding host:</td>
|
||||
<td><input name="portForwardingHost" type="text" size="32" maxlength="128" value="#[portForwardingHost]#"></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Forwarding port:</td>
|
||||
<td><input name="portForwardingPort" type="text" size="5" maxlength="5" value="#[portForwardingPort]#"></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Remote host user:</td>
|
||||
<td><input name="portForwardingUser" type="text" size="32" maxlength="128" value="#[portForwardingUser]#"></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>Remote host password:</td>
|
||||
<td><input name="portForwardingPwd" type="password" size="32" maxlength="128" value="#[portForwardingPwd]#"></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<p><b>Proxy Access Restrictions</b><br><br>You can restrict the access to this proxy using a two-stage security barrier:
|
||||
<ul>
|
||||
<li>define an <i>access domain</i> with a list of granted client IP-numbers or with wildcards</li>
|
||||
<li>define an <i>user account</i> with an user:password - pair</li>
|
||||
|
|
|
@ -52,13 +52,14 @@ import java.util.List;
|
|||
|
||||
import de.anomic.http.httpHeader;
|
||||
import de.anomic.plasma.plasmaSwitchboard;
|
||||
import de.anomic.server.serverCore;
|
||||
import de.anomic.server.serverObjects;
|
||||
import de.anomic.server.serverSwitch;
|
||||
import de.anomic.yacy.yacyCore;
|
||||
import de.anomic.yacy.yacySeedUploader;
|
||||
|
||||
public final class Settings_p {
|
||||
|
||||
|
||||
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
|
||||
// return variable that accumulates replacements
|
||||
serverObjects prop = new serverObjects();
|
||||
|
@ -68,14 +69,21 @@ public final class Settings_p {
|
|||
prop.put("port", env.getConfig("port", "8080"));
|
||||
|
||||
prop.put("peerName", env.getConfig("peerName", "nameless"));
|
||||
String peerLang = env.getConfig("htLocaleSelection", "default");
|
||||
if (peerLang.equals("default")) peerLang = "en";
|
||||
String peerLang = env.getConfig("htLocaleSelection", "default");
|
||||
if (peerLang.equals("default")) peerLang = "en";
|
||||
prop.put("peerLang", peerLang);
|
||||
|
||||
// http networking settings
|
||||
prop.put("isTransparentProxy", env.getConfig("isTransparentProxy", "false").equals("true") ? 1 : 0);
|
||||
prop.put("connectionKeepAliveSupport", env.getConfig("connectionKeepAliveSupport", "false").equals("true") ? 1 : 0);
|
||||
|
||||
// remote port forwarding settings
|
||||
prop.put("portForwardingEnabled",env.getConfig("portForwardingEnabled","false").equals("true")? 1 : 0);
|
||||
prop.put("portForwardingHost",env.getConfig("portForwardingHost", ""));
|
||||
prop.put("portForwardingPort",env.getConfig("portForwardingPort", ""));
|
||||
prop.put("portForwardingUser",env.getConfig("portForwardingUser", ""));
|
||||
prop.put("portForwardingPwd",env.getConfig("portForwardingPwd", ""));
|
||||
|
||||
// set values
|
||||
String s;
|
||||
int pos;
|
||||
|
@ -146,8 +154,8 @@ public final class Settings_p {
|
|||
// for backward compatiblity ....
|
||||
if ((enabledUploader.equalsIgnoreCase("Ftp")) ||
|
||||
((enabledUploader.equals("")) &&
|
||||
(env.getConfig("seedFTPPassword","").length() > 0) &&
|
||||
(env.getConfig("seedFilePath", "").length() > 0))) {
|
||||
(env.getConfig("seedFTPPassword","").length() > 0) &&
|
||||
(env.getConfig("seedFilePath", "").length() > 0))) {
|
||||
enabledUploader = "Ftp";
|
||||
env.setConfig("seedUploadMethod",enabledUploader);
|
||||
}
|
||||
|
@ -218,5 +226,5 @@ public final class Settings_p {
|
|||
// return rewrite properties
|
||||
return prop;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -37,8 +37,9 @@ Your settings are protected by a password.
|
|||
#[version]##(versioncomment)#:: - the latest public version is #[latestVersion]#. Click here to <a href="http://www.yacy.net/yacy/Download.html">download</a> it.#(/versioncomment)#
|
||||
</td></tr>
|
||||
<tr class="TableCellDark"><td>Proxy host</td><td>#[host]#:#[port]#</td></tr>
|
||||
<tr class="TableCellLight"><td>Remote proxy</td><td>#(remoteProxy)#not used::#[host]#:#[port]##(/remoteProxy)#</td></tr>
|
||||
<tr class="TableCellDark"><td>This peer's address</td><td>
|
||||
<tr class="TableCellLight"><td>Port forwarding host</td><td>#(portForwarding)#not used::#[host]#:#[port]##(/portForwarding)#</td></tr>
|
||||
<tr class="TableCellDark"><td>Remote proxy</td><td>#(remoteProxy)#not used::#[host]#:#[port]##(/remoteProxy)#</td></tr>
|
||||
<tr class="TableCellLight"><td>This peer's address</td><td>
|
||||
#(peerAddress)#
|
||||
Not assigned
|
||||
::
|
||||
|
@ -51,8 +52,8 @@ see the <a href="http://www.yacy.net/yacy/Installation.html#wininst">installatio
|
|||
#[address]# ; Your '.yacy' home at http://www.#[peername]#.yacy
|
||||
#(/peerAddress)#
|
||||
</td></tr>
|
||||
<tr class="TableCellLight"><td>This peer's name</td><td>#[peerName]#/#[hash]#</td></tr>
|
||||
<tr class="TableCellDark"><td>This peer's statistics</td><td>
|
||||
<tr class="TableCellDark"><td>This peer's name</td><td>#[peerName]#/#[hash]#</td></tr>
|
||||
<tr class="TableCellLight"><td>This peer's statistics</td><td>
|
||||
#(peerStatistics)#
|
||||
Unknown
|
||||
::
|
||||
|
@ -60,7 +61,7 @@ Uptime = #[uptime]#, Links# = #[links]#, RWIs# = #[words]#,
|
|||
Connects(#[juniorConnects]#|#[seniorConnects]#|#[principalConnects]#|#[disconnects]#) #[connects]# peers/hour
|
||||
#(/peerStatistics)#
|
||||
</td></tr>
|
||||
<tr class="TableCellLight"><td>This peer's status</td><td>
|
||||
<tr class="TableCellDark"><td>This peer's status</td><td>
|
||||
#(peerStatus)#
|
||||
Virgin - You have not yet published your peer, because you have not yet used the proxy. If you configured your proxy setting (see online: <a href="http://www.yacy.net/yacy/Installation.html#wininst">configure your browser's proxy settings</a> and go online by browsing the internet) you must first load any page through the proxy to prove that this works. With this status you are not allowed to search other peers.
|
||||
::
|
||||
|
@ -71,15 +72,15 @@ Senior - You are running a server and you support the global internet index, whi
|
|||
Principal - You are senior and you publish your seed-list to a ftp account which can be retrieved at #[seedURL]#. You can of course <a href="index.html">search the internet</a> using the other peers' global index on your own search page.
|
||||
#(/peerStatus)#
|
||||
</td></tr>
|
||||
<tr class="TableCellDark"><td>Other peers</td><td>#(otherPeers)#not online.::#[num]# other peers online.#(/otherPeers)#</td></tr>
|
||||
<tr class="TableCellLight"><td>Seed server</td><td>
|
||||
<tr class="TableCellLight"><td>Other peers</td><td>#(otherPeers)#not online.::#[num]# other peers online.#(/otherPeers)#</td></tr>
|
||||
<tr class="TableCellDark"><td>Seed server</td><td>
|
||||
#(seedServer)#
|
||||
Disabled. To enable this you need a ftp account where you can upload files to a web space. If you do that, you become a YaCy root server. You can configure your account details on the <a href="Settings_p.html">Settings page</a>.
|
||||
::
|
||||
Enabled: Updating periodically to server #[seedFTPServer]#
|
||||
#(/seedServer)#
|
||||
</td></tr>
|
||||
<tr class="TableCellDark"><td>Auto-popup on start-up</td><td>
|
||||
<tr class="TableCellLight"><td>Auto-popup on start-up</td><td>
|
||||
#(popup)#
|
||||
Disabled. To enable this again please use the <a href="Settings_p.html">Settings</a> page
|
||||
::
|
||||
|
@ -88,7 +89,7 @@ Enabled <input type="submit" name="dispop" value="Disable pop-up">
|
|||
</form>
|
||||
#(/popup)#
|
||||
</td></tr>
|
||||
<tr class="TableCellLight"><td>Online-mode</td><td>
|
||||
<tr class="TableCellDark"><td>Online-mode</td><td>
|
||||
#(omode)#
|
||||
<!-- online Mode 0 -->
|
||||
::
|
||||
|
@ -106,13 +107,13 @@ Attention: If you don't have a flatrate or are always-on,
|
|||
you must switch off the proxy to go off-line.
|
||||
#(/omode)#
|
||||
</td></tr>
|
||||
<tr class="TableCellDark"><td>Memory Usage</td><td>
|
||||
<tr class="TableCellLight"><td>Memory Usage</td><td>
|
||||
<form action="Status.html" method="get">free: #[freeMemory]# | total: #[totalMemory]# | max: #[maxMemory]# | <input type="submit" name="gc" value="do Garbage-Collect now"></form>
|
||||
</td></tr>
|
||||
<tr class="TableCellLight"><td>Traffic</td><td>
|
||||
<tr class="TableCellDark"><td>Traffic</td><td>
|
||||
In: #[trafficIn]# | Out: #[trafficOut]#
|
||||
</td></tr>
|
||||
<tr class="TableCellDark"><td>System Resources</td><td>
|
||||
<tr class="TableCellLight"><td>System Resources</td><td>
|
||||
processors: #[processors]#
|
||||
</td></tr>
|
||||
|
||||
|
|
|
@ -83,8 +83,18 @@ public class Status {
|
|||
prop.put("versioncomment", 1);//new version
|
||||
prop.put("versioncomment_latestVersion", yacyCore.latestVersion);
|
||||
|
||||
prop.put("host", serverCore.publicIP());
|
||||
prop.put("port", env.getConfig("port", "<unknown>"));
|
||||
prop.put("host", serverCore.publicLocalIP());
|
||||
prop.put("port", env.getConfig("port", "<unknown>"));
|
||||
|
||||
// port forwarding: hostname and port
|
||||
if ((serverCore.portForwardingEnabled) && (serverCore.portForwarding != null)) {
|
||||
prop.put("portForwarding", 1);
|
||||
prop.put("portForwarding_host", serverCore.portForwarding.getHost());
|
||||
prop.put("portForwarding_port", Integer.toString(serverCore.portForwarding.getPort()));
|
||||
} else {
|
||||
prop.put("portForwarding", 0);
|
||||
}
|
||||
|
||||
if (env.getConfig("remoteProxyUse", "false").equals("true")) {
|
||||
prop.put("remoteProxy", 1);
|
||||
prop.put("remoteProxy_host", env.getConfig("remoteProxyHost", "<unknown>"));
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
// hello.java
|
||||
// -----------------------
|
||||
// part of the AnomicHTTPD caching proxy
|
||||
// (C) by Michael Peter Christen; mc@anomic.de
|
||||
// first published on http://www.anomic.de
|
||||
// Frankfurt, Germany, 2004
|
||||
// last major change: 30.06.2004
|
||||
//hello.java
|
||||
//-----------------------
|
||||
//part of the AnomicHTTPD caching proxy
|
||||
//(C) by Michael Peter Christen; mc@anomic.de
|
||||
//first published on http://www.anomic.de
|
||||
//Frankfurt, Germany, 2004
|
||||
//last major change: 30.06.2004
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//This program is free software; you can redistribute it and/or modify
|
||||
//it under the terms of the GNU General Public License as published by
|
||||
//the Free Software Foundation; either version 2 of the License, or
|
||||
//(at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//This program is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
//GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//You should have received a copy of the GNU General Public License
|
||||
//along with this program; if not, write to the Free Software
|
||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// Using this software in any meaning (reading, learning, copying, compiling,
|
||||
// running) means that you agree that the Author(s) is (are) not responsible
|
||||
// for cost, loss of data or any harm that may be caused directly or indirectly
|
||||
// by usage of this softare or this documentation. The usage of this software
|
||||
// is on your own risk. The installation and usage (starting/running) of this
|
||||
// software may allow other people or application to access your computer and
|
||||
// any attached devices and is highly dependent on the configuration of the
|
||||
// software which must be done by the user of the software; the author(s) is
|
||||
// (are) also not responsible for proper configuration and usage of the
|
||||
// software, even if provoked by documentation provided together with
|
||||
// the software.
|
||||
//Using this software in any meaning (reading, learning, copying, compiling,
|
||||
//running) means that you agree that the Author(s) is (are) not responsible
|
||||
//for cost, loss of data or any harm that may be caused directly or indirectly
|
||||
//by usage of this softare or this documentation. The usage of this software
|
||||
//is on your own risk. The installation and usage (starting/running) of this
|
||||
//software may allow other people or application to access your computer and
|
||||
//any attached devices and is highly dependent on the configuration of the
|
||||
//software which must be done by the user of the software; the author(s) is
|
||||
//(are) also not responsible for proper configuration and usage of the
|
||||
//software, even if provoked by documentation provided together with
|
||||
//the software.
|
||||
//
|
||||
// Any changes to this file according to the GPL as documented in the file
|
||||
// gpl.txt aside this file in the shipment you received can be done to the
|
||||
// lines that follows this copyright notice here, but changes must not be
|
||||
// done inside the copyright notive above. A re-distribution must contain
|
||||
// the intact and unchanged copyright notice.
|
||||
// Contributions and changes to the program code must be marked as such.
|
||||
//Any changes to this file according to the GPL as documented in the file
|
||||
//gpl.txt aside this file in the shipment you received can be done to the
|
||||
//lines that follows this copyright notice here, but changes must not be
|
||||
//done inside the copyright notive above. A re-distribution must contain
|
||||
//the intact and unchanged copyright notice.
|
||||
//Contributions and changes to the program code must be marked as such.
|
||||
|
||||
// You must compile this file with
|
||||
// javac -classpath .:../../Classes hello.java
|
||||
// if the shell's current path is HTROOT
|
||||
//You must compile this file with
|
||||
//javac -classpath .:../../Classes hello.java
|
||||
//if the shell's current path is HTROOT
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
@ -54,83 +54,96 @@ import de.anomic.yacy.yacyCore;
|
|||
import de.anomic.yacy.yacySeed;
|
||||
|
||||
public class hello {
|
||||
|
||||
|
||||
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
|
||||
serverObjects prop = new serverObjects(); // return variable that accumulates replacements
|
||||
|
||||
if ((post == null) ||
|
||||
(env == null) ||
|
||||
(yacyCore.seedDB == null) ||
|
||||
(yacyCore.seedDB.mySeed == null)) return new serverObjects();
|
||||
|
||||
String iam = (String) post.get("iam",""); // complete seed of the requesting peer
|
||||
String key = (String) post.get("key",""); // transmission key for response
|
||||
String seed = (String) post.get("seed",""); //
|
||||
String pattern = (String) post.get("pattern",""); //
|
||||
String countStr= (String) post.get("count","0"); //
|
||||
serverObjects prop = new serverObjects(); // return variable that accumulates replacements
|
||||
|
||||
if ((post == null) ||
|
||||
(env == null) ||
|
||||
(yacyCore.seedDB == null) ||
|
||||
(yacyCore.seedDB.mySeed == null)) return new serverObjects();
|
||||
|
||||
String iam = (String) post.get("iam",""); // complete seed of the requesting peer
|
||||
String key = (String) post.get("key",""); // transmission key for response
|
||||
String seed = (String) post.get("seed",""); //
|
||||
String pattern = (String) post.get("pattern",""); //
|
||||
String countStr= (String) post.get("count","0"); //
|
||||
String mytime = (String) post.get("mytime",""); //
|
||||
int count = 0;
|
||||
try {count = (countStr == null) ? 0 : Integer.parseInt(countStr);} catch (NumberFormatException e) {count = 0;}
|
||||
int count = 0;
|
||||
try {count = (countStr == null) ? 0 : Integer.parseInt(countStr);} catch (NumberFormatException e) {count = 0;}
|
||||
Date remoteTime = yacyCore.parseUniversalDate((String) post.get("mytime")); // read remote time
|
||||
yacySeed remoteSeed = yacySeed.genRemoteSeed(seed, key, remoteTime);
|
||||
|
||||
//System.out.println("YACYHELLO: REMOTESEED=" + ((remoteSeed == null) ? "NULL" : remoteSeed.toString()));
|
||||
if (remoteSeed == null) return new serverObjects();
|
||||
|
||||
// we easily know the caller's IP:
|
||||
String yourip = (String) header.get("CLIENTIP", "<unknown>"); // read an artificial header addendum
|
||||
//System.out.println("YACYHELLO: YOUR IP=" + yourip);
|
||||
prop.put("yourip", yourip);
|
||||
remoteSeed.put("IP", yourip);
|
||||
|
||||
// now let's check if the calling peer can be reached and answers
|
||||
int port = Integer.parseInt((String) remoteSeed.get("Port", "8080"));
|
||||
int urls = yacyClient.queryUrlCount(remoteSeed);
|
||||
if (urls >= 0) {
|
||||
if (remoteSeed.get("PeerType", "senior") == null) {
|
||||
prop.put("yourtype", "senior");
|
||||
remoteSeed.put("PeerType", "senior");
|
||||
} else if (remoteSeed.get("PeerType", "principal").equals("principal")) {
|
||||
prop.put("yourtype", "principal");
|
||||
} else {
|
||||
prop.put("yourtype", "senior");
|
||||
remoteSeed.put("PeerType", "senior");
|
||||
}
|
||||
// connect the seed
|
||||
yacyCore.peerActions.peerArrival(remoteSeed, true);
|
||||
} else {
|
||||
prop.put("yourtype", "junior");
|
||||
yacySeed remoteSeed = yacySeed.genRemoteSeed(seed, key, remoteTime);
|
||||
|
||||
//System.out.println("YACYHELLO: REMOTESEED=" + ((remoteSeed == null) ? "NULL" : remoteSeed.toString()));
|
||||
if (remoteSeed == null) return new serverObjects();
|
||||
|
||||
// we easily know the caller's IP:
|
||||
String yourip = (String) header.get("CLIENTIP", "<unknown>"); // read an artificial header addendum
|
||||
//System.out.println("YACYHELLO: YOUR IP=" + yourip);
|
||||
prop.put("yourip", yourip);
|
||||
|
||||
int urls = -1;
|
||||
/*
|
||||
* Needed for port forwarding support ....
|
||||
*
|
||||
* If the peer has reported an other address as it has connected
|
||||
* to us, we try to use the reported address first ...
|
||||
*
|
||||
* @see serverCore#portForwardingEnabled
|
||||
*/
|
||||
if ((!remoteSeed.get("IP","").equalsIgnoreCase(yourip)) &&
|
||||
((urls = yacyClient.queryUrlCount(remoteSeed)) == -1)) {
|
||||
remoteSeed.put("IP", yourip);
|
||||
urls = yacyClient.queryUrlCount(remoteSeed);
|
||||
}
|
||||
|
||||
// now let's check if the calling peer can be reached and answers
|
||||
int port = Integer.parseInt(remoteSeed.get("Port", "8080"));
|
||||
if (urls >= 0) {
|
||||
if (remoteSeed.get("PeerType", "senior") == null) {
|
||||
prop.put("yourtype", "senior");
|
||||
remoteSeed.put("PeerType", "senior");
|
||||
} else if (remoteSeed.get("PeerType", "principal").equals("principal")) {
|
||||
prop.put("yourtype", "principal");
|
||||
} else {
|
||||
prop.put("yourtype", "senior");
|
||||
remoteSeed.put("PeerType", "senior");
|
||||
}
|
||||
// connect the seed
|
||||
yacyCore.peerActions.peerArrival(remoteSeed, true);
|
||||
} else {
|
||||
prop.put("yourtype", "junior");
|
||||
remoteSeed.put("LastSeen", yacyCore.universalDateShortString());
|
||||
yacyCore.peerActions.juniorConnects++; // update statistics
|
||||
remoteSeed.put("PeerType", "junior");
|
||||
yacyCore.log.logInfo("hello: responded remote junior peer '" + remoteSeed.getName() + "' from " + yourip + ":" + port);
|
||||
// no connection here, instead store junior in connection cache
|
||||
if ((remoteSeed.hash != null) && (remoteSeed.isProper())) yacyCore.peerActions.peerPing(remoteSeed);
|
||||
}
|
||||
|
||||
yacyCore.peerActions.juniorConnects++; // update statistics
|
||||
remoteSeed.put("PeerType", "junior");
|
||||
yacyCore.log.logInfo("hello: responded remote junior peer '" + remoteSeed.getName() + "' from " + yourip + ":" + port);
|
||||
// no connection here, instead store junior in connection cache
|
||||
if ((remoteSeed.hash != null) && (remoteSeed.isProper())) yacyCore.peerActions.peerPing(remoteSeed);
|
||||
}
|
||||
|
||||
String seeds = "";
|
||||
|
||||
// attach also my own seed
|
||||
// attach also my own seed
|
||||
seeds += "seed0=" + yacyCore.seedDB.mySeed.genSeedStr(key) + serverCore.crlfString;
|
||||
|
||||
// attach some more seeds, as requested
|
||||
if (yacyCore.seedDB != null) {
|
||||
if (count > yacyCore.seedDB.sizeConnected()) count = yacyCore.seedDB.sizeConnected();
|
||||
if (count > 100) count = 100;
|
||||
yacySeed[] ys = yacyCore.seedDB.seedsByAge(true, count); // latest seeds
|
||||
int c = 1;
|
||||
for (int i = 1; i < ys.length; i++) {
|
||||
if ((ys[i] != null) && (ys[i].isProper())) {
|
||||
|
||||
// attach some more seeds, as requested
|
||||
if (yacyCore.seedDB != null) {
|
||||
if (count > yacyCore.seedDB.sizeConnected()) count = yacyCore.seedDB.sizeConnected();
|
||||
if (count > 100) count = 100;
|
||||
yacySeed[] ys = yacyCore.seedDB.seedsByAge(true, count); // latest seeds
|
||||
int c = 1;
|
||||
for (int i = 1; i < ys.length; i++) {
|
||||
if ((ys[i] != null) && (ys[i].isProper())) {
|
||||
seeds += "seed" + c + "=" + ys[i].genSeedStr(key) + serverCore.crlfString;
|
||||
c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prop.put("mytime", yacyCore.universalDateShortString());
|
||||
prop.put("seedlist", seeds);
|
||||
// return rewrite properties
|
||||
return prop;
|
||||
// return rewrite properties
|
||||
return prop;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ import de.anomic.plasma.plasmaParserDocument;
|
|||
import de.anomic.plasma.parser.AbstractParser;
|
||||
import de.anomic.plasma.parser.Parser;
|
||||
import de.anomic.plasma.parser.ParserException;
|
||||
import de.anomic.server.serverByteBuffer;
|
||||
|
||||
public class pdfParser extends AbstractParser implements Parser {
|
||||
|
||||
|
@ -115,7 +116,7 @@ public class pdfParser extends AbstractParser implements Parser {
|
|||
docKeyWords = theDocInfo.getKeywords();
|
||||
}
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
serverByteBuffer out = new serverByteBuffer();
|
||||
writer = new OutputStreamWriter( out );
|
||||
stripper.writeText(theDocument, writer );
|
||||
|
||||
|
@ -123,6 +124,8 @@ public class pdfParser extends AbstractParser implements Parser {
|
|||
theDocument.close(); theDocument = null;
|
||||
|
||||
byte[] contents = out.toByteArray();
|
||||
out.close();
|
||||
out = null;
|
||||
|
||||
if ((docTitle == null) || (docTitle.length() == 0)) {
|
||||
docTitle = ((contents.length > 80)? new String(contents, 0, 80):new String(contents)).
|
||||
|
|
|
@ -414,6 +414,8 @@ public final class plasmaParser {
|
|||
|
||||
} catch (Exception e) { /* we can ignore this for the moment */
|
||||
serverLog.logWarning("PARSER", "Parser '" + className + "' doesn't work correctly and will be ignored.\n [" + e.getClass().getName() + "]: " + e.getMessage());
|
||||
} catch (Error e) { /* we can ignore this for the moment */
|
||||
serverLog.logWarning("PARSER", "Parser '" + className + "' doesn't work correctly and will be ignored.\n [" + e.getClass().getName() + "]: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
|
||||
package de.anomic.server;
|
||||
|
||||
import java.nio.channels.ClosedByInterruptException;
|
||||
|
||||
import de.anomic.server.logging.serverLog;
|
||||
|
||||
public abstract class serverAbstractThread extends Thread implements serverThread {
|
||||
|
@ -180,8 +182,10 @@ public abstract class serverAbstractThread extends Thread implements serverThrea
|
|||
}
|
||||
|
||||
public void jobExceptionHandler(Exception e) {
|
||||
// default handler for job exceptions. shall be overridden for own handler
|
||||
logError("thread '" + this.getName() + "': " + e.toString(),e);
|
||||
if (!(e instanceof ClosedByInterruptException)) {
|
||||
// default handler for job exceptions. shall be overridden for own handler
|
||||
logError("thread '" + this.getName() + "': " + e.toString(),e);
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
|
|
@ -94,7 +94,10 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
|
||||
// class variables
|
||||
private int port; // the listening port
|
||||
private ServerSocketChannel channel;
|
||||
|
||||
public static boolean portForwardingEnabled = false;
|
||||
public static serverPortForwarding portForwarding = null;
|
||||
|
||||
private ServerSocket socket; // listener
|
||||
public int maxSessions = 0; // max. number of sessions; 0=unlimited
|
||||
serverLog log; // log object
|
||||
|
@ -167,14 +170,23 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
}
|
||||
|
||||
// class initializer
|
||||
public serverCore(int port, int maxSessions, int timeout,
|
||||
boolean termSleepingThreads, boolean blockAttack,
|
||||
serverHandler handlerPrototype, serverSwitch switchboard,
|
||||
int commandMaxLength) throws IOException {
|
||||
public serverCore(
|
||||
int port,
|
||||
int maxSessions,
|
||||
int timeout,
|
||||
boolean termSleepingThreads,
|
||||
boolean blockAttack,
|
||||
serverHandler handlerPrototype,
|
||||
serverSwitch switchboard,
|
||||
int commandMaxLength
|
||||
) throws IOException {
|
||||
this.port = port;
|
||||
this.commandMaxLength = commandMaxLength;
|
||||
this.denyHost = (blockAttack) ? new Hashtable() : null;
|
||||
|
||||
// initialize logger
|
||||
this.log = new serverLog("SERVER");
|
||||
|
||||
/*
|
||||
try {
|
||||
ServerSocketFactory ssf = getServerSocketFactory(false, new File("D:\\dev\\proxy\\addon\\testkeys"), "passphrase");
|
||||
|
@ -185,13 +197,10 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
}
|
||||
*/
|
||||
|
||||
|
||||
// Open a new server-socket channel
|
||||
try {
|
||||
// Open a new server-socket channel
|
||||
this.channel = ServerSocketChannel.open();
|
||||
|
||||
// Binds the ServerSocket to a specific address
|
||||
this.socket = this.channel.socket();
|
||||
this.socket = new ServerSocket();
|
||||
this.socket.bind(new InetSocketAddress(port));
|
||||
|
||||
// this.socket = new ServerSocket(port);
|
||||
|
@ -199,6 +208,42 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
System.out.println("FATAL ERROR: " + e.getMessage() + " - probably root access rights needed. check port number"); System.exit(0);
|
||||
}
|
||||
|
||||
// doing the port forwarding stuff
|
||||
if (switchboard.getConfig("portForwardingEnabled","false").equalsIgnoreCase("true")) {
|
||||
try {
|
||||
String portFwHost = switchboard.getConfig("portForwardingHost","localhost");
|
||||
Integer portFwPort = Integer.valueOf(switchboard.getConfig("portForwardingPort","8080"));
|
||||
String portFwUser = switchboard.getConfig("portForwardingUser","xxx");
|
||||
|
||||
String localHost = this.socket.getInetAddress().getHostName();
|
||||
Integer localPort = new Integer(this.socket.getLocalPort());
|
||||
|
||||
this.log.logInfo("Trying to connect to remote port forwarding host " + portFwUser + "@" + portFwHost + ":" + portFwPort);
|
||||
|
||||
Class forwarderClass = Class.forName("de.anomic.server.serverPortForwardingSch");
|
||||
serverCore.portForwarding = (serverPortForwarding) forwarderClass.newInstance();
|
||||
|
||||
serverCore.portForwarding.init(
|
||||
portFwHost,
|
||||
portFwPort.intValue(),
|
||||
portFwUser,
|
||||
switchboard.getConfig("portForwardingPwd","xxx"),
|
||||
localHost,
|
||||
localPort.intValue());
|
||||
|
||||
serverCore.portForwarding.connect();
|
||||
serverCore.portForwardingEnabled = true;
|
||||
|
||||
this.log.logInfo("Remote port forwarding connection established: " + portFwHost+":"+portFwPort+" -> "+localHost+":"+localPort);
|
||||
} catch (Exception e) {
|
||||
this.log.logError("Unable to initialize server port forwarding.",e);
|
||||
switchboard.setConfig("portForwardingEnabled","false");
|
||||
} catch (Error e) {
|
||||
this.log.logError("Unable to initialize server port forwarding.",e);
|
||||
switchboard.setConfig("portForwardingEnabled","false");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
this.handlerPrototype = handlerPrototype;
|
||||
this.switchboard = switchboard;
|
||||
|
@ -207,7 +252,6 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
this.maxSessions = maxSessions;
|
||||
this.timeout = timeout;
|
||||
this.termSleepingThreads = termSleepingThreads;
|
||||
this.log = new serverLog("SERVER");
|
||||
} catch (java.lang.ClassNotFoundException e) {
|
||||
System.out.println("FATAL ERROR: " + e.getMessage() + " - Class Not Found"); System.exit(0);
|
||||
}
|
||||
|
@ -261,11 +305,21 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
public static InetAddress publicIP() {
|
||||
try {
|
||||
|
||||
// TODO: implement port forwarding here ...
|
||||
// if (portForwardingEnabled) {
|
||||
//
|
||||
// }
|
||||
|
||||
// If port forwarding was enabled we need to return the remote IP Address
|
||||
if ((serverCore.portForwardingEnabled)&&(serverCore.portForwarding != null)) {
|
||||
return InetAddress.getByName(serverCore.portForwarding.getHost());
|
||||
} else {
|
||||
return publicLocalIP();
|
||||
}
|
||||
} catch (java.net.UnknownHostException e) {
|
||||
System.err.println("ERROR: (internal) " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static InetAddress publicLocalIP() {
|
||||
try {
|
||||
|
||||
// list all addresses
|
||||
//InetAddress[] ia = InetAddress.getAllByName("localhost");
|
||||
InetAddress[] ia = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
|
||||
|
@ -358,17 +412,21 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
// consuming the isInterrupted Flag. Otherwise we could not properly close the session pool
|
||||
Thread.interrupted();
|
||||
|
||||
// closing the port forwarding channel
|
||||
if ((portForwardingEnabled) && (portForwarding != null) ) {
|
||||
portForwarding.disconnect();
|
||||
}
|
||||
|
||||
// close the session pool
|
||||
this.theSessionPool.close();
|
||||
|
||||
// closing the serverchannel and socket
|
||||
this.socket.close();
|
||||
this.channel.close();
|
||||
|
||||
// close the session pool
|
||||
this.theSessionPool.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.log.logSystem("Unable to close session pool: " + e.getMessage());
|
||||
}
|
||||
log.logSystem("* terminated");
|
||||
this.log.logSystem("* terminated");
|
||||
}
|
||||
|
||||
public int getJobCount() {
|
||||
|
@ -430,17 +488,33 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
threadCount = serverCore.this.theSessionThreadGroup.enumerate(threadList);
|
||||
|
||||
try {
|
||||
// trying to gracefull stop all still running sessions ...
|
||||
serverCore.this.log.logInfo("Trying to shutdown " + threadCount + " remaining session threads ...");
|
||||
for ( int currentThreadIdx = 0; currentThreadIdx < threadCount; currentThreadIdx++ ) {
|
||||
((Session)threadList[currentThreadIdx]).setStopped(true);
|
||||
}
|
||||
|
||||
// waiting a frew ms for the session objects to continue processing
|
||||
Thread.sleep(500);
|
||||
|
||||
// if there are some sessions that are blocking in IO, we simply close the socket
|
||||
for ( int currentThreadIdx = 0; currentThreadIdx < threadCount; currentThreadIdx++ ) {
|
||||
Session currentSession = (Session)threadList[currentThreadIdx];
|
||||
if (currentSession.isAlive()) {
|
||||
if ((currentSession.controlSocket != null)&&(currentSession.controlSocket.isConnected())) {
|
||||
currentSession.controlSocket.close();
|
||||
serverCore.this.log.logInfo("Closing socket of thread " + currentSession.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// we need to use a timeout here because of missing interruptable session threads ...
|
||||
for ( int currentThreadIdx = 0; currentThreadIdx < threadCount; currentThreadIdx++ ) {
|
||||
// we need to use a timeout here because of missing interruptable session threads ...
|
||||
if (threadList[currentThreadIdx].isAlive()) threadList[currentThreadIdx].join(500);
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
serverCore.this.log.logWarning("Interruption while trying to shutdown all session threads.");
|
||||
serverCore.this.log.logWarning("Interruption while trying to shutdown all remaining session threads.");
|
||||
}
|
||||
|
||||
this.isClosed = true;
|
||||
|
@ -538,6 +612,7 @@ public final class serverCore extends serverAbstractThread implements serverThre
|
|||
private int commandCounter; // for logging: number of commands in this session
|
||||
private String identity; // a string that identifies the client (i.e. ftp: account name)
|
||||
//private boolean promiscuous; // if true, no lines are read and streams are only passed
|
||||
|
||||
public Socket controlSocket; // dialog socket
|
||||
public InetAddress userAddress; // the address of the client
|
||||
public PushbackInputStream in; // on control input stream
|
||||
|
|
|
@ -52,11 +52,18 @@ import java.util.zip.GZIPOutputStream;
|
|||
|
||||
public final class serverFileUtils {
|
||||
|
||||
public static void copy(InputStream source, OutputStream dest) throws IOException {
|
||||
public static int copy(InputStream source, OutputStream dest) throws IOException {
|
||||
byte[] buffer = new byte[4096];
|
||||
int c;
|
||||
while ((c = source.read(buffer)) > 0) dest.write(buffer, 0, c);
|
||||
|
||||
int c, total = 0;
|
||||
while ((c = source.read(buffer)) > 0) {
|
||||
dest.write(buffer, 0, c);
|
||||
dest.flush();
|
||||
total += c;
|
||||
}
|
||||
dest.flush();
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
public static void copy(InputStream source, File dest) throws IOException {
|
||||
|
|
|
@ -47,7 +47,7 @@ public final class serverSemaphore {
|
|||
private long currentValue = 0;
|
||||
private long maximumValue = Long.MAX_VALUE;
|
||||
|
||||
protected serverSemaphore() {
|
||||
public serverSemaphore() {
|
||||
this(0,Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -122,21 +122,35 @@ public class yacyClient {
|
|||
Date remoteTime = yacyCore.parseUniversalDate((String) result.get("mytime")); // read remote time
|
||||
|
||||
// check consistency with expectation
|
||||
float otherPeerVersion = 0;
|
||||
if ((otherHash != null ) && (otherHash.length() > 0)) {
|
||||
yacySeed otherPeer = yacySeed.genRemoteSeed((String) result.get("seed0"), key, remoteTime);
|
||||
if ((otherPeer == null) || (!(otherPeer.hash.equals(otherHash)))) {
|
||||
yacyCore.log.logDebug("yacyClient.publishMySeed consistency error: other peer wrong");
|
||||
return -1; // no success
|
||||
}
|
||||
otherPeerVersion = otherPeer.getVersion();
|
||||
}
|
||||
|
||||
// set my own seed according to new information
|
||||
yacySeed mySeedBkp = (yacySeed) yacyCore.seedDB.mySeed.clone();
|
||||
yacyCore.seedDB.mySeed.put("IP", (String) result.get("yourip"));
|
||||
String mytype = (String) result.get("yourtype");
|
||||
if (mytype == null) mytype = "junior";
|
||||
if ((yacyCore.seedDB.mySeed.get("PeerType", "junior").equals("principal")) && (mytype.equals("senior"))) mytype = "principal";
|
||||
yacyCore.seedDB.mySeed.put("PeerType", mytype);
|
||||
if (!serverCore.portForwardingEnabled) {
|
||||
yacyCore.seedDB.mySeed.put("IP", (String) result.get("yourip"));
|
||||
}
|
||||
|
||||
/* If we have port forwarding enabled but the other peer uses a too old yacy version
|
||||
* we can ignore the seed-type that was reported by the peer.
|
||||
*
|
||||
* Otherwise we have to change our seed-type
|
||||
*
|
||||
* @see serverCore#portForwardingEnabled
|
||||
*/
|
||||
if ((!serverCore.portForwardingEnabled) || (otherPeerVersion > (float)0.381)) {
|
||||
String mytype = (String) result.get("yourtype");
|
||||
if (mytype == null) mytype = "junior";
|
||||
if ((yacyCore.seedDB.mySeed.get("PeerType", "junior").equals("principal")) && (mytype.equals("senior"))) mytype = "principal";
|
||||
yacyCore.seedDB.mySeed.put("PeerType", mytype);
|
||||
}
|
||||
|
||||
if (!(yacyCore.seedDB.mySeed.isProper())) {
|
||||
yacyCore.seedDB.mySeed = mySeedBkp;
|
||||
|
|
|
@ -457,7 +457,8 @@ public class yacyCore {
|
|||
}
|
||||
}
|
||||
availableUploaders.put(className.substring("yacySeedUpload".length()),fullClassName);
|
||||
} catch (Exception e) { /* we can ignore this for the moment */ }
|
||||
} catch (Exception e) { /* we can ignore this for the moment */
|
||||
} catch (Error e) { /* we can ignore this for the moment */ }
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
|
|
|
@ -91,27 +91,31 @@ public class yacyPeerActions {
|
|||
}
|
||||
|
||||
public void updateMySeed() {
|
||||
if (sb.getConfig("peerName", "nameless").equals("nameless"))
|
||||
sb.setConfig("peerName", serverCore.publicIP().getHostName() + yacyCore.speedKey + serverSystem.infoKey() + (System.currentTimeMillis() & 99));
|
||||
seedDB.mySeed.put("Name", sb.getConfig("peerName", "nameless"));
|
||||
seedDB.mySeed.put("Port", sb.getConfig("port", "8080"));
|
||||
seedDB.mySeed.put("ISpeed", "unknown"); // the speed of indexing (words/minute) of the peer
|
||||
long uptime = ((yacyCore.universalTime() - Long.parseLong(sb.getConfig("startupTime", "0"))) / 1000) / 60;
|
||||
seedDB.mySeed.put("Uptime", "" + uptime); // the number of minutes that the peer is up in minutes/day (moving average MA30)
|
||||
seedDB.mySeed.put("LCount", "" + sb.lUrlSize()); // the number of links that the peer has stored (LURL's)
|
||||
seedDB.mySeed.put("ICount", "" + sb.cacheSizeMin()); // the minimum number of words that the peer has indexed (as it says)
|
||||
seedDB.mySeed.put("SCount", "" + seedDB.sizeConnected()); // the number of seeds that the peer has stored
|
||||
seedDB.mySeed.put("CCount", "" + (((int) ((seedDB.sizeConnected() + seedDB.sizeDisconnected() + seedDB.sizePotential()) * 60.0 / (uptime + 1.01)) * 100) / 100.0)); // the number of clients that the peer connects (as connects/hour)
|
||||
seedDB.mySeed.put("Version", sb.getConfig("version", ""));
|
||||
if (seedDB.mySeed.get("PeerType","").equals("principal")) {
|
||||
// attach information about seed location
|
||||
seedDB.mySeed.put("seedURL", sb.getConfig("seedURL", ""));
|
||||
}
|
||||
seedDB.mySeed.setFlagDirectConnect(true);
|
||||
seedDB.mySeed.put("LastSeen", yacyCore.universalDateShortString());
|
||||
seedDB.mySeed.setFlagAcceptRemoteCrawl(sb.getConfig("crawlResponse", "").equals("true"));
|
||||
seedDB.mySeed.setFlagAcceptRemoteIndex(sb.getConfig("allowReceiveIndex", "").equals("true"));
|
||||
//mySeed.setFlagAcceptRemoteIndex(true);
|
||||
if (sb.getConfig("peerName", "nameless").equals("nameless"))
|
||||
sb.setConfig("peerName", serverCore.publicIP().getHostName() + yacyCore.speedKey + serverSystem.infoKey() + (System.currentTimeMillis() & 99));
|
||||
seedDB.mySeed.put("Name", sb.getConfig("peerName", "nameless"));
|
||||
if ((serverCore.portForwardingEnabled) && (serverCore.portForwarding != null)) {
|
||||
seedDB.mySeed.put("Port", Integer.toString(serverCore.portForwarding.getPort()));
|
||||
} else {
|
||||
seedDB.mySeed.put("Port", sb.getConfig("port", "8080"));
|
||||
}
|
||||
seedDB.mySeed.put("ISpeed", "unknown"); // the speed of indexing (words/minute) of the peer
|
||||
long uptime = ((yacyCore.universalTime() - Long.parseLong(sb.getConfig("startupTime", "0"))) / 1000) / 60;
|
||||
seedDB.mySeed.put("Uptime", "" + uptime); // the number of minutes that the peer is up in minutes/day (moving average MA30)
|
||||
seedDB.mySeed.put("LCount", "" + sb.lUrlSize()); // the number of links that the peer has stored (LURL's)
|
||||
seedDB.mySeed.put("ICount", "" + sb.cacheSizeMin()); // the minimum number of words that the peer has indexed (as it says)
|
||||
seedDB.mySeed.put("SCount", "" + seedDB.sizeConnected()); // the number of seeds that the peer has stored
|
||||
seedDB.mySeed.put("CCount", "" + (((int) ((seedDB.sizeConnected() + seedDB.sizeDisconnected() + seedDB.sizePotential()) * 60.0 / (uptime + 1.01)) * 100) / 100.0)); // the number of clients that the peer connects (as connects/hour)
|
||||
seedDB.mySeed.put("Version", sb.getConfig("version", ""));
|
||||
if (seedDB.mySeed.get("PeerType","").equals("principal")) {
|
||||
// attach information about seed location
|
||||
seedDB.mySeed.put("seedURL", sb.getConfig("seedURL", ""));
|
||||
}
|
||||
seedDB.mySeed.setFlagDirectConnect(true);
|
||||
seedDB.mySeed.put("LastSeen", yacyCore.universalDateShortString());
|
||||
seedDB.mySeed.setFlagAcceptRemoteCrawl(sb.getConfig("crawlResponse", "").equals("true"));
|
||||
seedDB.mySeed.setFlagAcceptRemoteIndex(sb.getConfig("allowReceiveIndex", "").equals("true"));
|
||||
//mySeed.setFlagAcceptRemoteIndex(true);
|
||||
}
|
||||
|
||||
public void saveMySeed() {
|
||||
|
|
|
@ -72,6 +72,7 @@ import java.util.StringTokenizer;
|
|||
import de.anomic.net.natLib;
|
||||
import de.anomic.plasma.plasmaSwitchboard;
|
||||
import de.anomic.server.serverCodings;
|
||||
import de.anomic.server.serverCore;
|
||||
import de.anomic.tools.bitfield;
|
||||
import de.anomic.tools.crypt;
|
||||
|
||||
|
@ -323,7 +324,11 @@ public class yacySeed {
|
|||
|
||||
// now calculate other information about the host
|
||||
newSeed.dna.put("Name", sb.getConfig("peerName", "unnamed"));
|
||||
newSeed.dna.put("Port", sb.getConfig("port", "8080"));
|
||||
if ((serverCore.portForwardingEnabled) && (serverCore.portForwarding != null)) {
|
||||
newSeed.dna.put("Port",Integer.toString(serverCore.portForwarding.getPort()));
|
||||
} else {
|
||||
newSeed.dna.put("Port", sb.getConfig("port", "8080"));
|
||||
}
|
||||
newSeed.dna.put("BDate", yacyCore.universalDateShortString());
|
||||
newSeed.dna.put("LastSeen", newSeed.dna.get("BDate")); // just as initial setting
|
||||
newSeed.dna.put("PeerType", "virgin");
|
||||
|
|
|
@ -121,7 +121,11 @@ public class yacySeedDB {
|
|||
}
|
||||
|
||||
mySeed.put("IP", ""); // we delete the old information to see what we have now
|
||||
mySeed.put("Port", sb.getConfig("port", "8080")); // set my seed's correct port number
|
||||
if ((serverCore.portForwardingEnabled) && (serverCore.portForwarding != null)) {
|
||||
mySeed.put("Port", Integer.toString(serverCore.portForwarding.getPort()));
|
||||
} else {
|
||||
mySeed.put("Port", sb.getConfig("port", "8080")); // set my seed's correct port number
|
||||
}
|
||||
mySeed.put("PeerType", "virgin"); // markup startup condition
|
||||
|
||||
// start our virtual DNS service for yacy peers with empty cache
|
||||
|
|
|
@ -468,3 +468,11 @@ isTransparentProxy=false
|
|||
|
||||
# Specifies if yacy should use the http connection keep-alive feature
|
||||
connectionKeepAliveSupport=false
|
||||
|
||||
# Configuration options needed to configure server port forwarding
|
||||
portForwardingEnabled=false
|
||||
portForwardingHost=
|
||||
portForwardingPort=
|
||||
portForwardingUser=
|
||||
portForwardingPwd=
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user