forked from I2P_Developers/i2p.i2p
* Router: Move router.ping file from temp directory to config directory
This commit is contained in:
@ -67,7 +67,7 @@ public class I2PAppContext {
|
|||||||
/** the context that components without explicit root are bound */
|
/** the context that components without explicit root are bound */
|
||||||
protected static volatile I2PAppContext _globalAppContext;
|
protected static volatile I2PAppContext _globalAppContext;
|
||||||
|
|
||||||
protected I2PProperties _overrideProps;
|
protected final I2PProperties _overrideProps;
|
||||||
|
|
||||||
private StatManager _statManager;
|
private StatManager _statManager;
|
||||||
private SessionKeyManager _sessionKeyManager;
|
private SessionKeyManager _sessionKeyManager;
|
||||||
@ -85,6 +85,7 @@ public class I2PAppContext {
|
|||||||
private RandomSource _random;
|
private RandomSource _random;
|
||||||
private KeyGenerator _keyGenerator;
|
private KeyGenerator _keyGenerator;
|
||||||
protected KeyRing _keyRing; // overridden in RouterContext
|
protected KeyRing _keyRing; // overridden in RouterContext
|
||||||
|
private final ServiceDirectory _serviceDir;
|
||||||
private volatile boolean _statManagerInitialized;
|
private volatile boolean _statManagerInitialized;
|
||||||
private volatile boolean _sessionKeyManagerInitialized;
|
private volatile boolean _sessionKeyManagerInitialized;
|
||||||
private volatile boolean _namingServiceInitialized;
|
private volatile boolean _namingServiceInitialized;
|
||||||
@ -199,6 +200,7 @@ public class I2PAppContext {
|
|||||||
if (envProps != null)
|
if (envProps != null)
|
||||||
_overrideProps.putAll(envProps);
|
_overrideProps.putAll(envProps);
|
||||||
_shutdownTasks = new ConcurrentHashSet(32);
|
_shutdownTasks = new ConcurrentHashSet(32);
|
||||||
|
_serviceDir = new ServiceDirectory();
|
||||||
initializeDirs();
|
initializeDirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,10 +214,10 @@ public class I2PAppContext {
|
|||||||
* Base i2p.dir.base getBaseDir() lib/, webapps/, docs/, geoip/, licenses/, ...
|
* Base i2p.dir.base getBaseDir() lib/, webapps/, docs/, geoip/, licenses/, ...
|
||||||
* Temp i2p.dir.temp getTempDir() Temporary files
|
* Temp i2p.dir.temp getTempDir() Temporary files
|
||||||
* Config i2p.dir.config getConfigDir() *.config, hosts.txt, addressbook/, ...
|
* Config i2p.dir.config getConfigDir() *.config, hosts.txt, addressbook/, ...
|
||||||
* PID i2p.dir.pid getPIDDir() router.ping
|
|
||||||
*
|
*
|
||||||
* (the following all default to the same as Config)
|
* (the following all default to the same as Config)
|
||||||
*
|
*
|
||||||
|
* PID i2p.dir.pid getPIDDir() router.ping
|
||||||
* Router i2p.dir.router getRouterDir() netDb/, peerProfiles/, router.*, keyBackup/, ...
|
* Router i2p.dir.router getRouterDir() netDb/, peerProfiles/, router.*, keyBackup/, ...
|
||||||
* Log i2p.dir.log getLogDir() logs/
|
* Log i2p.dir.log getLogDir() logs/
|
||||||
* App i2p.dir.app getAppDir() eepsite/, ...
|
* App i2p.dir.app getAppDir() eepsite/, ...
|
||||||
@ -250,6 +252,7 @@ public class I2PAppContext {
|
|||||||
private void initializeDirs() {
|
private void initializeDirs() {
|
||||||
String s = getProperty("i2p.dir.base", System.getProperty("user.dir"));
|
String s = getProperty("i2p.dir.base", System.getProperty("user.dir"));
|
||||||
_baseDir = new File(s);
|
_baseDir = new File(s);
|
||||||
|
|
||||||
// config defaults to base
|
// config defaults to base
|
||||||
s = getProperty("i2p.dir.config");
|
s = getProperty("i2p.dir.config");
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
@ -259,6 +262,7 @@ public class I2PAppContext {
|
|||||||
} else {
|
} else {
|
||||||
_configDir = _baseDir;
|
_configDir = _baseDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
// router defaults to config
|
// router defaults to config
|
||||||
s = getProperty("i2p.dir.router");
|
s = getProperty("i2p.dir.router");
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
@ -268,11 +272,17 @@ public class I2PAppContext {
|
|||||||
} else {
|
} else {
|
||||||
_routerDir = _configDir;
|
_routerDir = _configDir;
|
||||||
}
|
}
|
||||||
// pid defaults to system temp directory
|
|
||||||
s = getProperty("i2p.dir.pid", System.getProperty("java.io.tmpdir"));
|
// pid defaults to router directory (as of 0.8.12, was system temp dir previously)
|
||||||
_pidDir = new File(s);
|
s = getProperty("i2p.dir.pid");
|
||||||
if (!_pidDir.exists())
|
if (s != null) {
|
||||||
_pidDir.mkdir();
|
_pidDir = new SecureDirectory(s);
|
||||||
|
if (!_pidDir.exists())
|
||||||
|
_pidDir.mkdir();
|
||||||
|
} else {
|
||||||
|
_pidDir = _routerDir;
|
||||||
|
}
|
||||||
|
|
||||||
// these all default to router
|
// these all default to router
|
||||||
s = getProperty("i2p.dir.log");
|
s = getProperty("i2p.dir.log");
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
@ -282,6 +292,7 @@ public class I2PAppContext {
|
|||||||
} else {
|
} else {
|
||||||
_logDir = _routerDir;
|
_logDir = _routerDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = getProperty("i2p.dir.app");
|
s = getProperty("i2p.dir.app");
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
_appDir = new SecureDirectory(s);
|
_appDir = new SecureDirectory(s);
|
||||||
@ -339,8 +350,9 @@ public class I2PAppContext {
|
|||||||
/**
|
/**
|
||||||
* Where router.ping goes.
|
* Where router.ping goes.
|
||||||
* Applications should not use this.
|
* Applications should not use this.
|
||||||
* The same as the system temp dir for now.
|
* The same as the router dir by default as of 0.8.12
|
||||||
* Which is a problem for multi-user installations.
|
* Was the same as the system temp dir prior to that.
|
||||||
|
* Which was a problem for multi-user installations.
|
||||||
* @since 0.7.6
|
* @since 0.7.6
|
||||||
* @return dir constant for the life of the context
|
* @return dir constant for the life of the context
|
||||||
*/
|
*/
|
||||||
|
@ -1555,7 +1555,7 @@ public class Router implements RouterClock.ClockShiftListener {
|
|||||||
*/
|
*/
|
||||||
private void beginMarkingLiveliness() {
|
private void beginMarkingLiveliness() {
|
||||||
File f = getPingFile();
|
File f = getPingFile();
|
||||||
SimpleScheduler.getInstance().addPeriodicEvent(new MarkLiveliness(this, f), 0, LIVELINESS_DELAY);
|
SimpleScheduler.getInstance().addPeriodicEvent(new MarkLiveliness(this, f), 0, LIVELINESS_DELAY - (5*1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String PROP_BANDWIDTH_SHARE_PERCENTAGE = "router.sharePercentage";
|
public static final String PROP_BANDWIDTH_SHARE_PERCENTAGE = "router.sharePercentage";
|
||||||
@ -1812,11 +1812,12 @@ private static class UpdateRoutingKeyModifierJob extends JobImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a timestamp to the ping file where the wrapper can see it
|
* Write a timestamp to the ping file where
|
||||||
|
* other routers trying to use the same configuration can see it
|
||||||
*/
|
*/
|
||||||
private static class MarkLiveliness implements SimpleTimer.TimedEvent {
|
private static class MarkLiveliness implements SimpleTimer.TimedEvent {
|
||||||
private Router _router;
|
private final Router _router;
|
||||||
private File _pingFile;
|
private final File _pingFile;
|
||||||
|
|
||||||
public MarkLiveliness(Router router, File pingFile) {
|
public MarkLiveliness(Router router, File pingFile) {
|
||||||
_router = router;
|
_router = router;
|
||||||
|
@ -117,9 +117,7 @@ public class RouterContext extends I2PAppContext {
|
|||||||
* @param value The new value for the property.
|
* @param value The new value for the property.
|
||||||
*/
|
*/
|
||||||
public void setProperty(String propName, String value) {
|
public void setProperty(String propName, String value) {
|
||||||
if(_overrideProps != null) {
|
|
||||||
_overrideProps.setProperty(propName, value);
|
_overrideProps.setProperty(propName, value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user