Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

streaming ssl example works

  • Loading branch information...
commit b5902eca289f57948107cd3314518ec5936cc989 1 parent 461c0f1
James Halliday authored
13 example/ssl/client.js
View
@@ -0,0 +1,13 @@
+var upnode = require('../../');
+var tls = require('tls');
+var up = upnode.connect({
+ createStream : tls.connect.bind(null, 7000)
+});
+
+setInterval(function () {
+ up(function (remote) {
+ remote.time(function (t) {
+ console.log('time = ' + t);
+ });
+ });
+}, 1000);
13 example/ssl/keys/cert.pem
View
@@ -0,0 +1,13 @@
+-----BEGIN CERTIFICATE-----
+MIICATCCAWoCCQDLVlcLsnPCNDANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
+VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
+cyBQdHkgTHRkMB4XDTEyMDcyOTA4MzE0MloXDTEyMDgyODA4MzE0MlowRTELMAkG
+A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0
+IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA5fZ7
+N5wKgp9pvQAY/NqV6zwTBIy1EIwJ1zhqljafmqWAaD/kBBrCOHz/ReQF9AtDgRG0
+jULWHg3Vmt4tY1uItxd5UgnT2VfMH66Vg9laVmmmlDYx0yxdHIJYYGVt5IzblAVl
+Hgr3wgiOJRIRXbyQsp9kZ/vOVSpZCdfKwEMVE1sCAwEAATANBgkqhkiG9w0BAQUF
+AAOBgQAeU/vYbgaLd+0kzpEYV5H4HanwKgOR7auxFv17oZRC1CSumgaBSAljNArn
+TFBSwu55IwNOoj6skz7KH+WFU946II7BxIf6+Cm0YOlsW0kNIXDTKJRLjIClSwux
+M3njWfGGrVBDCxGp8qWIuuJHtRKCNvUlQZmG5Ozc7x5ogWG6pw==
+-----END CERTIFICATE-----
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ECQQD2flRQHIdI/TEq
+VAAQ36UP8arkRel4wbTi+mfTueNeH7BTNnwD5MhjM97BXod4Az7q5WPuA39pu4Py
+gyCI2VoLAkEA7tTxLAQ/l1HXh+rVBJzNek34HTz//r1wEdsHUiqrkpOHZKgs5j5W
+Sn876hCc3zmuw+xhIUOEygIYxaofSmZN8QJAac/fF6i3dmCiC16VzKiErex7BJTy
+XVEh+lGt4liovs3xnjcEU5ORZextUirnEmCqUKF6HUFJH7VMNf2OKNDM8wJAG2lx
+bN3n9pQ8Kqt3W5ors1fznFd+Alz32fTLuFCRdLdeGN18mciZ2t8Tn1/cwXo7Zt1g
+oJLBUPZApZ9LDB0F4QJBAOrZQ+rlrtOCw3JCZW9gmLeSgMkFS4t3tIiPJEyYysnu
+6KzVVDcl6tA8UHOA5JMb3uv8E/iAmv5SMQwQFGN/cf0=
+-----END RSA PRIVATE KEY-----
15 example/ssl/server.js
View
@@ -0,0 +1,15 @@
+var upnode = require('../../');
+var fs = require('fs');
+var tls = require('tls');
+
+var opts = {
+ key : fs.readFileSync(__dirname + '/keys/key.pem'),
+ cert : fs.readFileSync(__dirname + '/keys/cert.pem'),
+};
+var server = tls.createServer(opts, function (stream) {
+ var up = upnode(function (client, conn) {
+ this.time = function (cb) { cb(new Date().toString()) };
+ });
+ up.pipe(stream).pipe(up);
+});
+server.listen(7000);
11 index.js
View
@@ -15,16 +15,13 @@ var upnode = module.exports = function (cons) {
return connect.apply(null, [ up, cons ].concat(args));
};
- self.pipe = function (target) {
- var d = serverHandle(cons);
- self._serverHandle = d;
- return d.pipe(target);
- };
-
self.writable = true;
self.readable = true;
- [ 'write', 'end', 'destroy' ].forEach(function (name) {
+ var names = Object.keys(EventEmitter.prototype).concat(
+ 'pipe', 'write', 'end', 'destroy'
+ );
+ names.forEach(function (name) {
self[name] = function (buf) {
var h = self._serverHandle;
if (!h) h = self._serverHandle = serverHandle(cons);
Please sign in to comment.
Something went wrong with that request. Please try again.