mirror of
https://github.com/avwo/whistle.git
synced 2026-10-28 22:59:50 +08:00
feat: download certificate
This commit is contained in:
+9
-2
@@ -27,6 +27,7 @@ var customCertsInfo = {};
|
||||
var customCertsFiles = {};
|
||||
var customCertCount = 0;
|
||||
var cachePairs = new LRU({max: 5120});
|
||||
var certsCache = new LRU({max: 256});
|
||||
var ILEGAL_CHAR_RE = /[^a-z\d-]/i;
|
||||
var RANDOM_SERIAL = '.' + Date.now() + '.' + Math.floor(Math.random() * 10000);
|
||||
var PORT_RE = /:\d*$/;
|
||||
@@ -112,7 +113,7 @@ exports.hasCustomCerts = function() {
|
||||
};
|
||||
|
||||
function getCertificate(hostname) {
|
||||
return customPairs[hostname] || cachePairs.get(hostname);
|
||||
return customPairs[hostname] || cachePairs.get(hostname) || certsCache.get(hostname);
|
||||
}
|
||||
|
||||
function _createCertificate(hostname) {
|
||||
@@ -159,7 +160,13 @@ function createCertificate(hostname) {
|
||||
}
|
||||
|
||||
exports.createCertificate = function(hostname) {
|
||||
return getCertificate(hostname) || _createCertificate(hostname);
|
||||
hostname = getDomain(hostname);
|
||||
var cert = getCertificate(hostname);
|
||||
if (!cert) {
|
||||
cert = _createCertificate(hostname);
|
||||
certsCache.set(hostname, cert);
|
||||
}
|
||||
return cert;
|
||||
};
|
||||
|
||||
function loadCustomCerts(certDir) {
|
||||
|
||||
Reference in New Issue
Block a user