Michael Peter Christen 4 years ago
commit 13a2e6dc6e

@ -135,10 +135,10 @@ network.unit.definition = defaults/yacy.network.freeworld.unit
# This option is only valid if the network.unit.domain property is set to 'any' # This option is only valid if the network.unit.domain property is set to 'any'
network.unit.domain.nocheck = false network.unit.domain.nocheck = false
# in addition to non-dht networks a client may have its own agent name # A client may have its own agent name. This name can be set by the user and is set to a random value
# this option is only used if the value is non-empty and network.unit.dht = false # if not overwritten by the user. As an alternative, the name can be set with this property.
# that means it is not usable in YaCy p2p-configurations, only in private portal configurations # This option is only used if the value is non-empty.
network.unit.tenant.agent = network.unit.agent =
# Prefer https for in-protocol operations when available on remote peers # Prefer https for in-protocol operations when available on remote peers
# A distinct general setting is available to control whether https sould be used for remote search queries : remotesearch.https.preferred # A distinct general setting is available to control whether https sould be used for remote search queries : remotesearch.https.preferred

@ -224,7 +224,7 @@ public class ConfigNetwork_p
prop.putHTML("network.unit.name", sb.getConfig(SwitchboardConstants.NETWORK_NAME, "")); prop.putHTML("network.unit.name", sb.getConfig(SwitchboardConstants.NETWORK_NAME, ""));
prop.putHTML("network.unit.description", sb.getConfig("network.unit.description", "")); prop.putHTML("network.unit.description", sb.getConfig("network.unit.description", ""));
prop.putHTML("network.unit.domain", sb.getConfig(SwitchboardConstants.NETWORK_DOMAIN, "")); prop.putHTML("network.unit.domain", sb.getConfig(SwitchboardConstants.NETWORK_DOMAIN, ""));
prop.putHTML("network.unit.dht", sb.getConfig(SwitchboardConstants.DHT_ENABLED, "")); prop.putHTML("network.unit.dht", sb.getConfig(SwitchboardConstants.NETWORK_UNIT_DHT, ""));
networkBootstrapLocations.remove(sb.getConfig("network.unit.definition", "")); networkBootstrapLocations.remove(sb.getConfig("network.unit.definition", ""));
int c = 0; int c = 0;
for ( final String s : networkBootstrapLocations ) { for ( final String s : networkBootstrapLocations ) {

@ -1039,7 +1039,7 @@ public class YaCyDefaultServlet extends HttpServlet {
templatePatterns.put("simpleheadernavbar", sb.getConfig("decoration.simpleheadernavbar", "navbar-default")); templatePatterns.put("simpleheadernavbar", sb.getConfig("decoration.simpleheadernavbar", "navbar-default"));
// add navigation keys to enable or disable menu items // add navigation keys to enable or disable menu items
templatePatterns.put("navigation-p2p", sb.getConfigBool(SwitchboardConstants.DHT_ENABLED, true) || !sb.isRobinsonMode() ? 1 : 0); templatePatterns.put("navigation-p2p", sb.getConfigBool(SwitchboardConstants.NETWORK_UNIT_DHT, true) || !sb.isRobinsonMode() ? 1 : 0);
templatePatterns.put("navigation-p2p_authorized", authorized ? 1 : 0); templatePatterns.put("navigation-p2p_authorized", authorized ? 1 : 0);
String submitted = sb.getConfig("server.servlets.submitted", ""); String submitted = sb.getConfig("server.servlets.submitted", "");
boolean crawler_enabled = true; /* boolean crawler_enabled = true; /*

@ -633,6 +633,8 @@ public final class Switchboard extends serverSwitch {
partitionExponent, partitionExponent,
false, false,
this.exceed134217727); this.exceed134217727);
String agent = getConfig(SwitchboardConstants.NETWORK_UNIT_AGENT, "");
if (!agent.isEmpty()) this.peers.setMyName(agent); // this can thus be set using the environment variable yacy.network.unit.agent
this.localpeers = Collections.newSetFromMap(new ConcurrentHashMap<>()); this.localpeers = Collections.newSetFromMap(new ConcurrentHashMap<>());
new OneTimeBusyThread("Switchboard.scanForOtherYaCyInIntranet") { new OneTimeBusyThread("Switchboard.scanForOtherYaCyInIntranet") {
@Override @Override
@ -3473,7 +3475,7 @@ public final class Switchboard extends serverSwitch {
condenser, condenser,
searchEvent, searchEvent,
sourceName, sourceName,
getConfigBool(SwitchboardConstants.DHT_ENABLED, false), getConfigBool(SwitchboardConstants.NETWORK_UNIT_DHT, false),
this.getConfigBool(SwitchboardConstants.PROXY_TRANSPARENT_PROXY, false) ? "http://127.0.0.1:" + sb.getConfigInt(SwitchboardConstants.SERVER_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)); this.getConfig("crawler.http.acceptLanguage", null));
final RSSFeed feed = final RSSFeed feed =
@ -4142,7 +4144,7 @@ public final class Switchboard extends serverSwitch {
if ( this.peers.noDHTActivity() ) { if ( this.peers.noDHTActivity() ) {
return "no DHT distribution: network too small"; return "no DHT distribution: network too small";
} }
if ( !getConfigBool(SwitchboardConstants.DHT_ENABLED, true) ) { if ( !getConfigBool(SwitchboardConstants.NETWORK_UNIT_DHT, true) ) {
return "no DHT distribution: disabled by network.unit.dht"; return "no DHT distribution: disabled by network.unit.dht";
} }
if ( getConfig(SwitchboardConstants.INDEX_DIST_ALLOW, "false").equalsIgnoreCase("false") ) { if ( getConfig(SwitchboardConstants.INDEX_DIST_ALLOW, "false").equalsIgnoreCase("false") ) {

@ -268,8 +268,8 @@ public final class SwitchboardConstants {
public static final String REFERRER_META_POLICY_DEFAULT = "origin-when-cross-origin"; public static final String REFERRER_META_POLICY_DEFAULT = "origin-when-cross-origin";
public static final String DHT_ENABLED = "network.unit.dht"; public static final String NETWORK_UNIT_DHT = "network.unit.dht";
public static final String NETWORK_UNIT_AGENT = "network.unit.agent";
public static final String REMOTESEARCH_MAXCOUNT_DEFAULT = "network.unit.remotesearch.maxcount"; public static final String REMOTESEARCH_MAXCOUNT_DEFAULT = "network.unit.remotesearch.maxcount";
public static final String REMOTESEARCH_MAXTIME_DEFAULT = "network.unit.remotesearch.maxtime"; public static final String REMOTESEARCH_MAXTIME_DEFAULT = "network.unit.remotesearch.maxtime";
public static final String REMOTESEARCH_MAXCOUNT_USER = "remotesearch.maxcount"; public static final String REMOTESEARCH_MAXCOUNT_USER = "remotesearch.maxcount";

@ -77,8 +77,7 @@ public class serverSwitch {
private ConcurrentMap<String, Integer> upnpPortMap = new ConcurrentHashMap<>(); private ConcurrentMap<String, Integer> upnpPortMap = new ConcurrentHashMap<>();
private boolean isConnectedViaUpnp; private boolean isConnectedViaUpnp;
public serverSwitch(final File dataPath, final File appPath, public serverSwitch(final File dataPath, final File appPath, final String initPath, final String configPath) {
final String initPath, final String configPath) {
// we initialize the switchboard with a property file, // we initialize the switchboard with a property file,
// but maintain these properties then later in a new 'config' file // but maintain these properties then later in a new 'config' file
// to reset all changed configs, the config file must // to reset all changed configs, the config file must
@ -87,13 +86,10 @@ public class serverSwitch {
// file name of the config file // file name of the config file
this.dataPath = dataPath; this.dataPath = dataPath;
this.appPath = appPath; this.appPath = appPath;
this.configComment = "This is an automatically generated file, updated by serverAbstractSwitch and initialized by " this.configComment = "This is an automatically generated file, updated by serverAbstractSwitch and initialized by " + initPath;
+ initPath;
final File initFile = new File(appPath, initPath); final File initFile = new File(appPath, initPath);
this.configFile = new File(dataPath, configPath); // propertiesFile(config); this.configFile = new File(dataPath, configPath); // propertiesFile(config);
this.firstInit = !this.configFile.exists(); // this is true if the this.firstInit = !this.configFile.exists(); // this is true if the application was started for the first time
// application was started
// for the first time
new File(this.configFile.getParent()).mkdir(); new File(this.configFile.getParent()).mkdir();
// predefine init's // predefine init's
@ -111,6 +107,15 @@ public class serverSwitch {
this.configProps = new ConcurrentHashMap<String, String>(); this.configProps = new ConcurrentHashMap<String, String>();
} }
// overwrite configs with values from environment variables that start with "yacy_"
Properties sysprops = System.getProperties();
sysprops.forEach((key, value) -> {
String k = (String) key;
if (k.startsWith("yacy.")) {
this.configProps.put(k.substring(5), (String) value);
}
});
// remove all values from config that do not appear in init // remove all values from config that do not appear in init
this.configRemoved = new ConcurrentHashMap<String, String>(); this.configRemoved = new ConcurrentHashMap<String, String>();
Iterator<String> i = this.configProps.keySet().iterator(); Iterator<String> i = this.configProps.keySet().iterator();

@ -194,7 +194,6 @@ public final class yacy {
ConcurrentLog.config("STARTUP", "Maximum file system path length: " + OS.maxPathLength); ConcurrentLog.config("STARTUP", "Maximum file system path length: " + OS.maxPathLength);
f = new File(dataHome, "DATA/yacy.running"); f = new File(dataHome, "DATA/yacy.running");
final String conf = "DATA/SETTINGS/yacy.conf".replace("/", File.separator);
if (!f.createNewFile()) ConcurrentLog.severe("STARTUP", "WARNING: the file " + f + " can not be created!"); if (!f.createNewFile()) ConcurrentLog.severe("STARTUP", "WARNING: the file " + f + " can not be created!");
try { new FileOutputStream(f).write(Integer.toString(OS.getPID()).getBytes()); } catch (final Exception e) { } // write PID try { new FileOutputStream(f).write(Integer.toString(OS.getPID()).getBytes()); } catch (final Exception e) { } // write PID
f.deleteOnExit(); f.deleteOnExit();
@ -205,6 +204,7 @@ public final class yacy {
lock = channel.tryLock(); // lock yacy.running lock = channel.tryLock(); // lock yacy.running
} catch (final Exception e) { } } catch (final Exception e) { }
final String conf = "DATA/SETTINGS/yacy.conf".replace("/", File.separator);
try { try {
sb = new Switchboard(dataHome, appHome, "defaults/yacy.init".replace("/", File.separator), conf); sb = new Switchboard(dataHome, appHome, "defaults/yacy.init".replace("/", File.separator), conf);
} catch (final RuntimeException e) { } catch (final RuntimeException e) {

Loading…
Cancel
Save