create-servers
Advanced tools
Comparing version 3.0.1 to 3.1.0
# CHANGELOG | ||
## 3.1.0 | ||
- [#23], @DullReferenceException Support "*" for SNI host pattern | ||
## 3.0.1 | ||
@@ -4,0 +8,0 @@ |
@@ -228,3 +228,3 @@ 'use strict'; | ||
var hostRegexps = sniHosts.map(function(host) { | ||
return new RegExp( | ||
return host === '*' ? /.*/ : new RegExp( | ||
'^' + | ||
@@ -231,0 +231,0 @@ host |
{ | ||
"name": "create-servers", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Create an http AND/OR an https server and call the same request handler.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -375,51 +375,29 @@ /* | ||
test('supports SNI', async t => { | ||
t.plan(1); | ||
await testSni(t, { | ||
'example.com': { | ||
key: 'example-com-key.pem', | ||
cert: 'example-com-cert.pem' | ||
}, | ||
'example.net': { | ||
key: 'example-net-key.pem', | ||
cert: 'example-net-cert.pem' | ||
}, | ||
'*.example.org': { | ||
key: 'example-org-key.pem', | ||
cert: 'example-org-cert.pem' | ||
} | ||
}, ['example.com', 'example.net', 'foo.example.org']); | ||
}); | ||
const hostNames = ['example.com', 'example.net', 'foo.example.org']; | ||
let httpsServer; | ||
try { | ||
const servers = await createServersAsync({ | ||
https: { | ||
port: 3456, | ||
root: path.join(__dirname, 'fixtures'), | ||
sni: { | ||
'example.com': { | ||
key: 'example-com-key.pem', | ||
cert: 'example-com-cert.pem' | ||
}, | ||
'example.net': { | ||
key: 'example-net-key.pem', | ||
cert: 'example-net-cert.pem' | ||
}, | ||
'*.example.org': { | ||
key: 'example-org-key.pem', | ||
cert: 'example-org-cert.pem' | ||
} | ||
} | ||
}, | ||
handler: (req, res) => { | ||
res.write('Hello'); | ||
res.end(); | ||
} | ||
}); | ||
httpsServer = servers.https; | ||
hostNames.forEach(host => evilDNS.add(host, '0.0.0.0')); | ||
const responses = await Promise.all( | ||
hostNames.map(hostname => download(`https://${hostname}:3456/`)) | ||
); | ||
t.equals( | ||
responses.every(str => str === 'Hello'), | ||
true, | ||
'responses are as expected' | ||
); | ||
} catch (err) { | ||
return void t.error(err); | ||
} finally { | ||
httpsServer && httpsServer.close(); | ||
evilDNS.clear(); | ||
} | ||
test('supports catch-all * for SNI', async t => { | ||
await testSni(t, { | ||
'example.com': { | ||
key: 'example-com-key.pem', | ||
cert: 'example-com-cert.pem' | ||
}, | ||
'*': { | ||
key: 'example-org-key.pem', | ||
cert: 'example-org-cert.pem' | ||
} | ||
}, ['example.com', 'foo.example.org']); | ||
}); | ||
@@ -470,1 +448,38 @@ | ||
}); | ||
async function testSni(t, sniConfig, hostNames) { | ||
t.plan(1); | ||
let httpsServer; | ||
try { | ||
const servers = await createServersAsync({ | ||
https: { | ||
port: 3456, | ||
root: path.join(__dirname, 'fixtures'), | ||
sni: sniConfig | ||
}, | ||
handler: (req, res) => { | ||
res.write('Hello'); | ||
res.end(); | ||
} | ||
}); | ||
httpsServer = servers.https; | ||
hostNames.forEach(host => evilDNS.add(host, '0.0.0.0')); | ||
const responses = await Promise.all( | ||
hostNames.map(hostname => download(`https://${hostname}:3456/`)) | ||
); | ||
t.equals( | ||
responses.every(str => str === 'Hello'), | ||
true, | ||
'responses are as expected' | ||
); | ||
} catch (err) { | ||
return void t.error(err); | ||
} finally { | ||
httpsServer && httpsServer.close(); | ||
evilDNS.clear(); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56699
769