forked from I2P_Developers/i2p.i2p
Compare commits
3 Commits
i2p.i2p.2.
...
plugin-con
Author | SHA1 | Date | |
---|---|---|---|
48e40e2fd2 | |||
0469bf3c27 | |||
db98b6b0f5 |
@ -9,6 +9,8 @@ import java.util.Properties;
|
|||||||
import net.i2p.router.RouterContext;
|
import net.i2p.router.RouterContext;
|
||||||
import net.i2p.router.web.PluginStarter;
|
import net.i2p.router.web.PluginStarter;
|
||||||
import net.i2p.update.*;
|
import net.i2p.update.*;
|
||||||
|
import net.i2p.util.Log;
|
||||||
|
import net.i2p.util.SystemVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for or download an updated version of a plugin.
|
* Check for or download an updated version of a plugin.
|
||||||
@ -27,12 +29,14 @@ import net.i2p.update.*;
|
|||||||
class PluginUpdateHandler implements Checker, Updater {
|
class PluginUpdateHandler implements Checker, Updater {
|
||||||
private final RouterContext _context;
|
private final RouterContext _context;
|
||||||
private final ConsoleUpdateManager _mgr;
|
private final ConsoleUpdateManager _mgr;
|
||||||
|
private final Log _log;
|
||||||
|
|
||||||
public PluginUpdateHandler(RouterContext ctx, ConsoleUpdateManager mgr) {
|
public PluginUpdateHandler(RouterContext ctx, ConsoleUpdateManager mgr) {
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
|
_log = _context.logManager().getLog(PluginUpdateHandler.class);
|
||||||
_mgr = mgr;
|
_mgr = mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** check a single plugin */
|
/** check a single plugin */
|
||||||
@Override
|
@Override
|
||||||
public UpdateTask check(UpdateType type, UpdateMethod method,
|
public UpdateTask check(UpdateType type, UpdateMethod method,
|
||||||
@ -48,6 +52,10 @@ class PluginUpdateHandler implements Checker, Updater {
|
|||||||
xpi2pURL = props.getProperty("updateURL");
|
xpi2pURL = props.getProperty("updateURL");
|
||||||
List<URI> updateSources = null;
|
List<URI> updateSources = null;
|
||||||
if (xpi2pURL != null) {
|
if (xpi2pURL != null) {
|
||||||
|
xpi2pURL = xpi2pURL.replace("$OS", SystemVersion.getOS());
|
||||||
|
xpi2pURL = xpi2pURL.replace("$ARCH", SystemVersion.getArch());
|
||||||
|
if (_log.shouldLog(Log.INFO))
|
||||||
|
_log.info("Checking for updates for " + appName + ": " + xpi2pURL);
|
||||||
try {
|
try {
|
||||||
updateSources = Collections.singletonList(new URI(xpi2pURL));
|
updateSources = Collections.singletonList(new URI(xpi2pURL));
|
||||||
} catch (URISyntaxException use) {}
|
} catch (URISyntaxException use) {}
|
||||||
@ -61,7 +69,7 @@ class PluginUpdateHandler implements Checker, Updater {
|
|||||||
UpdateRunner update = new PluginUpdateChecker(_context, _mgr, updateSources, appName, oldVersion);
|
UpdateRunner update = new PluginUpdateChecker(_context, _mgr, updateSources, appName, oldVersion);
|
||||||
return update;
|
return update;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** download a single plugin */
|
/** download a single plugin */
|
||||||
@Override
|
@Override
|
||||||
public UpdateTask update(UpdateType type, UpdateMethod method, List<URI> updateSources,
|
public UpdateTask update(UpdateType type, UpdateMethod method, List<URI> updateSources,
|
||||||
@ -83,4 +91,4 @@ class PluginUpdateHandler implements Checker, Updater {
|
|||||||
return update;
|
return update;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,6 +838,8 @@ public class PluginStarter implements Runnable {
|
|||||||
argVal[i] = argVal[i].replace("$I2P", ctx.getBaseDir().getAbsolutePath());
|
argVal[i] = argVal[i].replace("$I2P", ctx.getBaseDir().getAbsolutePath());
|
||||||
argVal[i] = argVal[i].replace("$CONFIG", ctx.getConfigDir().getAbsolutePath());
|
argVal[i] = argVal[i].replace("$CONFIG", ctx.getConfigDir().getAbsolutePath());
|
||||||
argVal[i] = argVal[i].replace("$PLUGIN", pluginDir.getAbsolutePath());
|
argVal[i] = argVal[i].replace("$PLUGIN", pluginDir.getAbsolutePath());
|
||||||
|
argVal[i] = argVal[i].replace("$OS", SystemVersion.getOS());
|
||||||
|
argVal[i] = argVal[i].replace("$ARCH", SystemVersion.getArch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClientApp ca = ctx.routerAppManager().getClientApp(app.className, argVal);
|
ClientApp ca = ctx.routerAppManager().getClientApp(app.className, argVal);
|
||||||
@ -877,6 +879,8 @@ public class PluginStarter implements Runnable {
|
|||||||
argVal[i] = argVal[i].replace("$I2P", ctx.getBaseDir().getAbsolutePath());
|
argVal[i] = argVal[i].replace("$I2P", ctx.getBaseDir().getAbsolutePath());
|
||||||
argVal[i] = argVal[i].replace("$CONFIG", ctx.getConfigDir().getAbsolutePath());
|
argVal[i] = argVal[i].replace("$CONFIG", ctx.getConfigDir().getAbsolutePath());
|
||||||
argVal[i] = argVal[i].replace("$PLUGIN", pluginDir.getAbsolutePath());
|
argVal[i] = argVal[i].replace("$PLUGIN", pluginDir.getAbsolutePath());
|
||||||
|
argVal[i] = argVal[i].replace("$OS", SystemVersion.getOS());
|
||||||
|
argVal[i] = argVal[i].replace("$ARCH", SystemVersion.getArch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -887,6 +891,8 @@ public class PluginStarter implements Runnable {
|
|||||||
cp = cp.replace("$I2P", ctx.getBaseDir().getAbsolutePath());
|
cp = cp.replace("$I2P", ctx.getBaseDir().getAbsolutePath());
|
||||||
cp = cp.replace("$CONFIG", ctx.getConfigDir().getAbsolutePath());
|
cp = cp.replace("$CONFIG", ctx.getConfigDir().getAbsolutePath());
|
||||||
cp = cp.replace("$PLUGIN", pluginDir.getAbsolutePath());
|
cp = cp.replace("$PLUGIN", pluginDir.getAbsolutePath());
|
||||||
|
cp = cp.replace("$OS", SystemVersion.getOS());
|
||||||
|
cp = cp.replace("$ARCH", SystemVersion.getArch());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Old way - add for the whole JVM
|
// Old way - add for the whole JVM
|
||||||
|
@ -117,6 +117,56 @@ public abstract class SystemVersion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the OS of the system running I2P as a lower-case string
|
||||||
|
* for reference in clients.config and plugin.config files.
|
||||||
|
*
|
||||||
|
* matches the conventions of the Go cross compiler
|
||||||
|
*
|
||||||
|
* @return the OS of the system running I2P as a lower-case string
|
||||||
|
* @since 0.9.53
|
||||||
|
*/
|
||||||
|
public static String getOS() {
|
||||||
|
if (isWindows())
|
||||||
|
return "windows";
|
||||||
|
if (isMac())
|
||||||
|
return "mac";
|
||||||
|
if (isGNU())
|
||||||
|
return "linux"; /* actually... */
|
||||||
|
if (isLinuxService())
|
||||||
|
return "linux";
|
||||||
|
if (isAndroid())
|
||||||
|
return "android";
|
||||||
|
/** Everybody else knows if they're on a Windows machine or a
|
||||||
|
* Mac, so for now, assume linux here.
|
||||||
|
*/
|
||||||
|
return "linux";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the architecture of the system running I2P as a string
|
||||||
|
* for reference in clients.config and plugin.config files.
|
||||||
|
*
|
||||||
|
* matches the conventions of the Go cross compiler
|
||||||
|
*
|
||||||
|
* @return the architecture of the system running I2P as a string
|
||||||
|
* @since 0.9.53
|
||||||
|
*/
|
||||||
|
public static String getArch() {
|
||||||
|
if (is64Bit()){
|
||||||
|
if (isARM())
|
||||||
|
return "arm64";
|
||||||
|
if (isX86())
|
||||||
|
return "amd64";
|
||||||
|
}
|
||||||
|
if (isARM())
|
||||||
|
return "arm";
|
||||||
|
if (isX86())
|
||||||
|
return "386";
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isWindows() {
|
public static boolean isWindows() {
|
||||||
return _isWin;
|
return _isWin;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user