tls: de-duplicate for TLSSocket methods
Similar approach is used for `TLSWrap`, where C++ handle methods are mapped one-to-one in JS. PR-URL: https://github.com/nodejs/node/pull/22142 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
29cf335e6a
commit
3c2aa4b9f3
@ -591,10 +591,6 @@ TLSSocket.prototype.setMaxSendFragment = function setMaxSendFragment(size) {
|
||||
return this._handle.setMaxSendFragment(size) === 1;
|
||||
};
|
||||
|
||||
TLSSocket.prototype.getTLSTicket = function getTLSTicket() {
|
||||
return this._handle.getTLSTicket();
|
||||
};
|
||||
|
||||
TLSSocket.prototype._handleTimeout = function() {
|
||||
this._emitTLSError(new ERR_TLS_HANDSHAKE_TIMEOUT());
|
||||
};
|
||||
@ -671,51 +667,25 @@ TLSSocket.prototype.getPeerCertificate = function(detailed) {
|
||||
return null;
|
||||
};
|
||||
|
||||
TLSSocket.prototype.getFinished = function() {
|
||||
if (this._handle)
|
||||
return this._handle.getFinished();
|
||||
};
|
||||
// Proxy TLSSocket handle methods
|
||||
function makeSocketMethodProxy(name) {
|
||||
return function socketMethodProxy(...args) {
|
||||
if (this._handle)
|
||||
return this._handle[name].apply(this._handle, args);
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
TLSSocket.prototype.getPeerFinished = function() {
|
||||
if (this._handle)
|
||||
return this._handle.getPeerFinished();
|
||||
};
|
||||
|
||||
TLSSocket.prototype.getSession = function() {
|
||||
if (this._handle) {
|
||||
return this._handle.getSession();
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
TLSSocket.prototype.isSessionReused = function() {
|
||||
if (this._handle) {
|
||||
return this._handle.isSessionReused();
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
[
|
||||
'getFinished', 'getPeerFinished', 'getSession', 'isSessionReused',
|
||||
'getEphemeralKeyInfo', 'getProtocol', 'getTLSTicket'
|
||||
].forEach((method) => {
|
||||
TLSSocket.prototype[method] = makeSocketMethodProxy(method);
|
||||
});
|
||||
|
||||
TLSSocket.prototype.getCipher = function(err) {
|
||||
if (this._handle) {
|
||||
if (this._handle)
|
||||
return this._handle.getCurrentCipher();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
TLSSocket.prototype.getEphemeralKeyInfo = function() {
|
||||
if (this._handle)
|
||||
return this._handle.getEphemeralKeyInfo();
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
TLSSocket.prototype.getProtocol = function() {
|
||||
if (this._handle)
|
||||
return this._handle.getProtocol();
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user