forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p.0971' (head 6cb629b61e0177deda1e539b2f85a2473f3af7fb)
to branch 'i2p.i2p' (head 8e86ef70afbbbbdc2db06cec34f17dedd528c7e7)
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
|
@ -7,8 +7,8 @@ import java.util.Map;
|
||||
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.transport.FIFOBandwidthRefiller;
|
||||
import net.i2p.router.transport.TransportImpl;
|
||||
import net.i2p.router.transport.TransportManager;
|
||||
import net.i2p.router.transport.TransportUtil;
|
||||
import net.i2p.router.transport.udp.UDPTransport;
|
||||
import net.i2p.router.web.ConfigServiceHandler;
|
||||
import net.i2p.util.Addresses;
|
||||
@ -17,6 +17,7 @@ import net.i2p.util.Addresses;
|
||||
* Handler to deal with form submissions from the main config form and act
|
||||
* upon the values.
|
||||
*
|
||||
* Used for both /config and /confignet
|
||||
*/
|
||||
public class ConfigNetHandler extends FormHandler {
|
||||
private String _hostname;
|
||||
@ -45,6 +46,7 @@ public class ConfigNetHandler extends FormHandler {
|
||||
private String _sharePct;
|
||||
private boolean _ratesOnly;
|
||||
private boolean _udpDisabled;
|
||||
private String _ipv6Mode;
|
||||
private final Map<String, String> changes = new HashMap();
|
||||
private static final String PROP_HIDDEN = Router.PROP_HIDDEN_HIDDEN; // see Router for other choice
|
||||
|
||||
@ -130,6 +132,11 @@ public class ConfigNetHandler extends FormHandler {
|
||||
_udpDisabled = true;
|
||||
}
|
||||
|
||||
/** @since IPv6 */
|
||||
public void setIpv6(String mode) {
|
||||
_ipv6Mode = mode;
|
||||
}
|
||||
|
||||
private void recheckReachability() {
|
||||
_context.commSystem().recheckReachability();
|
||||
addFormNotice(_("Rechecking router reachability..."));
|
||||
@ -177,6 +184,26 @@ public class ConfigNetHandler extends FormHandler {
|
||||
restartRequired = true;
|
||||
}
|
||||
}
|
||||
if (_ipv6Mode != null) {
|
||||
// take care not to set default, as it will change
|
||||
String tcp6 = _context.getProperty(TransportUtil.NTCP_IPV6_CONFIG);
|
||||
if (tcp6 == null)
|
||||
tcp6 = TransportUtil.DEFAULT_IPV6_CONFIG.toConfigString();
|
||||
String udp6 = _context.getProperty(TransportUtil.SSU_IPV6_CONFIG);
|
||||
if (udp6 == null)
|
||||
udp6 = TransportUtil.DEFAULT_IPV6_CONFIG.toConfigString();
|
||||
boolean ch = false;
|
||||
if (!_ipv6Mode.equals(tcp6)) {
|
||||
changes.put(TransportUtil.NTCP_IPV6_CONFIG, _ipv6Mode);
|
||||
ch = true;
|
||||
}
|
||||
if (!_ipv6Mode.equals(udp6)) {
|
||||
changes.put(TransportUtil.SSU_IPV6_CONFIG, _ipv6Mode);
|
||||
ch = true;
|
||||
}
|
||||
if (ch)
|
||||
addFormNotice(_("Updating IPv6 setting"));
|
||||
}
|
||||
|
||||
// NTCP Settings
|
||||
// Normalize some things to make the following code a little easier...
|
||||
@ -370,7 +397,8 @@ public class ConfigNetHandler extends FormHandler {
|
||||
addFormError(_("Invalid address") + ": " + addr);
|
||||
return false;
|
||||
}
|
||||
boolean rv = TransportImpl.isPubliclyRoutable(iab);
|
||||
// TODO set IPv6 arg based on configuration?
|
||||
boolean rv = TransportUtil.isPubliclyRoutable(iab, true);
|
||||
if (!rv)
|
||||
addFormError(_("The hostname or IP {0} is not publicly routable", addr));
|
||||
return rv;
|
||||
|
@ -7,12 +7,15 @@ import net.i2p.data.RouterAddress;
|
||||
import net.i2p.router.CommSystemFacade;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.transport.TransportManager;
|
||||
import net.i2p.router.transport.udp.UDPAddress;
|
||||
import net.i2p.router.transport.TransportUtil;
|
||||
import net.i2p.router.transport.udp.UDPTransport;
|
||||
import net.i2p.util.Addresses;
|
||||
|
||||
/**
|
||||
*
|
||||
* Used for both /config and /confignet
|
||||
*/
|
||||
public class ConfigNetHelper extends HelperBase {
|
||||
public ConfigNetHelper() {}
|
||||
|
||||
/** copied from various private components */
|
||||
public final static String PROP_I2NP_NTCP_HOSTNAME = "i2np.ntcp.hostname";
|
||||
@ -20,6 +23,7 @@ public class ConfigNetHelper extends HelperBase {
|
||||
public final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoport";
|
||||
public final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoip";
|
||||
private final static String CHECKED = " checked=\"checked\" ";
|
||||
|
||||
public String getUdphostname() {
|
||||
return _context.getProperty(UDPTransport.PROP_EXTERNAL_HOST, "");
|
||||
}
|
||||
@ -32,22 +36,15 @@ public class ConfigNetHelper extends HelperBase {
|
||||
return _context.getProperty(PROP_I2NP_NTCP_PORT, "");
|
||||
}
|
||||
|
||||
public String getUdpAddress() {
|
||||
RouterAddress addr = _context.router().getRouterInfo().getTargetAddress("SSU");
|
||||
if (addr == null)
|
||||
return _("unknown");
|
||||
UDPAddress ua = new UDPAddress(addr);
|
||||
return ua.toString();
|
||||
}
|
||||
|
||||
/** @return host or "unknown" */
|
||||
public String getUdpIP() {
|
||||
RouterAddress addr = _context.router().getRouterInfo().getTargetAddress("SSU");
|
||||
if (addr == null)
|
||||
return _("unknown");
|
||||
UDPAddress ua = new UDPAddress(addr);
|
||||
if (ua.getHost() == null)
|
||||
String rv = addr.getHost();
|
||||
if (rv == null)
|
||||
return _("unknown");
|
||||
return ua.getHost();
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,6 +157,23 @@ public class ConfigNetHelper extends HelperBase {
|
||||
return CHECKED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Combined SSU/NTCP
|
||||
* Use SSU setting, then NTCP setting, then default
|
||||
* @since IPv6
|
||||
*/
|
||||
public String getIPv6Checked(String mode) {
|
||||
String s = _context.getProperty(TransportUtil.SSU_IPV6_CONFIG);
|
||||
if (s == null) {
|
||||
s = _context.getProperty(TransportUtil.NTCP_IPV6_CONFIG);
|
||||
if (s == null)
|
||||
s = TransportUtil.DEFAULT_IPV6_CONFIG.toConfigString();
|
||||
}
|
||||
if (s.equals(mode))
|
||||
return CHECKED;
|
||||
return "";
|
||||
}
|
||||
|
||||
public String[] getAddresses() {
|
||||
ArrayList<String> al = new ArrayList(Addresses.getAddresses());
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.RouterVersion;
|
||||
import net.i2p.router.TunnelPoolSettings;
|
||||
import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
|
||||
import net.i2p.router.transport.ntcp.NTCPAddress;
|
||||
import net.i2p.router.transport.TransportUtil;
|
||||
import net.i2p.stat.Rate;
|
||||
import net.i2p.stat.RateStat;
|
||||
import net.i2p.util.PortMapper;
|
||||
@ -159,7 +159,8 @@ public class SummaryHelper extends HelperBase {
|
||||
switch (status) {
|
||||
case CommSystemFacade.STATUS_OK:
|
||||
RouterAddress ra = routerInfo.getTargetAddress("NTCP");
|
||||
if (ra == null || (new NTCPAddress(ra)).isPubliclyRoutable())
|
||||
// TODO set IPv6 arg based on configuration?
|
||||
if (ra == null || TransportUtil.isPubliclyRoutable(ra.getIP(), true))
|
||||
return _("OK");
|
||||
return _("ERR-Private TCP Address");
|
||||
case CommSystemFacade.STATUS_DIFFERENT:
|
||||
|
Reference in New Issue
Block a user