Skip to content

Commit

Permalink
corrections to port forwarding
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@286 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Jun 16, 2005
1 parent d8cb332 commit dbda6e1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
15 changes: 10 additions & 5 deletions htroot/Settings_p.html
Expand Up @@ -60,18 +60,23 @@ <h2>Settings</h2>
</form><br>

<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>
<fieldset><legend>Server Access Settings</legend>
These settings configure the access method to your own http proxy and server.
All traffic is routed throug one single port, for both proxy and server.<br>
<br><b>Port Configuration</b><br><br>
<table border="0" cellspacing="5">
<tr valign="top">
<td>Proxy and Administration Port:</td>
<td>Proxy and http-Server Administration Port:</td>
<td><input name="port" type="text" size="5" maxlength="5" value="#[port]#"></td>
<td><i>Changes will take effect after restart only.</i></td>
</tr>
</table>


<p><b>Proxy Port Forwarding</b><br><br>
<p><b>Port Forwarding</b><br><br>
You can use a remote server running a ssh demon to forward your server/proxy port.
This is useful if you want to tunnel throug a NAT/router.
Alternatively, you can simply set a virtual server port on your NAT/Server to enable connections from outside.
<table border="0" cellspacing="5">
<tr valign="top">
<td>Enable port forwarding:</td>
Expand Down Expand Up @@ -101,7 +106,7 @@ <h2>Settings</h2>
</table>
</p>

<p><b>Proxy Access Restrictions</b><br><br>You can restrict the access to this proxy using a two-stage security barrier:
<p><b>Server Access Restrictions</b><br><br>You can restrict the access to this proxy/server 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>
Expand Down
27 changes: 13 additions & 14 deletions htroot/yacy/hello.java
Expand Up @@ -82,23 +82,22 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
//System.out.println("YACYHELLO: YOUR IP=" + yourip);
prop.put("yourip", yourip);

// now let's check if the calling peer can be reached and answers
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);
String reportedip = remoteSeed.get("IP", "");
remoteSeed.put("IP", yourip);
urls = yacyClient.queryUrlCount(remoteSeed);

// if this was not successful, we try to use the reported ip
if ((urls < 0) &&
(!remoteSeed.get("IP","").equalsIgnoreCase(yourip))) {
// the other peer does not respond under the ip it reported
// we try again using the ip we got from the http header
remoteSeed.put("IP", reportedip);
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"));
// assign status
if (urls >= 0) {
if (remoteSeed.get("PeerType", "senior") == null) {
prop.put("yourtype", "senior");
Expand All @@ -116,7 +115,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
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);
yacyCore.log.logInfo("hello: responded remote junior peer '" + remoteSeed.getName() + "' from " + yourip + ":" + remoteSeed.get("Port", "8080"));
// no connection here, instead store junior in connection cache
if ((remoteSeed.hash != null) && (remoteSeed.isProper())) yacyCore.peerActions.peerPing(remoteSeed);
}
Expand Down
2 changes: 2 additions & 0 deletions source/de/anomic/yacy/yacyClient.java
Expand Up @@ -134,6 +134,8 @@ public static int publishMySeed(String address, String otherHash) {

// set my own seed according to new information
yacySeed mySeedBkp = (yacySeed) yacyCore.seedDB.mySeed.clone();

// we overwrite our own IP number only, if we do not portForwarding
if (!serverCore.portForwardingEnabled) {
yacyCore.seedDB.mySeed.put("IP", (String) result.get("yourip"));
}
Expand Down

0 comments on commit dbda6e1

Please sign in to comment.