Browse Source

Add receivedShutdown() binding

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
70baeba8a9
  1. 3
      lib/tls.js
  2. 21
      src/node_crypto.cc
  3. 1
      src/node_crypto.h

3
lib/tls.js

@ -150,9 +150,6 @@ function SecurePair(credentials, isServer, requestCert, rejectUnauthorized) {
}
this._secureEstablished = false;
this._encInPending = [];
this._clearInPending = [];
this._rejectUnauthorized = rejectUnauthorized ? true : false;
this._requestCert = requestCert ? true : false;

21
src/node_crypto.cc

@ -326,6 +326,7 @@ void SecureStream::Initialize(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "getCurrentCipher", SecureStream::GetCurrentCipher);
NODE_SET_PROTOTYPE_METHOD(t, "start", SecureStream::Start);
NODE_SET_PROTOTYPE_METHOD(t, "shutdown", SecureStream::Shutdown);
NODE_SET_PROTOTYPE_METHOD(t, "receivedShutdown", SecureStream::ReceivedShutdown);
NODE_SET_PROTOTYPE_METHOD(t, "close", SecureStream::Close);
target->Set(String::NewSymbol("SecureStream"), t->GetFunction());
@ -726,15 +727,29 @@ Handle<Value> SecureStream::Start(const Arguments& args) {
return True();
}
Handle<Value> SecureStream::Shutdown(const Arguments& args) {
HandleScope scope;
SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder());
if (ss->ssl_ == NULL) return False();
if (SSL_shutdown(ss->ssl_) == 1) {
return True();
}
int r = SSL_shutdown(ss->ssl_);
return scope.Close(Integer::New(r));
}
Handle<Value> SecureStream::ReceivedShutdown(const Arguments& args) {
HandleScope scope;
SecureStream *ss = ObjectWrap::Unwrap<SecureStream>(args.Holder());
if (ss->ssl_ == NULL) return False();
int r = SSL_get_shutdown(ss->ssl_);
if (r | SSL_RECEIVED_SHUTDOWN) return True();
return False();
}

1
src/node_crypto.h

@ -69,6 +69,7 @@ class SecureStream : ObjectWrap {
static v8::Handle<v8::Value> VerifyError(const v8::Arguments& args);
static v8::Handle<v8::Value> GetCurrentCipher(const v8::Arguments& args);
static v8::Handle<v8::Value> Shutdown(const v8::Arguments& args);
static v8::Handle<v8::Value> ReceivedShutdown(const v8::Arguments& args);
static v8::Handle<v8::Value> Start(const v8::Arguments& args);
static v8::Handle<v8::Value> Close(const v8::Arguments& args);

Loading…
Cancel
Save