summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/socks_client_subprocess.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /netwerk/test/unit/socks_client_subprocess.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/test/unit/socks_client_subprocess.js')
-rw-r--r--netwerk/test/unit/socks_client_subprocess.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/netwerk/test/unit/socks_client_subprocess.js b/netwerk/test/unit/socks_client_subprocess.js
new file mode 100644
index 000000000..144bc8757
--- /dev/null
+++ b/netwerk/test/unit/socks_client_subprocess.js
@@ -0,0 +1,42 @@
+var CC = Components.Constructor;
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+
+const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
+ "nsIBinaryInputStream",
+ "setInputStream");
+const ProtocolProxyService = CC("@mozilla.org/network/protocol-proxy-service;1",
+ "nsIProtocolProxyService");
+var sts = Cc["@mozilla.org/network/socket-transport-service;1"]
+ .getService(Ci.nsISocketTransportService);
+
+function launchConnection(socks_vers, socks_port, dest_host, dest_port, dns)
+{
+ var pi_flags = 0;
+ if (dns == 'remote')
+ pi_flags = Ci.nsIProxyInfo.TRANSPARENT_PROXY_RESOLVES_HOST;
+
+ var pps = new ProtocolProxyService();
+ var pi = pps.newProxyInfo(socks_vers, 'localhost', socks_port,
+ pi_flags, -1, null);
+ var trans = sts.createTransport(null, 0, dest_host, dest_port, pi);
+ var input = trans.openInputStream(Ci.nsITransport.OPEN_BLOCKING,0,0);
+ var output = trans.openOutputStream(Ci.nsITransport.OPEN_BLOCKING,0,0);
+ var bin = new BinaryInputStream(input);
+ var data = bin.readBytes(5);
+ if (data == 'PING!') {
+ print('client: got ping, sending pong.');
+ output.write('PONG!', 5);
+ } else {
+ print('client: wrong data from server:', data);
+ output.write('Error: wrong data received.', 27);
+ }
+ output.close();
+}
+
+for (var arg of arguments) {
+ print('client: running test', arg);
+ test = arg.split('|');
+ launchConnection(test[0], parseInt(test[1]), test[2],
+ parseInt(test[3]), test[4]);
+}