mirror of
				https://git.coolaj86.com/coolaj86/greenlock-cli.js
				synced 2025-11-04 11:02:47 +00:00 
			
		
		
		
	add manual mode, move standalone to own module
This commit is contained in:
		
							parent
							
								
									b068152fb9
								
							
						
					
					
						commit
						9e90c23259
					
				@ -186,6 +186,9 @@ Options:
 | 
			
		||||
 | 
			
		||||
      --standalone [BOOLEAN]    Obtain certs using a "standalone" webserver.  (Default is true)
 | 
			
		||||
 | 
			
		||||
      --manual [BOOLEAN]        Print the token and key to the screen and wait for you to hit enter,
 | 
			
		||||
                                giving you time to copy it somewhere before continuing. (Default is false)
 | 
			
		||||
 | 
			
		||||
      --webroot BOOLEAN         Obtain certs by placing files in a webroot directory.
 | 
			
		||||
 | 
			
		||||
      --webroot-path STRING      public_html / webroot path.
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,7 @@ cli.parse({
 | 
			
		||||
, 'config-dir': [ false, " Configuration directory.", 'string', '~/letsencrypt/etc/' ]
 | 
			
		||||
, server: [ false, " ACME Directory Resource URI.", 'string', 'https://acme-v01.api.letsencrypt.org/directory)' ]
 | 
			
		||||
, standalone: [ false, " Obtain certs using a \"standalone\" webserver.", 'boolean', false ]
 | 
			
		||||
//, manual: [ false, " Provide laborious manual instructions for obtaining a cert (default: false)", 'boolean', false ]
 | 
			
		||||
, manual: [ false, " Print the token and key to the screen and wait for you to hit enter, giving you time to copy it somewhere before continuing (default: false)", 'boolean', false ]
 | 
			
		||||
, webroot: [ false, " Obtain certs by placing files in a webroot directory.", 'boolean', false ]
 | 
			
		||||
, 'webroot-path': [ false, " public_html / webroot path.", 'string' ]
 | 
			
		||||
//, 'standalone-supported-challenges': [ false, " Supported challenges, order preferences are randomly chosen. (default: http-01,tls-sni-01)", 'string', 'http-01,tls-sni-01']
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										8
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								index.js
									
									
									
									
									
								
							@ -19,12 +19,16 @@ module.exports.run = function (args) {
 | 
			
		||||
    challengeType = 'http-01';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (args.webrootPath) {
 | 
			
		||||
  if (args.manual) {
 | 
			
		||||
    leChallenge = require('le-challenge-manual').create({});
 | 
			
		||||
  }
 | 
			
		||||
  else if (args.webrootPath) {
 | 
			
		||||
    // webrootPath is all that really matters here
 | 
			
		||||
    // TODO rename le-challenge-fs to le-challenge-webroot
 | 
			
		||||
    leChallenge = require('./lib/webroot').create({ webrootPath: args.webrootPath });
 | 
			
		||||
  }
 | 
			
		||||
  else if (USE_DNS !== args.standalone) {
 | 
			
		||||
    leChallenge = require('./lib/standalone').create({});
 | 
			
		||||
    leChallenge = require('le-challenge-standalone').create({});
 | 
			
		||||
    servers = require('./lib/servers').create(leChallenge).startServers(
 | 
			
		||||
      args.http01Port || [80], args.tlsSni01Port || [443, 5001]
 | 
			
		||||
    , { debug: args.debug }
 | 
			
		||||
 | 
			
		||||
@ -1,32 +0,0 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
module.exports.create = function (defaults) {
 | 
			
		||||
  var handlers =  {
 | 
			
		||||
    getOptions: function () {
 | 
			
		||||
      return defaults;
 | 
			
		||||
    }
 | 
			
		||||
    //
 | 
			
		||||
    // set,get,remove challenges
 | 
			
		||||
    //
 | 
			
		||||
    // Note: this is fine for a one-off CLI tool
 | 
			
		||||
    // but a webserver using node-cluster or multiple
 | 
			
		||||
    // servers should use a database of some sort
 | 
			
		||||
  , _challenges: {}
 | 
			
		||||
  , set: function (args, domain, token, secret, cb) {
 | 
			
		||||
      handlers._challenges[token] = secret;
 | 
			
		||||
      cb(null);
 | 
			
		||||
    }
 | 
			
		||||
  , get: function (args, domain, token, cb) {
 | 
			
		||||
      // TODO keep in mind that, generally get args are just args.domains
 | 
			
		||||
      // and it is disconnected from the flow of setChallenge and removeChallenge
 | 
			
		||||
      cb(null, handlers._challenges[token]);
 | 
			
		||||
    }
 | 
			
		||||
  , remove: function (args, domain, token, cb) {
 | 
			
		||||
      delete handlers._challenges[token];
 | 
			
		||||
      cb(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  return handlers;
 | 
			
		||||
};
 | 
			
		||||
@ -36,6 +36,8 @@
 | 
			
		||||
    "cli": "^0.11.1",
 | 
			
		||||
    "homedir": "^0.6.0",
 | 
			
		||||
    "le-acme-core": "^2.0.5",
 | 
			
		||||
    "le-challenge-manual": "^2.0.0",
 | 
			
		||||
    "le-challenge-standalone": "^2.0.0",
 | 
			
		||||
    "le-store-certbot": "^2.0.2",
 | 
			
		||||
    "letsencrypt": "^2.0.3",
 | 
			
		||||
    "localhost.daplie.com-certificates": "^1.2.0",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user