Merge pull request #440 from lfuelling/master

Add setting for public facing port
pull/461/head
Burkhard 3 years ago committed by GitHub
commit a6a9828181
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -543,6 +543,9 @@ debug.snippets.statistics.enabled=false
#staticIP if you have a static IP, you can use this setting
staticIP=
#publicPort if you use a different port to access YaCy than the one it listens on, you can use this setting
publicPort=
# each time YaCy starts up, it can trigger the local browser to show the
# status page. This is active by default, to make it easier for first-time
# users to understand what this application does. You can disable browser

@ -63,6 +63,7 @@
::<!-- 12 -->
<p><strong>The Peer Name is:</strong> <span class="settingsValue">#[peerName]#</span><br />
<strong>Your static Ip(or DynDns) is:</strong> <span class="settingsValue">#[staticIP]#</span>
<strong>Your public port is:</strong> <span class="settingsValue">#[publicPort]#</span>
</p>
::<!-- 13 -->
<p><strong>Seed Settings changed.#(success)#::You are now a principal peer.#(/success)#</strong></p>

@ -212,6 +212,19 @@ public class SettingsAck_p {
env.setConfig(SwitchboardConstants.SERVER_STATICIP, "");
}
// publicPort
String publicPort = (post.get("publicPort")).trim();
try {
Integer pport = Integer.parseInt(publicPort);
if(pport < 65535 && pport >= 0) {
serverCore.usePublicPort = true;
sb.peers.mySeed().setPort(pport);
env.setConfig(SwitchboardConstants.SERVER_PUBLICPORT, publicPort);
}
} catch (NumberFormatException e) {
// noop
}
// server access data
String filter = (post.get("serverfilter")).trim();
/*String user = (String) post.get("serveruser");

@ -30,6 +30,15 @@
If the value you enter here does not match with this IP,
you will not be able to access the server pages anymore.</td>
</tr>
<tr valign="top">
<td><label for="publicPort">publicPort (optional):</label></td>
<td><input name="publicPort" id="publicPort" aria-describedby="publicPortInfo" type="text" size="32" maxlength="80" value="#[publicPort]#" /></td>
<td id="publicPortInfo"><strong>The publicPort can help that your peer can be reached by other peers in case that your
peer is behind a reverse proxy.</strong>
If the port used to access YaCy is the same port the application is listening on,
you don't need to set anything here, please leave it blank.<br />
</td>
</tr>
<tr valign="top">
<td><label for="fileHost">fileHost:</label></td>
<td><input name="fileHost" id="fileHost" aria-describedby="fileHostInfo" type="text" size="32" maxlength="80" value="#[fileHost]#" /><br />(requires restart)</td>

@ -93,6 +93,7 @@ public final class Settings_p {
prop.putHTML("peerName", sb.peers.mySeed().getName());
prop.putHTML("staticIP", env.getConfig("staticIP", ""));
prop.putHTML("publicPort", env.getConfig("publicPort",""));
prop.putHTML("fileHost", env.getConfig("fileHost", "localpeer"));
String peerLang = env.getConfig("locale.language", "default");
if (peerLang.equals("default")) peerLang = "en";

@ -569,6 +569,15 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
}
}
/**
* Set the public facing port.
* @param port the port to use
*/
public final void setPort(Integer port) {
if (!isProperPort(port)) return;
this.dna.put(Seed.PORT, String.valueOf(port));
}
/**
* Set several local IPs which are good to access this peer.
* This OVERWRITES ALL ips stored before!
@ -1373,7 +1382,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
* check if the given string containing an IP is proper. This checks also if the IP is within the given
* range of the network definition
* @param ipString
* @return true iff the IP is proper
* @return true if the IP is proper
*/
public static final boolean isProperIP(final String ipString) {
if (ipString == null) return false;
@ -1384,6 +1393,16 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
return islocal == Switchboard.getSwitchboard().isIntranetMode();
}
/**
* checks if the given port is within the allowed range (1-65535).
* @param port the port to check
* @return true if the port is valid
*/
public static final boolean isProperPort(final Integer port) {
if (port <= 0) return false;
return port <= 65535;
}
@Override
public final String toString() {
final ConcurrentMap<String, String> copymap = new ConcurrentHashMap<String, String>();

@ -61,6 +61,7 @@ public final class SwitchboardConstants {
public static final String SERVER_SSLPORT = "port.ssl"; // port for https
public static final String SERVER_SHUTDOWNPORT = "port.shutdown"; // local port to listen for a shutdown signal (0 <= disabled)
public static final String SERVER_STATICIP = "staticIP"; // static IP of http server
public static final String SERVER_PUBLICPORT = "publicPort";
public static final String PUBLIC_SEARCHPAGE = "publicSearchpage";

@ -39,5 +39,6 @@ public final class serverCore {
public static final String LF_STRING = UTF8.String(new byte[]{LF});
public static boolean useStaticIP = false;
public static boolean usePublicPort = false;
}

Loading…
Cancel
Save