Skip to content
Browse files

pass the service to createStream, ssl example with upnode+airport

  • Loading branch information...
1 parent a91dfc4 commit 2cdaa60867840003a59c03923e339ff147f30181 @substack committed Aug 5, 2012
Showing with 75 additions and 2 deletions.
  1. +16 −0 example/ssl/client.js
  2. +13 −0 example/ssl/keys/cert.pem
  3. +11 −0 example/ssl/keys/csr.pem
  4. +15 −0 example/ssl/keys/key.pem
  5. +18 −0 example/ssl/server.js
  6. +1 −1 index.js
  7. +1 −1 package.json
View
16 example/ssl/client.js
@@ -0,0 +1,16 @@
+var air = require('airport')(7500);
+var tls = require('tls');
+var up = air.connect({
+ role : 'time',
+ createStream : function (service) {
+ return tls.connect(service.port, service.host);
+ }
+});
+
+setInterval(function () {
+ up(function (remote) {
+ remote.time(function (t) {
+ console.log('time = ' + t);
+ });
+ });
+}, 1000);
View
13 example/ssl/keys/cert.pem
@@ -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-----
View
11 example/ssl/keys/csr.pem
@@ -0,0 +1,11 @@
+-----BEGIN CERTIFICATE REQUEST-----
+MIIBhDCB7gIBADBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEh
+MB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEB
+AQUAA4GNADCBiQKBgQDl9ns3nAqCn2m9ABj82pXrPBMEjLUQjAnXOGqWNp+apYBo
+P+QEGsI4fP9F5AX0C0OBEbSNQtYeDdWa3i1jW4i3F3lSCdPZV8wfrpWD2VpWaaaU
+NjHTLF0cglhgZW3kjNuUBWUeCvfCCI4lEhFdvJCyn2Rn+85VKlkJ18rAQxUTWwID
+AQABoAAwDQYJKoZIhvcNAQEFBQADgYEAjwmLVmd6QEEl98PBZ4jBP9gs9v+epAjN
+THMbe6jc4veH1bUaaZHMvQt4ECtewfUVN7OqA9j1InAXf7rkHeOv/GI3xeqR8v3L
+0xIC/t2UA/lBzSvCClryyx1kM7JsWXXZn/SWddJbrkVWg4kibEC2wR+MU4XXJOvU
+vUNrmxP3EiM=
+-----END CERTIFICATE REQUEST-----
View
15 example/ssl/keys/key.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXAIBAAKBgQDl9ns3nAqCn2m9ABj82pXrPBMEjLUQjAnXOGqWNp+apYBoP+QE
+GsI4fP9F5AX0C0OBEbSNQtYeDdWa3i1jW4i3F3lSCdPZV8wfrpWD2VpWaaaUNjHT
+LF0cglhgZW3kjNuUBWUeCvfCCI4lEhFdvJCyn2Rn+85VKlkJ18rAQxUTWwIDAQAB
+AoGACO/qW//pfKgbYOgHEJSiLPE5v/yD8O+wVjfwFIRs8YKrGeIZx3sOv0lEVoAF
+JzXk2rhIbxEA50wcWBd4ZhshlgEr72L2aapRJzqJV+Nu1TNSed9VSOnpknxicWPJ
+v5UBEI1Gw3iSKwMV7jKM7XQdrFK5MDHHFINxCO2onlw6TCECQQD2flRQHIdI/TEq
+VAAQ36UP8arkRel4wbTi+mfTueNeH7BTNnwD5MhjM97BXod4Az7q5WPuA39pu4Py
+gyCI2VoLAkEA7tTxLAQ/l1HXh+rVBJzNek34HTz//r1wEdsHUiqrkpOHZKgs5j5W
+Sn876hCc3zmuw+xhIUOEygIYxaofSmZN8QJAac/fF6i3dmCiC16VzKiErex7BJTy
+XVEh+lGt4liovs3xnjcEU5ORZextUirnEmCqUKF6HUFJH7VMNf2OKNDM8wJAG2lx
+bN3n9pQ8Kqt3W5ors1fznFd+Alz32fTLuFCRdLdeGN18mciZ2t8Tn1/cwXo7Zt1g
+oJLBUPZApZ9LDB0F4QJBAOrZQ+rlrtOCw3JCZW9gmLeSgMkFS4t3tIiPJEyYysnu
+6KzVVDcl6tA8UHOA5JMb3uv8E/iAmv5SMQwQFGN/cf0=
+-----END RSA PRIVATE KEY-----
View
18 example/ssl/server.js
@@ -0,0 +1,18 @@
+var upnode = require('upnode');
+var ports = require('seaport').connect('localhost', 7500);
+
+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);
+});
+
+ports.service('time', server.listen.bind(server));
View
2 index.js
@@ -67,7 +67,7 @@ Airport.prototype.connect = function (opts, fn) {
var inst = upnode(cons);
var c;
if (opts.createStream) {
- service.createStream = opts.createStream;
+ service.createStream = opts.createStream.bind(inst, service);
}
if (service.secret) {
View
2 package.json
@@ -1,7 +1,7 @@
{
"name" : "airport",
"description" : "role-based port management for upnode",
- "version" : "0.4.1",
+ "version" : "0.4.2",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/airport.git"

0 comments on commit 2cdaa60

Please sign in to comment.
Something went wrong with that request. Please try again.