proxygen
TLSPlaintextPeekingCallback.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
17 
18 namespace wangle {
19 
21  const std::vector<uint8_t>& bytes) {
22  CHECK_GE(bytes.size(), kPeekCount);
23  // TLS starts with
24  // 0: 0x16 - handshake magic
25  // 1: 0x03 - SSL major version
26  // 2: 0x00 to 0x03 - minor version
27  // 3-4: Length
28  // 5: 0x01 - Handshake type (Client Hello)
29  if (bytes[0] != 0x16 || bytes[1] != 0x03 || bytes[5] != 0x01) {
30  return false;
31  }
32  return true;
33 }
34 
37  const std::vector<uint8_t>& bytes,
38  const folly::SocketAddress& /* clientAddr */,
39  std::chrono::steady_clock::time_point /* acceptTime */,
40  TransportInfo&) {
44  }
45 
46  return nullptr;
47 }
48 
49 }
static bool looksLikeTLS(const std::vector< uint8_t > &peekBytes)
AcceptorHandshakeHelper::UniquePtr getHelper(const std::vector< uint8_t > &bytes, const folly::SocketAddress &clientAddr, std::chrono::steady_clock::time_point acceptTime, TransportInfo &tinfo) override
std::unique_ptr< AcceptorHandshakeHelper, folly::DelayedDestruction::Destructor > UniquePtr