very very very nearly complete
This commit is contained in:
		
							父節點
							
								
									26852d6662
								
							
						
					
					
						當前提交
						032bc874aa
					
				@ -25,20 +25,37 @@ module.exports.create = function (opts) {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    worker.on('message', function (msg) {
 | 
					    worker.on('message', function (msg) {
 | 
				
			||||||
      log(opts.debug, 'Message from worker ' + worker.pid, msg, msg && msg.type);
 | 
					      log(opts.debug, 'Message from worker ' + worker.id);
 | 
				
			||||||
      if ('LE_REQUEST' !== (msg && msg.type)) {
 | 
					      if ('LE_REQUEST' !== (msg && msg.type)) {
 | 
				
			||||||
 | 
					        log(opts.debug, 'Ignoring irrelevant message');
 | 
				
			||||||
 | 
					        log(opts.debug, msg);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      log(opts.debug, 'about to approveDomains');
 | 
				
			||||||
      opts.approveDomains(msg.domain, msg.certs, function (err, results) {
 | 
					      opts.approveDomains(msg.domain, msg.certs, function (err, results) {
 | 
				
			||||||
        if (err) {
 | 
					        if (err) {
 | 
				
			||||||
          log(opts.debug, 'Approval got ERROR', err.stack || err);
 | 
					          log(opts.debug, 'Approval got ERROR', err.stack || err);
 | 
				
			||||||
          worker.send({ type: 'LE_RESPONSE', error: err });
 | 
					          worker.send({ type: 'LE_RESPONSE', domain: msg.domain, error: err });
 | 
				
			||||||
          return;
 | 
					          return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var promise;
 | 
					        var promise;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // /*
 | 
				
			||||||
 | 
					        var certs = require('localhost.coolaj86.com-certificates').merge({
 | 
				
			||||||
 | 
					          subject: msg.domain
 | 
				
			||||||
 | 
					        , altnames: [ msg.domain ]
 | 
				
			||||||
 | 
					        , issuedAt: Date.now()
 | 
				
			||||||
 | 
					        , expiresAt: Date.now() + (90 * 24 * 60 * 60 * 1000)
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        certs.privkey = certs.key.toString('ascii');
 | 
				
			||||||
 | 
					        certs.cert = certs.cert.toString('ascii');
 | 
				
			||||||
 | 
					        certs.chain = '';
 | 
				
			||||||
 | 
					        worker.send({ type: 'LE_RESPONSE', domain: msg.domain, certs: certs });
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					        // */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (results.certs) {
 | 
					        if (results.certs) {
 | 
				
			||||||
          promise = opts._le.renew(results.options, results.certs);
 | 
					          promise = opts._le.renew(results.options, results.certs);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -49,10 +66,10 @@ module.exports.create = function (opts) {
 | 
				
			|||||||
        promise.then(function (certs) {
 | 
					        promise.then(function (certs) {
 | 
				
			||||||
          log(opts.debug, 'Approval got certs', certs);
 | 
					          log(opts.debug, 'Approval got certs', certs);
 | 
				
			||||||
          // certs = { subject, domains, issuedAt, expiresAt, privkey, cert, chain };
 | 
					          // certs = { subject, domains, issuedAt, expiresAt, privkey, cert, chain };
 | 
				
			||||||
          worker.send({ type: 'LE_RESPONSE', certs: certs });
 | 
					          worker.send({ type: 'LE_RESPONSE', domain: msg.domain, certs: certs });
 | 
				
			||||||
        }, function (err) {
 | 
					        }, function (err) {
 | 
				
			||||||
          log(opts.debug, 'Approval got ERROR', err.stack || err);
 | 
					          log(opts.debug, 'Approval got ERROR', err.stack || err);
 | 
				
			||||||
          worker.send({ type: 'LE_RESPONSE', error: err });
 | 
					          worker.send({ type: 'LE_RESPONSE', domain: msg.domain, error: err });
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,18 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function log(debug) {
 | 
				
			||||||
 | 
						if (!debug) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var args = Array.prototype.slice.call(arguments);
 | 
				
			||||||
 | 
						args.shift();
 | 
				
			||||||
 | 
						args.unshift("[le/lib/core.js]");
 | 
				
			||||||
 | 
						console.log.apply(console, args);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports.create = function (opts) {
 | 
					module.exports.create = function (opts) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -12,8 +25,11 @@ module.exports.create = function (opts) {
 | 
				
			|||||||
        process.send({ type: 'LE_REQUEST', domain: domain, options: { domains: [domain] }, certs: certs });
 | 
					        process.send({ type: 'LE_REQUEST', domain: domain, options: { domains: [domain] }, certs: certs });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        process.on('message', function (msg) {
 | 
					        process.on('message', function (msg) {
 | 
				
			||||||
 | 
					          log(opts.debug, 'Message from master');
 | 
				
			||||||
 | 
					          log(opts.debug, msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (msg.domain === domain) {
 | 
					          if (msg.domain === domain) {
 | 
				
			||||||
            cb(msg.certs);
 | 
					            cb(null, msg.certs);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								serve.js
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								serve.js
									
									
									
									
									
								
							@ -43,6 +43,7 @@ function runWorker() {
 | 
				
			|||||||
  , notBefore: 15 * 24 * 60 * 60 * 1000
 | 
					  , notBefore: 15 * 24 * 60 * 60 * 1000
 | 
				
			||||||
  , notAfter: 10 * 24 * 60 * 60 * 1000 // optional
 | 
					  , notAfter: 10 * 24 * 60 * 60 * 1000 // optional
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  , webrootPath: require('os').tmpdir() + require('path').sep + 'acme-challenge'
 | 
				
			||||||
    /*
 | 
					    /*
 | 
				
			||||||
  , getChallenge: function (domain, token, cb) {
 | 
					  , getChallenge: function (domain, token, cb) {
 | 
				
			||||||
      // the default behavior is to pass a message to master,
 | 
					      // the default behavior is to pass a message to master,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user