本文整理汇总了TypeScript中deferred.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: deferred
_startControlChannelServer():Promise {
var result = deferred();
var port = config.controlChannelPort;
var serverOptions = {
key: keys.privateKey,
cert: keys.certificate,
ca: [keys.certificate],
requestCert: true,
rejectUnauthorized: true
};
https.createServer(serverOptions, (req, res) => {
var path = this._pathForRequest(req);
console.log(req.connection.getPeerCertificate());
console.log(req.secure);
console.log(req.client.authorized);
}).listen(port, function(err) {
if (err) {
result.reject('Unable to start control channel server: ' + err);
} else {
console.log('Listening for control channel traffic on port', port);
result.resolve();
}
});
return result.promise;
}
开发者ID:PowerOlive,项目名称:lantern-node,代码行数:27,代码来源:ControlChannel.ts
示例2: _authenticate
private _authenticate(req, res):Promise {
var result = deferred();
var cert = '';
req.on('data', function (data) {
cert += data;
});
req.on('end', function () {
res.write(keys.sign(cert));
res.end();
});
result.resolve();
return result;
}
开发者ID:PowerOlive,项目名称:lantern-node,代码行数:13,代码来源:ControlChannel.ts
示例3: requestAuthentication
requestAuthentication():Promise {
var result = deferred();
var sponsor = config.sponsor;
if (!sponsor) {
console.log('No sponsor configured, skipping authentication');
result.resolve();
} else {
var options = {
// TODO: actually check the server's certificate against our trusted ones
host: sponsor.ip,
port: sponsor.port + 1,
path: '/authenticate',
method: 'POST',
key: keys.privateKey,
cert: keys.certificate,
ca: keys.trustedCertificates,
rejectUnauthorized: true
};
var req = https.request(options, function(res) {
var cert = '';
res.on('data', function (data) {
cert += data;
});
res.on('end', function () {
console.log('Got signed certificate');
var newOptions = {
// TODO: actually check the server's certificate against our trusted ones
host: sponsor.ip,
port: sponsor.port,
path: '/',
method: 'GET',
key: keys.privateKey,
cert: cert,
ca: keys.trustedCertificates,
rejectUnauthorized: true
};
var newReq = https.request(newOptions, function(res) {
});
newReq.on('error', function(error) {
console.log(error);
});
newReq.end();
});
});
req.write(keys.certificate);
req.end();
}
return result.promise;
}
开发者ID:PowerOlive,项目名称:lantern-node,代码行数:50,代码来源:ControlChannel.ts
示例4: start
start() {
var port = config.controlChannelPort;
var result = deferred();
https.createServer({key: keys.privateKey, cert: keys.certificate}, function(req, res){
res.end("o hai!")
}).listen(port, function(err) {
if (err) {
result.reject('Unable to start control channel server: ', err);
} else {
console.log('Control channel listening on port', port);
result.resolve();
}
});
return result.promise;
}
开发者ID:oxtoacart,项目名称:lantern-node,代码行数:15,代码来源:controlchannel.ts
注:本文中的deferred.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论