2012-02-23 16:37:49 +01:00
|
|
|
var common = require('../common');
|
|
|
|
var https = require('https'),
|
|
|
|
fs = require('fs'),
|
|
|
|
assert = require('assert');
|
|
|
|
|
2015-01-10 21:36:16 +01:00
|
|
|
if (!common.hasMultiLocalhost()) {
|
2012-02-23 16:37:49 +01:00
|
|
|
console.log('Skipping platform-specific test.');
|
|
|
|
process.exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
|
|
|
|
};
|
|
|
|
|
|
|
|
var server = https.createServer(options, function (req, res) {
|
2013-06-13 15:36:00 +02:00
|
|
|
console.log("Connect from: " + req.connection.remoteAddress);
|
|
|
|
assert.equal('127.0.0.2', req.connection.remoteAddress);
|
2012-02-23 16:37:49 +01:00
|
|
|
|
|
|
|
req.on('end', function() {
|
|
|
|
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
|
|
res.end('You are from: ' + req.connection.remoteAddress);
|
|
|
|
});
|
2012-12-16 23:39:59 +01:00
|
|
|
req.resume();
|
2012-02-23 16:37:49 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
server.listen(common.PORT, "127.0.0.1", function() {
|
2012-08-30 16:43:20 +02:00
|
|
|
var options = {
|
|
|
|
host: 'localhost',
|
2012-02-23 16:37:49 +01:00
|
|
|
port: common.PORT,
|
|
|
|
path: '/',
|
|
|
|
method: 'GET',
|
2012-08-30 16:43:20 +02:00
|
|
|
localAddress: '127.0.0.2',
|
|
|
|
rejectUnauthorized: false
|
|
|
|
};
|
2012-02-23 16:37:49 +01:00
|
|
|
|
|
|
|
var req = https.request(options, function(res) {
|
|
|
|
res.on('end', function() {
|
|
|
|
server.close();
|
|
|
|
process.exit();
|
|
|
|
});
|
2012-12-16 23:39:59 +01:00
|
|
|
res.resume();
|
2012-02-23 16:37:49 +01:00
|
|
|
});
|
|
|
|
req.end();
|
|
|
|
});
|