crypto: use consistent conn object unwrapping
We use `Foo:Unwrap(args.This())` everywhere else, let's use the same idiom for Connection::Unwrap().
This commit is contained in:
parent
4901353b98
commit
d4ad5d1151
@ -1282,7 +1282,7 @@ void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) {
|
|||||||
void Connection::EncIn(const FunctionCallbackInfo<Value>& args) {
|
void Connection::EncIn(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (args.Length() < 3) {
|
if (args.Length() < 3) {
|
||||||
return ThrowTypeError("Takes 3 parameters");
|
return ThrowTypeError("Takes 3 parameters");
|
||||||
@ -1332,7 +1332,7 @@ void Connection::EncIn(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::ClearOut(const FunctionCallbackInfo<Value>& args) {
|
void Connection::ClearOut(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (args.Length() < 3) {
|
if (args.Length() < 3) {
|
||||||
return ThrowTypeError("Takes 3 parameters");
|
return ThrowTypeError("Takes 3 parameters");
|
||||||
@ -1386,7 +1386,7 @@ void Connection::ClearOut(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
void Connection::ClearPending(const FunctionCallbackInfo<Value>& args) {
|
void Connection::ClearPending(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
int bytes_pending = BIO_pending(conn->bio_read_);
|
int bytes_pending = BIO_pending(conn->bio_read_);
|
||||||
args.GetReturnValue().Set(bytes_pending);
|
args.GetReturnValue().Set(bytes_pending);
|
||||||
}
|
}
|
||||||
@ -1394,7 +1394,7 @@ void Connection::ClearPending(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
void Connection::EncPending(const FunctionCallbackInfo<Value>& args) {
|
void Connection::EncPending(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
int bytes_pending = BIO_pending(conn->bio_write_);
|
int bytes_pending = BIO_pending(conn->bio_write_);
|
||||||
args.GetReturnValue().Set(bytes_pending);
|
args.GetReturnValue().Set(bytes_pending);
|
||||||
}
|
}
|
||||||
@ -1403,7 +1403,7 @@ void Connection::EncPending(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::EncOut(const FunctionCallbackInfo<Value>& args) {
|
void Connection::EncOut(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (args.Length() < 3) {
|
if (args.Length() < 3) {
|
||||||
return ThrowTypeError("Takes 3 parameters");
|
return ThrowTypeError("Takes 3 parameters");
|
||||||
@ -1434,7 +1434,7 @@ void Connection::EncOut(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::ClearIn(const FunctionCallbackInfo<Value>& args) {
|
void Connection::ClearIn(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (args.Length() < 3) {
|
if (args.Length() < 3) {
|
||||||
return ThrowTypeError("Takes 3 parameters");
|
return ThrowTypeError("Takes 3 parameters");
|
||||||
@ -1489,7 +1489,7 @@ void Connection::ClearIn(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (conn->ssl_ == NULL) return;
|
if (conn->ssl_ == NULL) return;
|
||||||
Local<Object> info = Object::New();
|
Local<Object> info = Object::New();
|
||||||
@ -1616,7 +1616,7 @@ void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::GetSession(const FunctionCallbackInfo<Value>& args) {
|
void Connection::GetSession(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (conn->ssl_ == NULL) return;
|
if (conn->ssl_ == NULL) return;
|
||||||
|
|
||||||
@ -1637,7 +1637,7 @@ void Connection::GetSession(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::SetSession(const FunctionCallbackInfo<Value>& args) {
|
void Connection::SetSession(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (args.Length() < 1 ||
|
if (args.Length() < 1 ||
|
||||||
(!args[0]->IsString() && !Buffer::HasInstance(args[0]))) {
|
(!args[0]->IsString() && !Buffer::HasInstance(args[0]))) {
|
||||||
@ -1675,7 +1675,7 @@ void Connection::SetSession(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::LoadSession(const FunctionCallbackInfo<Value>& args) {
|
void Connection::LoadSession(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (args.Length() >= 1 && Buffer::HasInstance(args[0])) {
|
if (args.Length() >= 1 && Buffer::HasInstance(args[0])) {
|
||||||
ssize_t slen = Buffer::Length(args[0].As<Object>());
|
ssize_t slen = Buffer::Length(args[0].As<Object>());
|
||||||
@ -1697,7 +1697,7 @@ void Connection::LoadSession(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
void Connection::IsSessionReused(const FunctionCallbackInfo<Value>& args) {
|
void Connection::IsSessionReused(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
bool yes = conn->ssl_ && SSL_session_reused(conn->ssl_);
|
bool yes = conn->ssl_ && SSL_session_reused(conn->ssl_);
|
||||||
args.GetReturnValue().Set(yes);
|
args.GetReturnValue().Set(yes);
|
||||||
}
|
}
|
||||||
@ -1706,7 +1706,7 @@ void Connection::IsSessionReused(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::Start(const FunctionCallbackInfo<Value>& args) {
|
void Connection::Start(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
if (!SSL_is_init_finished(conn->ssl_)) {
|
if (!SSL_is_init_finished(conn->ssl_)) {
|
||||||
@ -1731,7 +1731,7 @@ void Connection::Start(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::Shutdown(const FunctionCallbackInfo<Value>& args) {
|
void Connection::Shutdown(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (conn->ssl_ == NULL) {
|
if (conn->ssl_ == NULL) {
|
||||||
return args.GetReturnValue().Set(false);
|
return args.GetReturnValue().Set(false);
|
||||||
@ -1746,7 +1746,7 @@ void Connection::Shutdown(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
void Connection::ReceivedShutdown(const FunctionCallbackInfo<Value>& args) {
|
void Connection::ReceivedShutdown(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
bool yes =
|
bool yes =
|
||||||
conn->ssl_ && SSL_get_shutdown(conn->ssl_) == SSL_RECEIVED_SHUTDOWN;
|
conn->ssl_ && SSL_get_shutdown(conn->ssl_) == SSL_RECEIVED_SHUTDOWN;
|
||||||
args.GetReturnValue().Set(yes);
|
args.GetReturnValue().Set(yes);
|
||||||
@ -1755,7 +1755,7 @@ void Connection::ReceivedShutdown(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
void Connection::IsInitFinished(const FunctionCallbackInfo<Value>& args) {
|
void Connection::IsInitFinished(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
bool yes = conn->ssl_ && SSL_is_init_finished(conn->ssl_);
|
bool yes = conn->ssl_ && SSL_is_init_finished(conn->ssl_);
|
||||||
args.GetReturnValue().Set(yes);
|
args.GetReturnValue().Set(yes);
|
||||||
}
|
}
|
||||||
@ -1764,7 +1764,7 @@ void Connection::IsInitFinished(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::VerifyError(const FunctionCallbackInfo<Value>& args) {
|
void Connection::VerifyError(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (conn->ssl_ == NULL) {
|
if (conn->ssl_ == NULL) {
|
||||||
return args.GetReturnValue().SetNull();
|
return args.GetReturnValue().SetNull();
|
||||||
@ -1920,7 +1920,7 @@ void Connection::VerifyError(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::GetCurrentCipher(const FunctionCallbackInfo<Value>& args) {
|
void Connection::GetCurrentCipher(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
if (conn->ssl_ == NULL) return;
|
if (conn->ssl_ == NULL) return;
|
||||||
|
|
||||||
OPENSSL_CONST SSL_CIPHER *c = SSL_get_current_cipher(conn->ssl_);
|
OPENSSL_CONST SSL_CIPHER *c = SSL_get_current_cipher(conn->ssl_);
|
||||||
@ -1938,7 +1938,7 @@ void Connection::GetCurrentCipher(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::Close(const FunctionCallbackInfo<Value>& args) {
|
void Connection::Close(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (conn->ssl_ != NULL) {
|
if (conn->ssl_ != NULL) {
|
||||||
SSL_free(conn->ssl_);
|
SSL_free(conn->ssl_);
|
||||||
@ -1951,7 +1951,7 @@ void Connection::Close(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::GetNegotiatedProto(const FunctionCallbackInfo<Value>& args) {
|
void Connection::GetNegotiatedProto(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (conn->is_server_) {
|
if (conn->is_server_) {
|
||||||
const unsigned char* npn_proto;
|
const unsigned char* npn_proto;
|
||||||
@ -1974,7 +1974,7 @@ void Connection::GetNegotiatedProto(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) {
|
void Connection::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (args.Length() < 1 || !Buffer::HasInstance(args[0])) {
|
if (args.Length() < 1 || !Buffer::HasInstance(args[0])) {
|
||||||
return ThrowError("Must give a Buffer as first argument");
|
return ThrowError("Must give a Buffer as first argument");
|
||||||
@ -1989,7 +1989,7 @@ void Connection::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::GetServername(const FunctionCallbackInfo<Value>& args) {
|
void Connection::GetServername(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (conn->is_server_ && !conn->servername_.IsEmpty()) {
|
if (conn->is_server_ && !conn->servername_.IsEmpty()) {
|
||||||
args.GetReturnValue().Set(conn->servername_);
|
args.GetReturnValue().Set(conn->servername_);
|
||||||
@ -2002,7 +2002,7 @@ void Connection::GetServername(const FunctionCallbackInfo<Value>& args) {
|
|||||||
void Connection::SetSNICallback(const FunctionCallbackInfo<Value>& args) {
|
void Connection::SetSNICallback(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Connection* conn = Connection::Unwrap(args);
|
Connection* conn = Connection::Unwrap(args.This());
|
||||||
|
|
||||||
if (args.Length() < 1 || !args[0]->IsFunction()) {
|
if (args.Length() < 1 || !args[0]->IsFunction()) {
|
||||||
return ThrowError("Must give a Function as first argument");
|
return ThrowError("Must give a Function as first argument");
|
||||||
|
@ -201,8 +201,8 @@ class Connection : ObjectWrap {
|
|||||||
void ClearError();
|
void ClearError();
|
||||||
void SetShutdownFlags();
|
void SetShutdownFlags();
|
||||||
|
|
||||||
static Connection* Unwrap(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
static Connection* Unwrap(v8::Local<v8::Object> object) {
|
||||||
Connection* conn = ObjectWrap::Unwrap<Connection>(args.This());
|
Connection* conn = ObjectWrap::Unwrap<Connection>(object);
|
||||||
conn->ClearError();
|
conn->ClearError();
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user