forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p.zzz.ipv6' (head 5c147c6e394fae03752dcf497923a90e3f2db529)
to branch 'i2p.i2p' (head 7af6987d5546664f76589afe0cbeeb780f4b5d58)
This commit is contained in:
@ -97,7 +97,7 @@
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="jar1" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
|
||||
<target name="jar1" depends="compile, bundle-news, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
|
||||
<!-- set if unset -->
|
||||
<property name="workspace.changes.j.tr" value="" />
|
||||
<jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class">
|
||||
@ -134,7 +134,6 @@
|
||||
<jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class" update="true" />
|
||||
</target>
|
||||
|
||||
|
||||
<target name="jarUpToDate">
|
||||
<uptodate property="jar.uptodate" targetfile="build/routerconsole.jar" >
|
||||
<srcfiles dir= "build/obj" includes="**/*.class" />
|
||||
@ -166,6 +165,44 @@
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="bundle-news" unless="no.bundle">
|
||||
<exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
|
||||
<arg value="./bundle-messages-news.sh" />
|
||||
</exec>
|
||||
<exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
|
||||
<arg value="./bundle-messages-news.sh" />
|
||||
</exec>
|
||||
<exec executable="sh" osfamily="windows" failifexecutionfails="false" >
|
||||
<arg value="./bundle-messages-news.sh" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="extractProxyTags">
|
||||
<java classname="net.i2p.util.TranslateReader" fork="true" failonerror="true">
|
||||
<classpath>
|
||||
<pathelement location="../../../build/i2p.jar" />
|
||||
</classpath>
|
||||
<arg value="tag" />
|
||||
<arg value="../../../installer/resources/initialNews/initialNews.xml" />
|
||||
<arg value="build/News.java" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="poupdate-news" depends="extractProxyTags">
|
||||
<exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="true" >
|
||||
<arg value="./bundle-messages-news.sh" />
|
||||
<arg value="-p" />
|
||||
</exec>
|
||||
<exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="true" >
|
||||
<arg value="./bundle-messages-news.sh" />
|
||||
<arg value="-p" />
|
||||
</exec>
|
||||
<exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
|
||||
<arg value="./bundle-messages-news.sh" />
|
||||
<arg value="-p" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="listChangedFiles2" depends="warUpToDate" if="shouldListChanges2" >
|
||||
<exec executable="mtn" outputproperty="workspace.changes.w" errorproperty="mtn.error2" failifexecutionfails="false" >
|
||||
<arg value="list" />
|
||||
|
110
apps/routerconsole/java/bundle-messages-news.sh
Executable file
110
apps/routerconsole/java/bundle-messages-news.sh
Executable file
@ -0,0 +1,110 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Update messages_xx.po and messages_xx.class files,
|
||||
# from both java and jsp sources.
|
||||
# Requires installed programs xgettext, msgfmt, msgmerge, and find.
|
||||
#
|
||||
# usage:
|
||||
# bundle-messages.sh (generates the resource bundle from the .po file)
|
||||
# bundle-messages.sh -p (updates the .po file from the source tags, then generates the resource bundle)
|
||||
#
|
||||
# zzz - public domain
|
||||
#
|
||||
CLASS=net.i2p.router.news.messages
|
||||
TMPFILE=build/javafiles-news.txt
|
||||
export TZ=UTC
|
||||
RC=0
|
||||
|
||||
if [ "$1" = "-p" ]
|
||||
then
|
||||
POUPDATE=1
|
||||
fi
|
||||
|
||||
# on windows, one must specify the path of commnad find
|
||||
# since windows has its own retarded version of find.
|
||||
if which find|grep -q -i windows ; then
|
||||
export PATH=.:/bin:/usr/local/bin:$PATH
|
||||
fi
|
||||
# Fast mode - update ondemond
|
||||
# set LG2 to the language you need in envrionment varibales to enable this
|
||||
|
||||
# add ../java/ so the refs will work in the po file
|
||||
JPATHS="../java/build/News.java"
|
||||
for i in ../locale-news/messages_*.po
|
||||
do
|
||||
# get language
|
||||
LG=${i#../locale-news/messages_}
|
||||
LG=${LG%.po}
|
||||
|
||||
# skip, if specified
|
||||
if [ $LG2 ]; then
|
||||
[ $LG != $LG2 ] && continue || echo INFO: Language update is set to [$LG2] only.
|
||||
fi
|
||||
|
||||
if [ "$POUPDATE" = "1" ]
|
||||
then
|
||||
# make list of java files newer than the .po file
|
||||
find $JPATHS -name *.java -newer $i > $TMPFILE
|
||||
fi
|
||||
if [ -s build/obj/net/i2p/router/news/messages_$LG.class -a \
|
||||
build/obj/net/i2p/router/news/messages_$LG.class -nt $i -a \
|
||||
! -s $TMPFILE ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$POUPDATE" = "1" ]
|
||||
then
|
||||
echo "Updating the $i file from the tags..."
|
||||
# extract strings from java and jsp files, and update messages.po files
|
||||
# translate calls must be one of the forms:
|
||||
# _("foo")
|
||||
# _x("foo")
|
||||
# intl._("foo")
|
||||
# intl.title("foo")
|
||||
# In a jsp, you must use a helper or handler that has the context set.
|
||||
# To start a new translation, copy the header from an old translation to the new .po file,
|
||||
# then ant distclean updater.
|
||||
find $JPATHS -name *.java > $TMPFILE
|
||||
xgettext -f $TMPFILE -L java --from-code=UTF-8 --no-location\
|
||||
--keyword=_ \
|
||||
-o ${i}t
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - xgettext failed on ${i}, not updating translations"
|
||||
rm -f ${i}t
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
msgmerge -U --backup=none $i ${i}t
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgmerge failed on ${i}, not updating translations"
|
||||
rm -f ${i}t
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
rm -f ${i}t
|
||||
# so we don't do this again
|
||||
touch $i
|
||||
fi
|
||||
|
||||
if [ "$LG" != "en" ]
|
||||
then
|
||||
# only generate for non-source language
|
||||
echo "Generating ${CLASS}_$LG ResourceBundle..."
|
||||
|
||||
# convert to class files in build/obj
|
||||
msgfmt --java --statistics -r $CLASS -l $LG -d build/obj $i
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "ERROR - msgfmt failed on ${i}, not updating translations"
|
||||
# msgfmt leaves the class file there so the build would work the next time
|
||||
find build/obj -name messages_${LG}.class -exec rm -f {} \;
|
||||
RC=1
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
rm -f $TMPFILE
|
||||
exit $RC
|
@ -30,14 +30,12 @@ import net.i2p.util.VersionComparator;
|
||||
* @since 0.7.12
|
||||
*/
|
||||
class PluginUpdateChecker extends UpdateRunner {
|
||||
private final ByteArrayOutputStream _baos;
|
||||
private final String _appName;
|
||||
private final String _oldVersion;
|
||||
|
||||
public PluginUpdateChecker(RouterContext ctx, ConsoleUpdateManager mgr,
|
||||
List<URI> uris, String appName, String oldVersion ) {
|
||||
super(ctx, mgr, uris);
|
||||
_baos = new ByteArrayOutputStream(TrustedUpdate.HEADER_BYTES);
|
||||
super(ctx, mgr, uris, oldVersion);
|
||||
if (!uris.isEmpty())
|
||||
_currentURI = uris.get(0);
|
||||
_appName = appName;
|
||||
@ -85,7 +83,10 @@ class PluginUpdateChecker extends UpdateRunner {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining,
|
||||
String url, String outputFile, boolean notModified) {
|
||||
super.transferComplete(alreadyTransferred, bytesTransferred, bytesRemaining,
|
||||
url, outputFile, notModified);
|
||||
// super sets _newVersion if newer
|
||||
boolean newer = _newVersion != null;
|
||||
if (newer) {
|
||||
|
@ -21,6 +21,7 @@ import net.i2p.update.*;
|
||||
import net.i2p.util.EepGet;
|
||||
import net.i2p.util.FileUtil;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.OrderedProperties;
|
||||
import net.i2p.util.SecureDirectory;
|
||||
import net.i2p.util.SecureFile;
|
||||
@ -147,7 +148,7 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
return;
|
||||
}
|
||||
File tempDir = new File(_context.getTempDir(), "tmp" + _context.random().nextInt() + "-unzip");
|
||||
if (!FileUtil.extractZip(to, tempDir)) {
|
||||
if (!FileUtil.extractZip(to, tempDir, Log.ERROR)) {
|
||||
f.delete();
|
||||
to.delete();
|
||||
FileUtil.rmdir(tempDir, false);
|
||||
@ -374,7 +375,7 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
}
|
||||
|
||||
// Finally, extract the zip to the plugin directory
|
||||
if (!FileUtil.extractZip(to, destDir)) {
|
||||
if (!FileUtil.extractZip(to, destDir, Log.WARN)) {
|
||||
to.delete();
|
||||
statusDone("<b>" + _("Failed to install plugin in {0}", destDir.getAbsolutePath()) + "</b>");
|
||||
return;
|
||||
|
@ -39,9 +39,10 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
||||
protected boolean _isPartial;
|
||||
/** set by the listeners on completion */
|
||||
protected String _newVersion;
|
||||
// 56 byte header, only used for suds
|
||||
private final ByteArrayOutputStream _baos;
|
||||
/** 56 byte header, only used for suds */
|
||||
protected final ByteArrayOutputStream _baos;
|
||||
protected URI _currentURI;
|
||||
private final String _currentVersion;
|
||||
|
||||
private static final String SIGNED_UPDATE_FILE = "i2pupdate.sud";
|
||||
|
||||
@ -49,7 +50,18 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
||||
protected static final long INACTIVITY_TIMEOUT = 5*60*1000;
|
||||
protected static final long NOPROXY_INACTIVITY_TIMEOUT = 60*1000;
|
||||
|
||||
/**
|
||||
* Uses router version for partial checks
|
||||
*/
|
||||
public UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, List<URI> uris) {
|
||||
this(ctx, mgr, uris, RouterVersion.VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param currentVersion used for partial checks
|
||||
* @since 0.9.7
|
||||
*/
|
||||
public UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, List<URI> uris, String currentVersion) {
|
||||
super("Update Runner");
|
||||
setDaemon(true);
|
||||
_context = ctx;
|
||||
@ -58,6 +70,7 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
||||
_urls = uris;
|
||||
_baos = new ByteArrayOutputStream(TrustedUpdate.HEADER_BYTES);
|
||||
_updateFile = (new File(ctx.getTempDir(), "update" + ctx.random().nextInt() + ".tmp")).getAbsolutePath();
|
||||
_currentVersion = currentVersion;
|
||||
}
|
||||
|
||||
//////// begin UpdateTask methods
|
||||
@ -184,7 +197,7 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
||||
if (_isPartial) {
|
||||
// Compare version with what we have now
|
||||
String newVersion = TrustedUpdate.getVersionString(new ByteArrayInputStream(_baos.toByteArray()));
|
||||
boolean newer = VersionComparator.comp(newVersion, RouterVersion.VERSION) > 0;
|
||||
boolean newer = VersionComparator.comp(newVersion, _currentVersion) > 0;
|
||||
if (newer) {
|
||||
_newVersion = newVersion;
|
||||
} else {
|
||||
|
@ -14,7 +14,7 @@ public class ConfigTunnelsHelper extends HelperBase {
|
||||
private static final String HOPS = ngettext("1 hop", "{0} hops");
|
||||
private static final String TUNNELS = ngettext("1 tunnel", "{0} tunnels");
|
||||
|
||||
private static final String PROP_ADVANCED = "routerconsole.advanced";
|
||||
static final String PROP_ADVANCED = "routerconsole.advanced";
|
||||
|
||||
public String getForm() {
|
||||
StringBuilder buf = new StringBuilder(1024);
|
||||
|
@ -1,6 +1,9 @@
|
||||
package net.i2p.router.web;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@ -8,6 +11,7 @@ import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.update.ConsoleUpdateManager;
|
||||
import static net.i2p.update.UpdateType.*;
|
||||
import net.i2p.util.TranslateReader;
|
||||
|
||||
/**
|
||||
* If news file does not exist, use file from the initialNews directory
|
||||
@ -138,11 +142,36 @@ public class NewsHelper extends ContentHelper {
|
||||
return mgr.getStatus();
|
||||
}
|
||||
|
||||
private static final String BUNDLE_NAME = "net.i2p.router.news.messages";
|
||||
|
||||
/**
|
||||
* If we haven't downloaded news yet, use the translated initial news file
|
||||
*/
|
||||
@Override
|
||||
public String getContent() {
|
||||
File news = new File(_page);
|
||||
if (!news.exists())
|
||||
if (!news.exists()) {
|
||||
_page = (new File(_context.getBaseDir(), "docs/initialNews/initialNews.xml")).getAbsolutePath();
|
||||
// don't use super, translate on-the-fly
|
||||
Reader reader = null;
|
||||
try {
|
||||
char[] buf = new char[512];
|
||||
StringBuilder out = new StringBuilder(2048);
|
||||
reader = new TranslateReader(_context, BUNDLE_NAME, new FileInputStream(_page));
|
||||
int len;
|
||||
while((len = reader.read(buf)) > 0) {
|
||||
out.append(buf, 0, len);
|
||||
}
|
||||
return out.toString();
|
||||
} catch (IOException ioe) {
|
||||
return "";
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null)
|
||||
reader.close();
|
||||
} catch (IOException foo) {}
|
||||
}
|
||||
}
|
||||
return super.getContent();
|
||||
}
|
||||
|
||||
|
@ -763,7 +763,7 @@ public class PluginStarter implements Runnable {
|
||||
/**
|
||||
* Returns <code>true</code> if one or more client threads are running in a given plugin.
|
||||
* @param pluginName
|
||||
* @return
|
||||
* @return true if running
|
||||
*/
|
||||
private static boolean isClientThreadRunning(String pluginName) {
|
||||
ThreadGroup group = pluginThreadGroups.get(pluginName);
|
||||
|
@ -39,8 +39,12 @@ public class TunnelRenderer {
|
||||
Map<Hash, TunnelPool> clientInboundPools = _context.tunnelManager().getInboundClientPools();
|
||||
Map<Hash, TunnelPool> clientOutboundPools = _context.tunnelManager().getOutboundClientPools();
|
||||
destinations = new ArrayList(clientInboundPools.keySet());
|
||||
boolean debug = _context.getBooleanProperty(ConfigTunnelsHelper.PROP_ADVANCED);
|
||||
for (int i = 0; i < destinations.size(); i++) {
|
||||
Hash client = destinations.get(i);
|
||||
boolean isLocal = _context.clientManager().isLocal(client);
|
||||
if ((!isLocal) && (!debug))
|
||||
continue;
|
||||
TunnelPool in = null;
|
||||
TunnelPool outPool = null;
|
||||
in = clientInboundPools.get(client);
|
||||
@ -53,7 +57,7 @@ public class TunnelRenderer {
|
||||
name = client.toBase64().substring(0,4);
|
||||
out.write("<h2><a name=\"" + client.toBase64().substring(0,4)
|
||||
+ "\" ></a>" + _("Client tunnels for") + ' ' + _(name));
|
||||
if (_context.clientManager().isLocal(client))
|
||||
if (isLocal)
|
||||
out.write(" (<a href=\"/configtunnels#" + client.toBase64().substring(0,4) +"\">" + _("configure") + "</a>)</h2>\n");
|
||||
else
|
||||
out.write(" (" + _("dead") + ")</h2>\n");
|
||||
|
Reference in New Issue
Block a user