@@ -591,10 +591,6 @@ TLSSocket.prototype.setMaxSendFragment = function setMaxSendFragment(size) {
591
591
return this . _handle . setMaxSendFragment ( size ) === 1 ;
592
592
} ;
593
593
594
- TLSSocket . prototype . getTLSTicket = function getTLSTicket ( ) {
595
- return this . _handle . getTLSTicket ( ) ;
596
- } ;
597
-
598
594
TLSSocket . prototype . _handleTimeout = function ( ) {
599
595
this . _emitTLSError ( new ERR_TLS_HANDSHAKE_TIMEOUT ( ) ) ;
600
596
} ;
@@ -671,51 +667,25 @@ TLSSocket.prototype.getPeerCertificate = function(detailed) {
671
667
return null ;
672
668
} ;
673
669
674
- TLSSocket . prototype . getFinished = function ( ) {
675
- if ( this . _handle )
676
- return this . _handle . getFinished ( ) ;
677
- } ;
678
-
679
- TLSSocket . prototype . getPeerFinished = function ( ) {
680
- if ( this . _handle )
681
- return this . _handle . getPeerFinished ( ) ;
682
- } ;
683
-
684
- TLSSocket . prototype . getSession = function ( ) {
685
- if ( this . _handle ) {
686
- return this . _handle . getSession ( ) ;
687
- }
688
-
689
- return null ;
690
- } ;
691
-
692
- TLSSocket . prototype . isSessionReused = function ( ) {
693
- if ( this . _handle ) {
694
- return this . _handle . isSessionReused ( ) ;
695
- }
696
-
697
- return null ;
698
- } ;
699
-
700
- TLSSocket . prototype . getCipher = function ( err ) {
701
- if ( this . _handle ) {
702
- return this . _handle . getCurrentCipher ( ) ;
703
- } else {
670
+ // Proxy TLSSocket handle methods
671
+ function makeSocketMethodProxy ( name ) {
672
+ return function socketMethodProxy ( ...args ) {
673
+ if ( this . _handle )
674
+ return this . _handle [ name ] . apply ( this . _handle , args ) ;
704
675
return null ;
705
- }
706
- } ;
707
-
708
- TLSSocket . prototype . getEphemeralKeyInfo = function ( ) {
709
- if ( this . _handle )
710
- return this . _handle . getEphemeralKeyInfo ( ) ;
676
+ } ;
677
+ }
711
678
712
- return null ;
713
- } ;
679
+ [
680
+ 'getFinished' , 'getPeerFinished' , 'getSession' , 'isSessionReused' ,
681
+ 'getEphemeralKeyInfo' , 'getProtocol' , 'getTLSTicket'
682
+ ] . forEach ( ( method ) => {
683
+ TLSSocket . prototype [ method ] = makeSocketMethodProxy ( method ) ;
684
+ } ) ;
714
685
715
- TLSSocket . prototype . getProtocol = function ( ) {
686
+ TLSSocket . prototype . getCipher = function ( err ) {
716
687
if ( this . _handle )
717
- return this . _handle . getProtocol ( ) ;
718
-
688
+ return this . _handle . getCurrentCipher ( ) ;
719
689
return null ;
720
690
} ;
721
691
0 commit comments