| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b4c75a9 commit 17cb272
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,7 +26,6 @@ namespace node { | |||
| 26 | 26 | ||
| 27 | 27 | using v8::Array; | |
| 28 | 28 | using v8::ArrayBuffer; | |
| 29 | - using v8::ArrayBufferView; | ||
| 30 | 29 | using v8::BackingStore; | |
| 31 | 30 | using v8::Context; | |
| 32 | 31 | using v8::EscapableHandleScope; | |
@@ -87,18 +86,10 @@ void LogSecret( | |||
| 87 | 86 | keylog_cb(ssl.get(), line.c_str()); | |
| 88 | 87 | } | |
| 89 | 88 | ||
| 90 | - bool SetALPN(const SSLPointer& ssl, const std::string& alpn) { | ||
| 91 | - return SSL_set_alpn_protos( | ||
| 92 | - ssl.get(), | ||
| 93 | - reinterpret_cast<const uint8_t*>(alpn.c_str()), | ||
| 94 | - alpn.length()) == 0; | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - bool SetALPN(const SSLPointer& ssl, Local<Value> alpn) { | ||
| 98 | - if (!alpn->IsArrayBufferView()) | ||
| 99 | - return false; | ||
| 100 | - ArrayBufferViewContents<unsigned char> protos(alpn.As<ArrayBufferView>()); | ||
| 101 | - return SSL_set_alpn_protos(ssl.get(), protos.data(), protos.length()) == 0; | ||
| 89 | + bool SetALPN(const SSLPointer& ssl, std::string_view alpn) { | ||
| 90 | + return SSL_set_alpn_protos(ssl.get(), | ||
| 91 | + reinterpret_cast<const uint8_t*>(alpn.data()), | ||
| 92 | + alpn.length()) == 0; | ||
| 102 | 93 | } | |
| 103 | 94 | ||
| 104 | 95 | MaybeLocal<Value> GetSSLOCSPResponse( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,9 +33,8 @@ void LogSecret( | |||
| 33 | 33 | const unsigned char* secret, | |
| 34 | 34 | size_t secretlen); | |
| 35 | 35 | ||
| 36 | - bool SetALPN(const SSLPointer& ssl, const std::string& alpn); | ||
| 37 | - | ||
| 38 | - bool SetALPN(const SSLPointer& ssl, v8::Local<v8::Value> alpn); | ||
| 36 | + // TODO(tniessen): use std::u8string_view when we switch to C++20. | ||
| 37 | + bool SetALPN(const SSLPointer& ssl, std::string_view alpn); | ||
| 39 | 38 | ||
| 40 | 39 | v8::MaybeLocal<v8::Value> GetSSLOCSPResponse( | |
| 41 | 40 | Environment* env, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1530,7 +1530,8 @@ void TLSWrap::SetALPNProtocols(const FunctionCallbackInfo<Value>& args) { | |||
| 1530 | 1530 | return env->ThrowTypeError("Must give a Buffer as first argument"); | |
| 1531 | 1531 | ||
| 1532 | 1532 | if (w->is_client()) { | |
| 1533 | - CHECK(SetALPN(w->ssl_, args[0])); | ||
| 1533 | + ArrayBufferViewContents<char> protos(args[0].As<ArrayBufferView>()); | ||
| 1534 | + CHECK(SetALPN(w->ssl_, {protos.data(), protos.length()})); | ||
| 1534 | 1535 | } else { | |
| 1535 | 1536 | CHECK( | |
| 1536 | 1537 | w->object()->SetPrivate( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments