Minor change in routerconsole and core code for making I2P work great

in "portable" mode.
This commit is contained in:
meeh
2018-06-30 13:07:41 +00:00
parent d8cc2a3560
commit 3de1fa2295
2 changed files with 33 additions and 15 deletions

View File

@ -6,10 +6,7 @@ import java.io.FileFilter;
import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.Inet4Address;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@ -410,8 +407,26 @@ public class RouterConsoleRunner implements RouterApp {
if (!workDirCreated)
System.err.println("ERROR: Unable to create Jetty temporary work directory");
// NOTE
// This code was added by Meeh @ 22 Apr 2018 for use in the browser bundle.
// In the case of a portable mode, the jar in question isn't routerconsole.jar but itself.
String isPortableStr = System.getProperty("i2p.dir.portableMode");
boolean isPortable = Boolean.parseBoolean(isPortableStr);
String routerConsoleJar = "";
// so Jetty can find WebAppConfiguration
System.setProperty("jetty.class.path", _context.getBaseDir() + "/lib/routerconsole.jar");
if (isPortable) {
try {
routerConsoleJar = new File(RouterConsoleRunner.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getAbsolutePath();
} catch (URISyntaxException e) {
// This shouln't be able to happen.
System.err.println("ERROR: Fatal portable error, can't locate where I (jarfile) am.");
return; // Yes, cancel at this point.
}
} else {
routerConsoleJar = _context.getBaseDir() + "/lib/routerconsole.jar";
}
System.setProperty("jetty.class.path", routerConsoleJar);
// FIXME
// http://dev.eclipse.org/mhonarc/lists/jetty-users/msg03487.html
//_server.setGracefulShutdown(1000);

View File

@ -322,16 +322,19 @@ public class I2PAppContext {
} else {
_appDir = _routerDir;
}
/******
(new Exception("Initialized by")).printStackTrace();
System.err.println("Base directory: " + _baseDir.getAbsolutePath());
System.err.println("Config directory: " + _configDir.getAbsolutePath());
System.err.println("Router directory: " + _routerDir.getAbsolutePath());
System.err.println("App directory: " + _appDir.getAbsolutePath());
System.err.println("Log directory: " + _logDir.getAbsolutePath());
System.err.println("PID directory: " + _pidDir.getAbsolutePath());
System.err.println("Temp directory: " + getTempDir().getAbsolutePath());
******/
String isPortableStr = System.getProperty("i2p.dir.portableMode");
boolean isPortable = Boolean.parseBoolean(isPortableStr);
if (isPortable) {
// In portable we like debug information :)
//(new Exception("Initialized by")).printStackTrace();
System.err.println("Base directory: " + _baseDir.getAbsolutePath());
System.err.println("Config directory: " + _configDir.getAbsolutePath());
System.err.println("Router directory: " + _routerDir.getAbsolutePath());
System.err.println("App directory: " + _appDir.getAbsolutePath());
System.err.println("Log directory: " + _logDir.getAbsolutePath());
System.err.println("PID directory: " + _pidDir.getAbsolutePath());
System.err.println("Temp directory: " + getTempDir().getAbsolutePath());
}
if (doInit) {
// Bad practice, sets a static field to this in constructor.