forked from I2P_Developers/i2p.i2p
NDT: Add support for test over SSL
error handling log tweaks
This commit is contained in:
@ -22,7 +22,6 @@ package com.vuze.plugins.mlab;
|
|||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -49,9 +48,12 @@ import net.i2p.util.Log;
|
|||||||
*/
|
*/
|
||||||
public class MLabRunner {
|
public class MLabRunner {
|
||||||
// ns.measurementlab.net does not support https
|
// ns.measurementlab.net does not support https
|
||||||
// use ndt_ssl for test over ssl? but Tcpbw100 doesn't support it
|
|
||||||
//private static final String NS_URL = "http://ns.measurementlab.net/ndt?format=json";
|
//private static final String NS_URL = "http://ns.measurementlab.net/ndt?format=json";
|
||||||
private static final String NS_URL_SSL = "https://mlab-ns.appspot.com/ndt?format=json";
|
private static final String NS_URL_SSL = "https://mlab-ns.appspot.com/ndt?format=json";
|
||||||
|
// 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;
|
||||||
private static final long NS_TIMEOUT = 20*1000;
|
private static final long NS_TIMEOUT = 20*1000;
|
||||||
private final I2PAppContext _context;
|
private final I2PAppContext _context;
|
||||||
private final Log _log;
|
private final Log _log;
|
||||||
@ -114,16 +116,20 @@ public class MLabRunner {
|
|||||||
String server_host = null;
|
String server_host = null;
|
||||||
String server_city = null;
|
String server_city = null;
|
||||||
String server_country = null;
|
String server_country = null;
|
||||||
|
boolean useSSL = _context.getProperty(PROP_SSL, DEFAULT_USE_SSL);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
||||||
|
// http to name server
|
||||||
// public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort,
|
// public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort,
|
||||||
// int numRetries, long minSize, long maxSize, String outputFile, OutputStream outputStream,
|
// int numRetries, long minSize, long maxSize, String outputFile, OutputStream outputStream,
|
||||||
// String url, boolean allowCaching, String etag, String postData) {
|
// String url, boolean allowCaching, String etag, String postData) {
|
||||||
//EepGet eepget = new EepGet(_context, false, null, 0,
|
//EepGet eepget = new EepGet(_context, false, null, 0,
|
||||||
// 0, 2, 1024, null, baos,
|
// 0, 2, 1024, null, baos,
|
||||||
// NS_URL, false, null, null);
|
// NS_URL, false, null, null);
|
||||||
EepGet eepget = new SSLEepGet(_context, baos, NS_URL_SSL);
|
// 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);
|
boolean ok = eepget.fetch(NS_TIMEOUT, NS_TIMEOUT, NS_TIMEOUT);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
throw new IOException("ns fetch failed");
|
throw new IOException("ns fetch failed");
|
||||||
@ -138,13 +144,12 @@ public class MLabRunner {
|
|||||||
}
|
}
|
||||||
if (_log.shouldWarn())
|
if (_log.shouldWarn())
|
||||||
_log.warn("Got response: " + DataHelper.getUTF8(b));
|
_log.warn("Got response: " + DataHelper.getUTF8(b));
|
||||||
// TODO use IP instead to avoid another lookup?
|
// TODO use IP instead to avoid another lookup? - no, won't work with ssl
|
||||||
// or use "fqdn" in response instead of "url"
|
// use "fqdn" in response instead of "url" since ndt_ssl does not have url
|
||||||
URL url = new URL((String)map.get( "url" ));
|
server_host = (String)map.get("fqdn");
|
||||||
if (url == null) {
|
if (server_host == null) {
|
||||||
throw new IOException("no url");
|
throw new IOException("no fqdn");
|
||||||
}
|
}
|
||||||
server_host = url.getHost();
|
|
||||||
server_city = (String) map.get("city");
|
server_city = (String) map.get("city");
|
||||||
server_country = (String) map.get("country");
|
server_country = (String) map.get("country");
|
||||||
// ignore the returned port in the URL (7123) which is the applet, not the control port
|
// ignore the returned port in the URL (7123) which is the applet, not the control port
|
||||||
@ -158,12 +163,14 @@ public class MLabRunner {
|
|||||||
if (server_host == null) {
|
if (server_host == null) {
|
||||||
// fallback to old, discouraged approach
|
// fallback to old, discouraged approach
|
||||||
server_host = "ndt.iupui.donar.measurement-lab.org";
|
server_host = "ndt.iupui.donar.measurement-lab.org";
|
||||||
|
useSSL = false;
|
||||||
if (_log.shouldWarn())
|
if (_log.shouldWarn())
|
||||||
_log.warn("Failed to select server, falling back to donar method");
|
_log.warn("Failed to select server, falling back to donar method");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String[] args = useSSL ? new String[] { "-s", server_host } : new String[] { server_host };
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
final Tcpbw100 test = Tcpbw100.mainSupport( new String[]{ server_host });
|
final Tcpbw100 test = Tcpbw100.mainSupport(args);
|
||||||
|
|
||||||
run.addListener(
|
run.addListener(
|
||||||
new ToolRunListener()
|
new ToolRunListener()
|
||||||
@ -344,6 +351,8 @@ public class MLabRunner {
|
|||||||
|
|
||||||
/** standalone test */
|
/** standalone test */
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
boolean useSSL = args.length > 0 && args[0].equals("-s");
|
||||||
|
System.setProperty(PROP_SSL, Boolean.toString(useSSL));
|
||||||
I2PAppContext ctx = I2PAppContext.getGlobalContext();
|
I2PAppContext ctx = I2PAppContext.getGlobalContext();
|
||||||
MLabRunner mlab = MLabRunner.getInstance(ctx);
|
MLabRunner mlab = MLabRunner.getInstance(ctx);
|
||||||
TestListener lsnr = new TestListener();
|
TestListener lsnr = new TestListener();
|
||||||
|
@ -70,6 +70,7 @@ public class NDTConstants {
|
|||||||
|
|
||||||
// NDT pre-fixed port ID
|
// NDT pre-fixed port ID
|
||||||
public static final int CONTROL_PORT_DEFAULT = 3001;
|
public static final int CONTROL_PORT_DEFAULT = 3001;
|
||||||
|
public static final int CONTROL_PORT_SSL = 3010;
|
||||||
|
|
||||||
// Section: SRV-QUEUE message status constants
|
// Section: SRV-QUEUE message status constants
|
||||||
public static final int SRV_QUEUE_TEST_STARTS_NOW = 0;
|
public static final int SRV_QUEUE_TEST_STARTS_NOW = 0;
|
||||||
|
@ -25,16 +25,11 @@ public class ResultsTextPane extends JTextPane {
|
|||||||
* String to be inserted into the document
|
* String to be inserted into the document
|
||||||
**/
|
**/
|
||||||
public void append(String paramTextStr) {
|
public void append(String paramTextStr) {
|
||||||
/****
|
|
||||||
try {
|
try {
|
||||||
getStyledDocument().insertString(getStyledDocument().getLength(),
|
getStyledDocument().insertString(getStyledDocument().getLength(),
|
||||||
paramTextStr, null);
|
paramTextStr, null);
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
System.out
|
|
||||||
.println("WARNING: failed to append text to the text pane! ["
|
|
||||||
+ paramTextStr + "]");
|
|
||||||
}
|
}
|
||||||
****/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,8 +89,8 @@ import java.net.Socket;
|
|||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.security.AccessController;
|
import java.security.GeneralSecurityException;
|
||||||
import java.security.PrivilegedAction;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
@ -120,6 +120,7 @@ import com.vuze.plugins.mlab.tools.ndt.swingemu.*;
|
|||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.util.Addresses;
|
import net.i2p.util.Addresses;
|
||||||
import net.i2p.util.I2PAppThread;
|
import net.i2p.util.I2PAppThread;
|
||||||
|
import net.i2p.util.I2PSSLSocketFactory;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -296,7 +297,22 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
|
|
||||||
// I2P
|
// I2P
|
||||||
private String _displayStatus = "";
|
private String _displayStatus = "";
|
||||||
private final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(Tcpbw100.class);
|
private final I2PAppContext _context = I2PAppContext.getGlobalContext();
|
||||||
|
private final Log _log = _context.logManager().getLog(Tcpbw100.class);
|
||||||
|
private final boolean _useSSL;
|
||||||
|
private final I2PSSLSocketFactory _sslFactory;
|
||||||
|
|
||||||
|
public Tcpbw100(boolean useSSL) {
|
||||||
|
super();
|
||||||
|
I2PSSLSocketFactory sslFactory = null;
|
||||||
|
if (useSSL) {
|
||||||
|
try {
|
||||||
|
sslFactory = new I2PSSLSocketFactory(_context, true, "certificates/ndt");
|
||||||
|
} catch (GeneralSecurityException gse) { throw new IllegalStateException("init", gse); }
|
||||||
|
}
|
||||||
|
_sslFactory = sslFactory;
|
||||||
|
_useSSL = useSSL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* public static void main for invoking as an Application
|
* public static void main for invoking as an Application
|
||||||
@ -310,11 +326,14 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
/** bigly */
|
/** bigly */
|
||||||
public static Tcpbw100 mainSupport(String[] args) {
|
public static Tcpbw100 mainSupport(String[] args) {
|
||||||
JFrame frame = new JFrame("ANL/Internet2 NDT (applet)");
|
JFrame frame = new JFrame("ANL/Internet2 NDT (applet)");
|
||||||
|
boolean useSSL = args.length > 0 && args[0].equals("-s");
|
||||||
|
if (useSSL)
|
||||||
|
args = Arrays.copyOfRange(args, 1, args.length);
|
||||||
if (args.length < 1 || args.length > 2) {
|
if (args.length < 1 || args.length > 2) {
|
||||||
System.out.println("Usage: java -jar Tcpbw100.jar <hostname> [client-id]");
|
System.out.println("Usage: java -jar Tcpbw100.jar [-s] <hostname> [client-id]");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
final Tcpbw100 applet = new Tcpbw100();
|
final Tcpbw100 applet = new Tcpbw100(useSSL);
|
||||||
frame.addWindowListener(new WindowAdapter() {
|
frame.addWindowListener(new WindowAdapter() {
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
applet.destroy();
|
applet.destroy();
|
||||||
@ -748,8 +767,6 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_log.warn("?", e);
|
|
||||||
|
|
||||||
String sMessage = NDTUtils.isEmpty(e.getMessage())
|
String sMessage = NDTUtils.isEmpty(e.getMessage())
|
||||||
? _resBundDisplayMsgs.getString("withoutMessage")
|
? _resBundDisplayMsgs.getString("withoutMessage")
|
||||||
: e.getMessage();
|
: e.getMessage();
|
||||||
@ -758,6 +775,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
_sErrMsg = _resBundDisplayMsgs.getString("unexpectedException")
|
_sErrMsg = _resBundDisplayMsgs.getString("unexpectedException")
|
||||||
+ " (" + e.getClass().getName() + "): "
|
+ " (" + e.getClass().getName() + "): "
|
||||||
+ sMessage + "\n";
|
+ sMessage + "\n";
|
||||||
|
_log.warn(_sErrMsg, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If test failed due to any reason, mark failure reason too
|
// If test failed due to any reason, mark failure reason too
|
||||||
@ -808,7 +826,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String lang = I2PAppContext.getGlobalContext().getProperty("routerconsole.lang");
|
String lang = _context.getProperty("routerconsole.lang");
|
||||||
if (lang != null) {
|
if (lang != null) {
|
||||||
_localeObj = new Locale(lang);
|
_localeObj = new Locale(lang);
|
||||||
_sLang = lang;
|
_sLang = lang;
|
||||||
@ -826,7 +844,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null,
|
||||||
"Error while loading language files:\n" + e.getMessage());
|
"Error while loading language files:\n" + e.getMessage());
|
||||||
_log.warn("?", e);
|
_log.warn("bundle", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
createMainWindow();
|
createMainWindow();
|
||||||
@ -1237,8 +1255,6 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
|
|
||||||
getAppletContext().showDocument(_targetURL);
|
getAppletContext().showDocument(_targetURL);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_log.warn("?", e);
|
|
||||||
|
|
||||||
String sMessage = NDTUtils.isEmpty(e.getMessage())
|
String sMessage = NDTUtils.isEmpty(e.getMessage())
|
||||||
? _resBundDisplayMsgs.getString("withoutMessage")
|
? _resBundDisplayMsgs.getString("withoutMessage")
|
||||||
: e.getMessage();
|
: e.getMessage();
|
||||||
@ -1247,6 +1263,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
+ " (" + e.getClass().getName() + "): "
|
+ " (" + e.getClass().getName() + "): "
|
||||||
+ sMessage + "\n";
|
+ sMessage + "\n";
|
||||||
|
|
||||||
|
_log.warn(_sErrMsg, e);
|
||||||
_resultsTxtPane.append(_sErrMsg);
|
_resultsTxtPane.append(_sErrMsg);
|
||||||
}
|
}
|
||||||
} // end mail-to functionality
|
} // end mail-to functionality
|
||||||
@ -1282,7 +1299,8 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
_displayStatus = msg;
|
_displayStatus = msg;
|
||||||
}
|
}
|
||||||
_log.warn("NDT STATUS: " + msg);
|
if (_log.shouldWarn())
|
||||||
|
_log.warn("NDT STATUS: " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1358,6 +1376,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
// connect to server using port obtained above
|
// connect to server using port obtained above
|
||||||
Socket midSrvrSockObj = null;
|
Socket midSrvrSockObj = null;
|
||||||
try {
|
try {
|
||||||
|
// this one is NOT SSL
|
||||||
midSrvrSockObj = new Socket(hostAddress, midport);
|
midSrvrSockObj = new Socket(hostAddress, midport);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
_log.warn("Don't know about host: " + sHostName, e);
|
_log.warn("Don't know about host: " + sHostName, e);
|
||||||
@ -1641,9 +1660,9 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
srvSocket = new ServerSocket(
|
srvSocket = new ServerSocket(
|
||||||
NDTConstants.SOCKET_FREE_PORT_INDICATOR);
|
NDTConstants.SOCKET_FREE_PORT_INDICATOR);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_log.warn("?", e);
|
|
||||||
_sErrMsg = _resBundDisplayMsgs.getString("sfwSocketFail")
|
_sErrMsg = _resBundDisplayMsgs.getString("sfwSocketFail")
|
||||||
+ "\n";
|
+ "\n";
|
||||||
|
_log.warn(_sErrMsg, e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1680,6 +1699,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
|
|
||||||
// Now, run Test from client for the C->S direction SFW test
|
// Now, run Test from client for the C->S direction SFW test
|
||||||
// trying to connect to ephemeral port number sent by server
|
// trying to connect to ephemeral port number sent by server
|
||||||
|
// this one is NOT SSL
|
||||||
Socket sfwSocket = new Socket();
|
Socket sfwSocket = new Socket();
|
||||||
try {
|
try {
|
||||||
// create socket to ephemeral port. testTime now specified in mS
|
// create socket to ephemeral port. testTime now specified in mS
|
||||||
@ -1693,7 +1713,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
sfwCtl.send_json_msg(MessageType.TEST_MSG, new String(
|
sfwCtl.send_json_msg(MessageType.TEST_MSG, new String(
|
||||||
NDTConstants.SFW_PREDEFINED_TEST_MESSAGE).getBytes());
|
NDTConstants.SFW_PREDEFINED_TEST_MESSAGE).getBytes());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_log.warn("?", e);
|
_log.warn("sfwSocket", e);
|
||||||
//Indication that there might be a firewall from C->S side.
|
//Indication that there might be a firewall from C->S side.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1819,7 +1839,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
// client connects to this port
|
// client connects to this port
|
||||||
final Socket outSocket;
|
final Socket outSocket;
|
||||||
try {
|
try {
|
||||||
outSocket = new Socket(hostAddress, iC2sport);
|
outSocket = newSocket(hostAddress, iC2sport);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
_log.warn("Don't know about host: " + sHostName, e);
|
_log.warn("Don't know about host: " + sHostName, e);
|
||||||
_sErrMsg = _resBundDisplayMsgs.getString("unknownServer")
|
_sErrMsg = _resBundDisplayMsgs.getString("unknownServer")
|
||||||
@ -1917,7 +1937,8 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
try {
|
try {
|
||||||
outStream.write(_yabuff2Write, 0, _yabuff2Write.length);
|
outStream.write(_yabuff2Write, 0, _yabuff2Write.length);
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
_log.warn("SocketException while writing to server", e);
|
// normal after 10 seconds
|
||||||
|
_log.debug("SocketException while writing to server (normal)", e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// catch (InterruptedIOException iioe) {
|
// catch (InterruptedIOException iioe) {
|
||||||
@ -2084,7 +2105,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
// Create socket and bind to port as instructed by server
|
// Create socket and bind to port as instructed by server
|
||||||
Socket inSocket;
|
Socket inSocket;
|
||||||
try {
|
try {
|
||||||
inSocket = new Socket(hostAddress, iS2cport);
|
inSocket = newSocket(hostAddress, iS2cport);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
_log.warn("Don't know about host: " + sHostName, e);
|
_log.warn("Don't know about host: " + sHostName, e);
|
||||||
_sErrMsg = "unknown server\n";
|
_sErrMsg = "unknown server\n";
|
||||||
@ -2202,9 +2223,9 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
_iSsndqueue = Integer.parseInt(JSONUtils.getValueFromJsonObj(tmpstr3, "UnsentDataAmount"));
|
_iSsndqueue = Integer.parseInt(JSONUtils.getValueFromJsonObj(tmpstr3, "UnsentDataAmount"));
|
||||||
_dSbytes = Double.parseDouble(JSONUtils.getValueFromJsonObj(tmpstr3, "TotalSentByte"));
|
_dSbytes = Double.parseDouble(JSONUtils.getValueFromJsonObj(tmpstr3, "TotalSentByte"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_log.warn("?", e);
|
|
||||||
_sErrMsg = _resBundDisplayMsgs.getString("inboundWrongMessage")
|
_sErrMsg = _resBundDisplayMsgs.getString("inboundWrongMessage")
|
||||||
+ "\n";
|
+ "\n";
|
||||||
|
_log.warn(_sErrMsg, e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2220,9 +2241,9 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
_dSbytes = Double.parseDouble(tmpstr3.substring(k1 + 1)
|
_dSbytes = Double.parseDouble(tmpstr3.substring(k1 + 1)
|
||||||
.substring(k2 + 1));
|
.substring(k2 + 1));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_log.warn("?", e);
|
|
||||||
_sErrMsg = _resBundDisplayMsgs.getString("inboundWrongMessage")
|
_sErrMsg = _resBundDisplayMsgs.getString("inboundWrongMessage")
|
||||||
+ "\n";
|
+ "\n";
|
||||||
|
_log.warn(_sErrMsg, e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2497,7 +2518,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
// The default control port used for the NDT tests session. NDT server
|
// The default control port used for the NDT tests session. NDT server
|
||||||
// listens
|
// listens
|
||||||
// to this port
|
// to this port
|
||||||
int ctlport = NDTConstants.CONTROL_PORT_DEFAULT;
|
int ctlport = _useSSL ? NDTConstants.CONTROL_PORT_SSL : NDTConstants.CONTROL_PORT_DEFAULT;
|
||||||
|
|
||||||
// Commenting these 2 variables - seem unused
|
// Commenting these 2 variables - seem unused
|
||||||
// double wait2;
|
// double wait2;
|
||||||
@ -2521,7 +2542,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
+ "] "
|
+ "] "
|
||||||
+ _resBundDisplayMsgs.getString("toRunTest") + "\n");
|
+ _resBundDisplayMsgs.getString("toRunTest") + "\n");
|
||||||
// create socket to host specified by user and the default port
|
// create socket to host specified by user and the default port
|
||||||
ctlSocket = new Socket(hostAddress, ctlport);
|
ctlSocket = newSocket(hostAddress, ctlport);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
_log.warn("Don't know about host: " + sHostName, e);
|
_log.warn("Don't know about host: " + sHostName, e);
|
||||||
_sErrMsg = _resBundDisplayMsgs.getString("unknownServer") + "\n";
|
_sErrMsg = _resBundDisplayMsgs.getString("unknownServer") + "\n";
|
||||||
@ -2565,6 +2586,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
_sErrMsg = _resBundDisplayMsgs.getString("unsupportedClient")
|
_sErrMsg = _resBundDisplayMsgs.getString("unsupportedClient")
|
||||||
+ "\n";
|
+ "\n";
|
||||||
_bFailed = true;
|
_bFailed = true;
|
||||||
|
try { ctlSocket.close(); } catch (IOException ioe) {}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2597,7 +2619,11 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
.getString("unsupportedMsgExtendedLogin")
|
.getString("unsupportedMsgExtendedLogin")
|
||||||
+ "\n");
|
+ "\n");
|
||||||
// create socket to host specified by user and the default port
|
// create socket to host specified by user and the default port
|
||||||
ctlSocket = new Socket(hostAddress, ctlport);
|
// we seem to always get here, why bother trying extended above?
|
||||||
|
if (ctlSocket != null) {
|
||||||
|
try { ctlSocket.close(); } catch (IOException ioe) {}
|
||||||
|
}
|
||||||
|
ctlSocket = newSocket(hostAddress, ctlport);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
_log.warn("Don't know about host: " + sHostName, e);
|
_log.warn("Don't know about host: " + sHostName, e);
|
||||||
_sErrMsg = _resBundDisplayMsgs.getString("unknownServer") + "\n";
|
_sErrMsg = _resBundDisplayMsgs.getString("unknownServer") + "\n";
|
||||||
@ -2808,6 +2834,9 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
// cannot be successfully run,
|
// cannot be successfully run,
|
||||||
// indicate reason
|
// indicate reason
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
|
// None of test_xxx catch NumberFormatException,
|
||||||
|
// do it here so we don't kill the whole thing
|
||||||
|
try {
|
||||||
if (sPanel.wantToStop()) { // user has indicated decision to stop
|
if (sPanel.wantToStop()) { // user has indicated decision to stop
|
||||||
// tests from GUI
|
// tests from GUI
|
||||||
protocolObj.send_json_msg(MessageType.MSG_ERROR,
|
protocolObj.send_json_msg(MessageType.MSG_ERROR,
|
||||||
@ -2871,6 +2900,11 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
_bFailed = true;
|
_bFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
// None of test_xxx catch NumberFormatException,
|
||||||
|
// do it here so we don't kill the whole thing
|
||||||
|
_log.warn("nfe", nfe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sPanel.wantToStop()) { // user has indicated decision to stop tests
|
if (sPanel.wantToStop()) { // user has indicated decision to stop tests
|
||||||
@ -2973,6 +3007,25 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
pub_status = "done";
|
pub_status = "done";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a SSL or standard socket depending on config
|
||||||
|
*/
|
||||||
|
private Socket newSocket(InetAddress hostAddress, int ctlPort) throws IOException {
|
||||||
|
if (_log.shouldInfo())
|
||||||
|
_log.info("Connecting to " + hostAddress + ':' + ctlPort, new Exception("I did it"));
|
||||||
|
Socket rv;
|
||||||
|
if (_useSSL) {
|
||||||
|
rv = _sslFactory.createSocket(hostAddress, ctlPort);
|
||||||
|
if (_log.shouldWarn())
|
||||||
|
_log.warn("New SSL socket to " + hostAddress + ':' + ctlPort);
|
||||||
|
} else {
|
||||||
|
rv = new Socket(hostAddress, ctlPort);
|
||||||
|
if (_log.shouldWarn())
|
||||||
|
_log.warn("New non-SSL socket to " + hostAddress + ':' + ctlPort);
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that interprets test results. This routine extracts the key-value
|
* Method that interprets test results. This routine extracts the key-value
|
||||||
* pairs of results of various categories and assigns these to the correct
|
* pairs of results of various categories and assigns these to the correct
|
||||||
@ -4439,10 +4492,15 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
* @return {int} The parsed value.
|
* @return {int} The parsed value.
|
||||||
*/
|
*/
|
||||||
private int parseMsgBodyToInt(String msg, int radix) {
|
private int parseMsgBodyToInt(String msg, int radix) {
|
||||||
if (jsonSupport) {
|
try {
|
||||||
return Integer.parseInt(JSONUtils.getSingleMessage(msg), radix);
|
if (jsonSupport) {
|
||||||
} else {
|
return Integer.parseInt(JSONUtils.getSingleMessage(msg), radix);
|
||||||
return Integer.parseInt(msg, radix);
|
} else {
|
||||||
|
return Integer.parseInt(msg, radix);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
_log.warn("parse", nfe);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4469,7 +4527,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
thread_group.destroy();
|
thread_group.destroy();
|
||||||
break;
|
break;
|
||||||
}catch( Throwable e ){
|
}catch( Throwable e ){
|
||||||
_log.warn("?", e);
|
_log.warn("TG", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4495,7 +4553,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
Thread t,
|
Thread t,
|
||||||
Throwable e)
|
Throwable e)
|
||||||
{
|
{
|
||||||
_log.debug("?", e);
|
_log.warn("TG", e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4515,7 +4573,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
|||||||
}catch( Throwable e ){
|
}catch( Throwable e ){
|
||||||
|
|
||||||
if ( !( e instanceof ThreadDeath )){
|
if ( !( e instanceof ThreadDeath )){
|
||||||
_log.debug("?", e);
|
_log.warn("TG", e);
|
||||||
}
|
}
|
||||||
}finally{
|
}finally{
|
||||||
//sem.release();
|
//sem.release();
|
||||||
|
Reference in New Issue
Block a user