diff --git a/apps/routerconsole/java/src/com/vuze/plugins/mlab/MLabRunner.java b/apps/routerconsole/java/src/com/vuze/plugins/mlab/MLabRunner.java index c9cf64049..d1c13cb2c 100644 --- a/apps/routerconsole/java/src/com/vuze/plugins/mlab/MLabRunner.java +++ b/apps/routerconsole/java/src/com/vuze/plugins/mlab/MLabRunner.java @@ -53,7 +53,8 @@ public class MLabRunner { // use ndt_ssl for test over ssl private static final String NS_URL_SSL_SSL = "https://mlab-ns.appspot.com/ndt_ssl?format=json"; private static final String PROP_SSL = "routerconsole.bwtest.useSSL"; - private static final boolean DEFAULT_USE_SSL = true; + // SSL hangs far too often + private static final boolean DEFAULT_USE_SSL = false; private static final long NS_TIMEOUT = 20*1000; private final I2PAppContext _context; private final Log _log; diff --git a/apps/routerconsole/java/src/edu/internet2/ndt/JSONUtils.java b/apps/routerconsole/java/src/edu/internet2/ndt/JSONUtils.java index dc05dfe12..267e66d34 100644 --- a/apps/routerconsole/java/src/edu/internet2/ndt/JSONUtils.java +++ b/apps/routerconsole/java/src/edu/internet2/ndt/JSONUtils.java @@ -68,4 +68,18 @@ public class JSONUtils { return obj.toJSONString().getBytes(); } + + /** + * Function that return json object represented by jsontext and included + * single message assigned to "msg" key + * @param msg {byte[]} message which should be assigned to json object + * @return {byte[]} json object represented by jsontext and encodes into a sequence of bytes + * @since 0.9.45 + */ + public static byte[] createJsonLoginObj(byte[] msg, byte tests) { + JSONObject obj = new JSONObject(); + obj.put("msg", new String(msg)); + obj.put("tests", Integer.toString(tests & 0xff)); + return obj.toJSONString().getBytes(); + } } diff --git a/apps/routerconsole/java/src/edu/internet2/ndt/NDTConstants.java b/apps/routerconsole/java/src/edu/internet2/ndt/NDTConstants.java index 20342a244..042c92820 100644 --- a/apps/routerconsole/java/src/edu/internet2/ndt/NDTConstants.java +++ b/apps/routerconsole/java/src/edu/internet2/ndt/NDTConstants.java @@ -44,10 +44,11 @@ public class NDTConstants { /* * TODO for a later release: Version could be moved to some "configurable" * or "property" area instead of being in code that needs compilation. + * Changed to match https://github.com/measurement-kit/measurement-kit/blob/master/src/libmeasurement_kit/ndt/internal.hpp */ - public static final String VERSION = "3.7.0"; + public static final String VERSION = "v3.7.0"; - public static final String NDT_TITLE_STR = "Network Diagnostic Tool Client v"; + public static final String NDT_TITLE_STR = "Network Diagnostic Tool Client "; // Section: Test type public static final byte TEST_MID = (1 << 0); diff --git a/apps/routerconsole/java/src/edu/internet2/ndt/Protocol.java b/apps/routerconsole/java/src/edu/internet2/ndt/Protocol.java index f8ce08d83..c2fb6b2d2 100644 --- a/apps/routerconsole/java/src/edu/internet2/ndt/Protocol.java +++ b/apps/routerconsole/java/src/edu/internet2/ndt/Protocol.java @@ -82,6 +82,29 @@ public class Protocol { } } + /** + * Send protocol messages given their type and data byte array + * + * @param bParamType + * Control Message Type + * @param bParamToSend + * Data value array to send + * @throws IOException + * If data cannot be successfully written to the Output Stream + * + * @since 0.9.45 + * */ + public void send_json_login_msg(byte bParamType, byte[] bParamToSend) + throws IOException { + if (jsonSupport) { + byte[] ver = new byte[bParamToSend.length - 1]; + System.arraycopy(bParamToSend, 1, ver, 0, ver.length); + send_msg(bParamType, JSONUtils.createJsonLoginObj(bParamToSend, bParamToSend[0])); + } else { + send_msg(bParamType, bParamToSend); + } + } + /** * Send protocol messages given their type and data byte array * diff --git a/apps/routerconsole/java/src/edu/internet2/ndt/Tcpbw100.java b/apps/routerconsole/java/src/edu/internet2/ndt/Tcpbw100.java index e31c960da..fb8cdae2b 100644 --- a/apps/routerconsole/java/src/edu/internet2/ndt/Tcpbw100.java +++ b/apps/routerconsole/java/src/edu/internet2/ndt/Tcpbw100.java @@ -232,8 +232,8 @@ public class Tcpbw100 extends JApplet implements ActionListener { String sHostName = null; InetAddress hostAddress = null; String _sTestResults, _sMidBoxTestResult; - byte _yTests = NDTConstants.TEST_MID | NDTConstants.TEST_C2S - | NDTConstants.TEST_S2C | NDTConstants.TEST_SFW + byte _yTests = /* NDTConstants.TEST_MID | */ NDTConstants.TEST_C2S + | NDTConstants.TEST_S2C /* | NDTConstants.TEST_SFW */ | NDTConstants.TEST_STATUS | NDTConstants.TEST_META; int _iC2sSFWResult = NDTConstants.SFW_NOTTESTED; int _iS2cSFWResult = NDTConstants.SFW_NOTTESTED; @@ -940,7 +940,9 @@ public class Tcpbw100 extends JApplet implements ActionListener { _chkboxPreferIPv6 = new JCheckBox( _resBundDisplayMsgs.getString("preferIPv6")); // I2P - _chkboxPreferIPv6.setSelected(Addresses.isConnectedIPv6()); + // IPv6 unreliable, only prefer if we don't have a IPv4 address + //_chkboxPreferIPv6.setSelected(Addresses.isConnectedIPv6()); + _chkboxPreferIPv6.setSelected(!Addresses.isConnected()); _chkboxPreferIPv6.addActionListener(this); // 2. Conduct default tests? _chkboxDefaultTest = new JCheckBox( @@ -2567,7 +2569,12 @@ public class Tcpbw100 extends JApplet implements ActionListener { send[0] = _yTests; System.arraycopy(NDTConstants.VERSION.getBytes(), 0, send, 1, NDTConstants.VERSION.length()); - protocolObj.send_json_msg(MessageType.MSG_EXTENDED_LOGIN, send); + // I2P - adds tests as "tests" in json + // https://github.com/measurement-kit/measurement-kit/blob/master/src/libmeasurement_kit/ndt/messages.cpp + //protocolObj.send_json_msg(MessageType.MSG_EXTENDED_LOGIN, send); + protocolObj.send_json_login_msg(MessageType.MSG_EXTENDED_LOGIN, send); + // SSL in particular will hang here for several minutes + ctlSocket.setSoTimeout(30*1000); // read the specially crafted data that kicks off the old clients if (protocolObj.readn(msg, 13) != 13) { @@ -2577,6 +2584,7 @@ public class Tcpbw100 extends JApplet implements ActionListener { try { ctlSocket.close(); } catch (IOException ioe) {} return; } + ctlSocket.setSoTimeout(60*1000); for (;;) { @@ -2988,7 +2996,7 @@ public class Tcpbw100 extends JApplet implements ActionListener { _resultsTxtPane.append(ex + "\n"); } // interpret middlebox test results - if ((_yTests & NDTConstants.TEST_MID) == NDTConstants.TEST_MID) { + if (_sMidBoxTestResult != null && (_yTests & NDTConstants.TEST_MID) == NDTConstants.TEST_MID) { middleboxResults(_sMidBoxTestResult); } @@ -4478,7 +4486,7 @@ public class Tcpbw100 extends JApplet implements ActionListener { return Integer.parseInt(msg, radix); } } catch (NumberFormatException nfe) { - _log.warn("parse", nfe); + _log.warn("parse input: \"" + msg + '"', nfe); return 0; } }