propagate from branch 'i2p.i2p.zzz.i2pcontrol' (head 1334d424003d201aa352cf57a6ba2f61241ef363)

to branch 'i2p.i2p' (head fe8a90fdbdd491e16040e3ed91a35faa72fd78f2)
This commit is contained in:
zzz
2019-01-28 15:10:30 +00:00
129 changed files with 51913 additions and 42676 deletions

View File

@ -429,6 +429,7 @@
<!-- these are to detect tomcat version and reproducible build setting -->
<jvmarg value="-Dbuild.reproducible=${build.reproducible}" />
<jvmarg value="-Dwith-libtomcat8-java=${with-libtomcat8-java}" />
<jvmarg value="-Dwith-libtomcat9-java=${with-libtomcat9-java}" />
<jvmarg value="-Djasper.jar=../../jetty/jettylib/jasper-runtime.jar" />
<classpath>
<pathelement location="../../jetty/jettylib/jasper-runtime.jar" />

View File

@ -85,6 +85,21 @@ public class MLabRunner {
* or null if there was already a test in progress.
*/
public ToolRun runNDT(final ToolListener listener) {
boolean useSSL = _context.getProperty(PROP_SSL, DEFAULT_USE_SSL);
return runNDT(listener, useSSL, null);
}
/**
* Non-blocking, spawns a thread and returns immediately.
*
* @param listener use to detect completion and get results
* @param use_SSL whether to use SSL to talk to the servers
* @param serverHost if non-null, bypass the name server and run test with this host
* @return a ToolRun object which may be used to cancel the test,
* or null if there was already a test in progress.
* @since 0.9.39
*/
public ToolRun runNDT(final ToolListener listener, final boolean use_SSL, final String serverHost) {
if (!_running.compareAndSet(false, true)) {
listener.reportSummary("Test already running");
listener.reportDetail("Test already running");
@ -113,52 +128,54 @@ public class MLabRunner {
// The first is to switch to our new name server, ns.measurementlab.net. For example: http://ns.measurementlab.net/ndt will return a JSON string with the closest NDT server. Example integration can be found on www.measurementlab.net/p/ndt.html
// The other option, discouraged, is to continue using donar which should still be resolving. It just uses ns.measurementlab.net on the backend now. However, this is currently down according to my tests, so we'll work on getting this back as soon as possible.
String server_host = null;
String server_host = serverHost;
String server_city = null;
String server_country = null;
boolean useSSL = _context.getProperty(PROP_SSL, DEFAULT_USE_SSL);
boolean useSSL = use_SSL;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
// http to name server
// public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort,
// int numRetries, long minSize, long maxSize, String outputFile, OutputStream outputStream,
// String url, boolean allowCaching, String etag, String postData) {
//EepGet eepget = new EepGet(_context, false, null, 0,
// 0, 2, 1024, null, baos,
// NS_URL, false, null, null);
// https to name server
String nsURL = useSSL ? NS_URL_SSL_SSL : NS_URL_SSL;
EepGet eepget = new SSLEepGet(_context, baos, nsURL);
boolean ok = eepget.fetch(NS_TIMEOUT, NS_TIMEOUT, NS_TIMEOUT);
if (!ok)
throw new IOException("ns fetch failed");
int code = eepget.getStatusCode();
if (code != 200)
throw new IOException("ns fetch failed: " + code);
JSONParser parser = new JSONParser();
byte[] b = baos.toByteArray();
String s = new String(b, "ISO-8859-1");
JSONObject map = (JSONObject) parser.parse(s);
if (map == null) {
throw new IOException("no map");
if (server_host == null) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
// http to name server
// public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort,
// int numRetries, long minSize, long maxSize, String outputFile, OutputStream outputStream,
// String url, boolean allowCaching, String etag, String postData) {
//EepGet eepget = new EepGet(_context, false, null, 0,
// 0, 2, 1024, null, baos,
// NS_URL, false, null, null);
// https to name server
String nsURL = useSSL ? NS_URL_SSL_SSL : NS_URL_SSL;
EepGet eepget = new SSLEepGet(_context, baos, nsURL);
boolean ok = eepget.fetch(NS_TIMEOUT, NS_TIMEOUT, NS_TIMEOUT);
if (!ok)
throw new IOException("ns fetch failed");
int code = eepget.getStatusCode();
if (code != 200)
throw new IOException("ns fetch failed: " + code);
JSONParser parser = new JSONParser();
byte[] b = baos.toByteArray();
String s = new String(b, "ISO-8859-1");
JSONObject map = (JSONObject) parser.parse(s);
if (map == null) {
throw new IOException("no map");
}
if (_log.shouldWarn())
_log.warn("Got response: " + DataHelper.getUTF8(b));
// TODO use IP instead to avoid another lookup? - no, won't work with ssl
// use "fqdn" in response instead of "url" since ndt_ssl does not have url
server_host = (String)map.get("fqdn");
if (server_host == null) {
throw new IOException("no fqdn");
}
server_city = (String) map.get("city");
server_country = (String) map.get("country");
// ignore the returned port in the URL (7123) which is the applet, not the control port
if (_log.shouldWarn())
_log.warn("Selected server: " + server_host);
} catch (Exception e) {
if (_log.shouldWarn())
_log.warn("Failed to get server", e);
}
if (_log.shouldWarn())
_log.warn("Got response: " + DataHelper.getUTF8(b));
// TODO use IP instead to avoid another lookup? - no, won't work with ssl
// use "fqdn" in response instead of "url" since ndt_ssl does not have url
server_host = (String)map.get("fqdn");
if (server_host == null) {
throw new IOException("no fqdn");
}
server_city = (String) map.get("city");
server_country = (String) map.get("country");
// ignore the returned port in the URL (7123) which is the applet, not the control port
if (_log.shouldWarn())
_log.warn("Selected server: " + server_host);
} catch (Exception e) {
if (_log.shouldWarn())
_log.warn("Failed to get server", e);
}
if (server_host == null) {
@ -171,7 +188,18 @@ public class MLabRunner {
String[] args = useSSL ? new String[] { "-s", server_host } : new String[] { server_host };
long start = System.currentTimeMillis();
final Tcpbw100 test = Tcpbw100.mainSupport(args);
final Tcpbw100 test;
try {
test = Tcpbw100.mainSupport(args);
} catch (IllegalArgumentException iae) {
String err = "Failed to connect to bandwidth test server " + server_host;
_log.error(err, iae);
if (listener != null) {
listener.reportSummary(err);
listener.reportDetail(err);
}
return;
}
final AtomicBoolean cancelled = new AtomicBoolean();
run.addListener(
@ -359,11 +387,17 @@ public class MLabRunner {
/** standalone test */
public static void main(String[] args) {
boolean useSSL = args.length > 0 && args[0].equals("-s");
System.setProperty(PROP_SSL, Boolean.toString(useSSL));
String host;
if (useSSL && args.length > 1)
host = args[1];
else if (!useSSL && args.length > 0)
host = args[0];
else
host = null;
I2PAppContext ctx = I2PAppContext.getGlobalContext();
MLabRunner mlab = MLabRunner.getInstance(ctx);
TestListener lsnr = new TestListener();
mlab.runNDT(lsnr);
mlab.runNDT(lsnr, useSSL, host);
try { Thread.sleep(2000); } catch (InterruptedException ie) { return; }
for (int i = 0; i < 180; i++) {
if (lsnr.isComplete())

View File

@ -21,11 +21,11 @@ import java.net.Socket;
public class OsfwWorker implements Runnable {
private ServerSocket _srvSocket;
private int _iTestTime;
private final ServerSocket _srvSocket;
private final int _iTestTime;
private boolean _iFinalized = false;
// local Tcpbw100 Applet reference
Tcpbw100 _localTcpAppObj;
private final Tcpbw100 _localTcpAppObj;
/**
* Constructor
@ -39,6 +39,7 @@ public class OsfwWorker implements Runnable {
OsfwWorker(ServerSocket srvSocketParam, int iParamTestTime) {
this._srvSocket = srvSocketParam;
this._iTestTime = iParamTestTime;
this._localTcpAppObj = null;
}
/**

View File

@ -12,8 +12,8 @@ import java.net.Socket;
* */
public class Protocol {
private InputStream _ctlInStream;
private OutputStream _ctlOutStream;
private final InputStream _ctlInStream;
private final OutputStream _ctlOutStream;
private boolean jsonSupport = true;
/**

View File

@ -318,13 +318,17 @@ public class Tcpbw100 extends JApplet implements ActionListener {
/**
* public static void main for invoking as an Application
* @param args String array of command line arguments
* */
* @throws IllegalArgumentException on bad hostname
**/
public static void main(String[] args) {
Tcpbw100 test = mainSupport( args );
test.runIt();
}
/** bigly */
/**
* bigly
* @throws IllegalArgumentException on bad hostname
**/
public static Tcpbw100 mainSupport(String[] args) {
JFrame frame = new JFrame("ANL/Internet2 NDT (applet)");
boolean useSSL = args.length > 0 && args[0].equals("-s");

View File

@ -63,7 +63,7 @@ public class StatSummarizer implements Runnable, ClientApp {
/**
* @return null if disabled
* @since 0.0.38
* @since 0.9.38
*/
public static StatSummarizer instance(I2PAppContext ctx) {
ClientApp app = ctx.clientAppManager().getRegisteredApp(NAME);
@ -99,7 +99,7 @@ public class StatSummarizer implements Runnable, ClientApp {
}
}
/** @since 0.0.38 */
/** @since 0.9.38 */
public static boolean isDisabled(I2PAppContext ctx) {
return ctx.clientAppManager().getRegisteredApp(NAME) == null;
}
@ -270,7 +270,7 @@ public class StatSummarizer implements Runnable, ClientApp {
// at java.lang.Class.forName(Class.java:270)
// at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:82)
setDisabled();
String s = "Error rendering - disabling graph generation. Install ttf-dejavu font package?";
String s = "Error rendering - disabling graph generation. Install fonts-dejavu font package?";
_log.logAlways(Log.WARN, s);
IOException ioe = new IOException(s);
ioe.initCause(ncdfe);
@ -359,7 +359,7 @@ public class StatSummarizer implements Runnable, ClientApp {
// at java.lang.Class.forName(Class.java:270)
// at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:82)
setDisabled();
String s = "Error rendering - disabling graph generation. Install ttf-dejavu font package?";
String s = "Error rendering - disabling graph generation. Install fonts-dejavu font package?";
_log.logAlways(Log.WARN, s);
IOException ioe = new IOException(s);
ioe.initCause(ncdfe);

View File

@ -139,8 +139,11 @@ public class WebAppStarter {
if (classNames.length == 0)
classNames = wac.getDefaultConfigurationClasses();
String[] newClassNames = new String[classNames.length + 1];
for (int j = 0; j < classNames.length; j++)
for (int j = 0; j < classNames.length; j++) {
newClassNames[j] = classNames[j];
// fix for Jetty 9.4 ticket #2385
wac.prependServerClass("-" + classNames[j]);
}
newClassNames[classNames.length] = WebAppConfiguration.class.getName();
wac.setConfigurationClasses(newClassNames);
}

View File

@ -32,6 +32,7 @@ import net.i2p.data.Destination;
import net.i2p.data.Hash;
import net.i2p.data.Lease;
import net.i2p.data.LeaseSet;
import net.i2p.data.LeaseSet2;
import net.i2p.data.router.RouterAddress;
import net.i2p.data.router.RouterInfo;
import net.i2p.router.RouterContext;
@ -519,11 +520,21 @@ class NetDbRenderer {
median = dist;
}
buf.append("&nbsp;&nbsp;<b>Distance: </b>").append(fmt.format(biLog2(dist)));
buf.append("&nbsp;&nbsp;<b>Type: </b>").append(ls.getType());
int type = ls.getType();
buf.append("&nbsp;&nbsp;<b>Type: </b>").append(type);
if (type != DatabaseEntry.KEY_TYPE_LEASESET) {
LeaseSet2 ls2 = (LeaseSet2) ls;
buf.append("&nbsp;&nbsp;<b>Unpublished? </b>").append(ls2.isUnpublished());
boolean isOff = ls2.isOffline();
buf.append("&nbsp;&nbsp;<b>Offline signed? </b>").append(isOff);
if (isOff)
buf.append("&nbsp;&nbsp;<b>Type: </b>").append(ls2.getTransientSigningKey().getType());
}
buf.append("</td></tr>\n<tr><td colspan=\"2\">");
//buf.append(dest.toBase32()).append("<br>");
buf.append("<b>Signature type:</b> ").append(dest.getSigningPublicKey().getType());
buf.append("&nbsp;&nbsp;<b>Encryption Key:</b> ").append(ls.getEncryptionKey().toBase64().substring(0, 20)).append("&hellip;");
if (type != DatabaseEntry.KEY_TYPE_META_LS2)
buf.append("&nbsp;&nbsp;<b>Encryption Key:</b> ").append(ls.getEncryptionKey().toBase64().substring(0, 20)).append("&hellip;");
buf.append("</td></tr>\n<tr><td colspan=\"2\">");
buf.append("<b>Routing Key:</b> ").append(ls.getRoutingKey().toBase64());
buf.append("</td></tr>");