wwbmmm commented on code in PR #2102:
URL: https://github.com/apache/brpc/pull/2102#discussion_r1091403785


##########
src/brpc/adaptive_protocol_type.h:
##########
@@ -44,6 +44,7 @@ class AdaptiveProtocolType {
 public:
     explicit AdaptiveProtocolType() : _type(PROTOCOL_UNKNOWN) {}
     explicit AdaptiveProtocolType(ProtocolType type) : _type(type) {}
+    explicit AdaptiveProtocolType(butil::StringPiece name) { 
AssignWithString(name); }

Review Comment:
   这里可以直接调用operator=(name),就不用改那么多了



##########
src/brpc/details/ssl_helper.cpp:
##########
@@ -833,6 +874,23 @@ void Print(std::ostream& os, X509* cert, const char* sep) {
     os << butil::StringPiece(bufp, len);
 }
 
+std::string ALPNProtocolToString(const AdaptiveProtocolType& protocol) {
+    std::string name = protocol.name();
+    // Default use http 1.1 version
+    if (name.compare(0, 4, "http") == 0) {
+        name = "http/1.1";
+    }
+
+    // ALPN extension uses 1 byte to record the protocol length
+    // and it's maximum length is 255.
+    if (name.size() > CHAR_MAX) {
+        name = name.substr(0, CHAR_MAX); 
+    }
+
+    char lenght = static_cast<char>(name.size());

Review Comment:
   lenght -> length



##########
src/brpc/details/ssl_helper.cpp:
##########
@@ -521,6 +558,10 @@ SSL_CTX* CreateServerSSLContext(const std::string& 
certificate,
 
 #endif  // OPENSSL_NO_DH
 
+    // Set ALPN callback to choose application protocol.
+    if (SetServerALPNCallback(ssl_ctx.get(), alpns) != 0) {

Review Comment:
   如果alpns为空串,则不需要SetServerALPNCallback



##########
src/brpc/server.h:
##########
@@ -686,6 +688,10 @@ friend class Controller;
     ServerOptions _options;
     butil::EndPoint _listen_addr;
 
+    // ALPN extention protocol-list format. Server initialize this with alpns 
options.
+    // OpenSSL API use this variable to avoid conversion at each handshake.
+    std::string _row_alpns;

Review Comment:
   row在这里是什么意思?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to