1717#endif
1818
1919namespace node {
20+ namespace crypto {
2021
2122using namespace v8 ;
2223
@@ -307,29 +308,29 @@ static int serr(SSL *ssl, const char* func, int rv) {
307308 return 0 ;
308309}
309310
310- void SecureStream ::Initialize (Handle<Object> target) {
311+ void Connection ::Initialize (Handle<Object> target) {
311312 HandleScope scope;
312313
313- Local<FunctionTemplate> t = FunctionTemplate::New (SecureStream ::New);
314+ Local<FunctionTemplate> t = FunctionTemplate::New (Connection ::New);
314315 t->InstanceTemplate ()->SetInternalFieldCount (1 );
315- t->SetClassName (String::NewSymbol (" SecureStream " ));
316-
317- NODE_SET_PROTOTYPE_METHOD (t, " encIn" , SecureStream ::EncIn);
318- NODE_SET_PROTOTYPE_METHOD (t, " clearOut" , SecureStream ::ClearOut);
319- NODE_SET_PROTOTYPE_METHOD (t, " clearIn" , SecureStream ::ClearIn);
320- NODE_SET_PROTOTYPE_METHOD (t, " encOut" , SecureStream ::EncOut);
321- NODE_SET_PROTOTYPE_METHOD (t, " clearPending" , SecureStream ::ClearPending);
322- NODE_SET_PROTOTYPE_METHOD (t, " encPending" , SecureStream ::EncPending);
323- NODE_SET_PROTOTYPE_METHOD (t, " getPeerCertificate" , SecureStream ::GetPeerCertificate);
324- NODE_SET_PROTOTYPE_METHOD (t, " isInitFinished" , SecureStream ::IsInitFinished);
325- NODE_SET_PROTOTYPE_METHOD (t, " verifyError" , SecureStream ::VerifyError);
326- NODE_SET_PROTOTYPE_METHOD (t, " getCurrentCipher" , SecureStream ::GetCurrentCipher);
327- NODE_SET_PROTOTYPE_METHOD (t, " start" , SecureStream ::Start);
328- NODE_SET_PROTOTYPE_METHOD (t, " shutdown" , SecureStream ::Shutdown);
329- NODE_SET_PROTOTYPE_METHOD (t, " receivedShutdown" , SecureStream ::ReceivedShutdown);
330- NODE_SET_PROTOTYPE_METHOD (t, " close" , SecureStream ::Close);
331-
332- target->Set (String::NewSymbol (" SecureStream " ), t->GetFunction ());
316+ t->SetClassName (String::NewSymbol (" Connection " ));
317+
318+ NODE_SET_PROTOTYPE_METHOD (t, " encIn" , Connection ::EncIn);
319+ NODE_SET_PROTOTYPE_METHOD (t, " clearOut" , Connection ::ClearOut);
320+ NODE_SET_PROTOTYPE_METHOD (t, " clearIn" , Connection ::ClearIn);
321+ NODE_SET_PROTOTYPE_METHOD (t, " encOut" , Connection ::EncOut);
322+ NODE_SET_PROTOTYPE_METHOD (t, " clearPending" , Connection ::ClearPending);
323+ NODE_SET_PROTOTYPE_METHOD (t, " encPending" , Connection ::EncPending);
324+ NODE_SET_PROTOTYPE_METHOD (t, " getPeerCertificate" , Connection ::GetPeerCertificate);
325+ NODE_SET_PROTOTYPE_METHOD (t, " isInitFinished" , Connection ::IsInitFinished);
326+ NODE_SET_PROTOTYPE_METHOD (t, " verifyError" , Connection ::VerifyError);
327+ NODE_SET_PROTOTYPE_METHOD (t, " getCurrentCipher" , Connection ::GetCurrentCipher);
328+ NODE_SET_PROTOTYPE_METHOD (t, " start" , Connection ::Start);
329+ NODE_SET_PROTOTYPE_METHOD (t, " shutdown" , Connection ::Shutdown);
330+ NODE_SET_PROTOTYPE_METHOD (t, " receivedShutdown" , Connection ::ReceivedShutdown);
331+ NODE_SET_PROTOTYPE_METHOD (t, " close" , Connection ::Close);
332+
333+ target->Set (String::NewSymbol (" Connection " ), t->GetFunction ());
333334}
334335
335336
@@ -373,16 +374,16 @@ static int VerifyCallback(int preverify_ok, X509_STORE_CTX *ctx) {
373374 //
374375 // Since we cannot perform I/O quickly enough in this callback, we ignore
375376 // all preverify_ok errors and let the handshake continue. It is
376- // imparative that the user use SecureStream ::VerifyError after the
377+ // imparative that the user use Connection ::VerifyError after the
377378 // 'secure' callback has been made.
378379 return 1 ;
379380}
380381
381382
382- Handle<Value> SecureStream ::New (const Arguments& args) {
383+ Handle<Value> Connection ::New (const Arguments& args) {
383384 HandleScope scope;
384385
385- SecureStream *p = new SecureStream ();
386+ Connection *p = new Connection ();
386387 p->Wrap (args.Holder ());
387388
388389 if (args.Length () < 1 || !args[0 ]->IsObject ()) {
@@ -435,10 +436,10 @@ Handle<Value> SecureStream::New(const Arguments& args) {
435436}
436437
437438
438- Handle<Value> SecureStream ::EncIn (const Arguments& args) {
439+ Handle<Value> Connection ::EncIn (const Arguments& args) {
439440 HandleScope scope;
440441
441- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
442+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
442443
443444 if (args.Length () < 3 ) {
444445 return ThrowException (Exception::TypeError (
@@ -477,10 +478,10 @@ Handle<Value> SecureStream::EncIn(const Arguments& args) {
477478}
478479
479480
480- Handle<Value> SecureStream ::ClearOut (const Arguments& args) {
481+ Handle<Value> Connection ::ClearOut (const Arguments& args) {
481482 HandleScope scope;
482483
483- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
484+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
484485
485486 if (args.Length () < 3 ) {
486487 return ThrowException (Exception::TypeError (
@@ -531,28 +532,28 @@ Handle<Value> SecureStream::ClearOut(const Arguments& args) {
531532}
532533
533534
534- Handle<Value> SecureStream ::ClearPending (const Arguments& args) {
535+ Handle<Value> Connection ::ClearPending (const Arguments& args) {
535536 HandleScope scope;
536537
537- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
538+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
538539 int bytes_pending = BIO_pending (ss->bio_read_ );
539540 return scope.Close (Integer::New (bytes_pending));
540541}
541542
542543
543- Handle<Value> SecureStream ::EncPending (const Arguments& args) {
544+ Handle<Value> Connection ::EncPending (const Arguments& args) {
544545 HandleScope scope;
545546
546- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
547+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
547548 int bytes_pending = BIO_pending (ss->bio_write_ );
548549 return scope.Close (Integer::New (bytes_pending));
549550}
550551
551552
552- Handle<Value> SecureStream ::EncOut (const Arguments& args) {
553+ Handle<Value> Connection ::EncOut (const Arguments& args) {
553554 HandleScope scope;
554555
555- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
556+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
556557
557558 if (args.Length () < 3 ) {
558559 return ThrowException (Exception::TypeError (
@@ -586,10 +587,10 @@ Handle<Value> SecureStream::EncOut(const Arguments& args) {
586587}
587588
588589
589- Handle<Value> SecureStream ::ClearIn (const Arguments& args) {
590+ Handle<Value> Connection ::ClearIn (const Arguments& args) {
590591 HandleScope scope;
591592
592- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
593+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
593594
594595 if (args.Length () < 3 ) {
595596 return ThrowException (Exception::TypeError (
@@ -642,10 +643,10 @@ Handle<Value> SecureStream::ClearIn(const Arguments& args) {
642643}
643644
644645
645- Handle<Value> SecureStream ::GetPeerCertificate (const Arguments& args) {
646+ Handle<Value> Connection ::GetPeerCertificate (const Arguments& args) {
646647 HandleScope scope;
647648
648- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
649+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
649650
650651 if (ss->ssl_ == NULL ) return Undefined ();
651652 Local<Object> info = Object::New ();
@@ -700,11 +701,11 @@ Handle<Value> SecureStream::GetPeerCertificate(const Arguments& args) {
700701 return scope.Close (info);
701702}
702703
703- Handle<Value> SecureStream ::Start (const Arguments& args) {
704+ Handle<Value> Connection ::Start (const Arguments& args) {
704705 HandleScope scope;
705706 int rv;
706707
707- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
708+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
708709
709710 if (!SSL_is_init_finished (ss->ssl_ )) {
710711 if (ss->is_server_ ) {
@@ -728,10 +729,10 @@ Handle<Value> SecureStream::Start(const Arguments& args) {
728729}
729730
730731
731- Handle<Value> SecureStream ::Shutdown (const Arguments& args) {
732+ Handle<Value> Connection ::Shutdown (const Arguments& args) {
732733 HandleScope scope;
733734
734- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
735+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
735736
736737 if (ss->ssl_ == NULL ) return False ();
737738 int r = SSL_shutdown (ss->ssl_ );
@@ -740,10 +741,10 @@ Handle<Value> SecureStream::Shutdown(const Arguments& args) {
740741}
741742
742743
743- Handle<Value> SecureStream ::ReceivedShutdown (const Arguments& args) {
744+ Handle<Value> Connection ::ReceivedShutdown (const Arguments& args) {
744745 HandleScope scope;
745746
746- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
747+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
747748
748749 if (ss->ssl_ == NULL ) return False ();
749750 int r = SSL_get_shutdown (ss->ssl_ );
@@ -754,18 +755,18 @@ Handle<Value> SecureStream::ReceivedShutdown(const Arguments& args) {
754755}
755756
756757
757- Handle<Value> SecureStream ::IsInitFinished (const Arguments& args) {
758+ Handle<Value> Connection ::IsInitFinished (const Arguments& args) {
758759 HandleScope scope;
759- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
760+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
760761 if (ss->ssl_ == NULL ) return False ();
761762 return SSL_is_init_finished (ss->ssl_ ) ? True () : False ();
762763}
763764
764765
765- Handle<Value> SecureStream ::VerifyError (const Arguments& args) {
766+ Handle<Value> Connection ::VerifyError (const Arguments& args) {
766767 HandleScope scope;
767768
768- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
769+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
769770
770771 if (ss->ssl_ == NULL ) return Null ();
771772
@@ -906,10 +907,10 @@ Handle<Value> SecureStream::VerifyError(const Arguments& args) {
906907}
907908
908909
909- Handle<Value> SecureStream ::GetCurrentCipher (const Arguments& args) {
910+ Handle<Value> Connection ::GetCurrentCipher (const Arguments& args) {
910911 HandleScope scope;
911912
912- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
913+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
913914 OPENSSL_CONST SSL_CIPHER *c;
914915
915916 if ( ss->ssl_ == NULL ) return Undefined ();
@@ -923,10 +924,10 @@ Handle<Value> SecureStream::GetCurrentCipher(const Arguments& args) {
923924 return scope.Close (info);
924925}
925926
926- Handle<Value> SecureStream ::Close (const Arguments& args) {
927+ Handle<Value> Connection ::Close (const Arguments& args) {
927928 HandleScope scope;
928929
929- SecureStream *ss = ObjectWrap::Unwrap<SecureStream >(args.Holder ());
930+ Connection *ss = ObjectWrap::Unwrap<Connection >(args.Holder ());
930931
931932 if (ss->ssl_ != NULL ) {
932933 SSL_free (ss->ssl_ );
@@ -2667,7 +2668,7 @@ void InitCrypto(Handle<Object> target) {
26672668 ERR_load_crypto_strings ();
26682669
26692670 SecureContext::Initialize (target);
2670- SecureStream ::Initialize (target);
2671+ Connection ::Initialize (target);
26712672 Cipher::Initialize (target);
26722673 Decipher::Initialize (target);
26732674 Hmac::Initialize (target);
@@ -2684,7 +2685,8 @@ void InitCrypto(Handle<Object> target) {
26842685 version_symbol = NODE_PSYMBOL (" version" );
26852686}
26862687
2688+ } // namespace crypto
26872689} // namespace node
26882690
2689- NODE_MODULE (node_crypto, node::InitCrypto);
2691+ NODE_MODULE (node_crypto, node::crypto:: InitCrypto);
26902692
0 commit comments