proxygen
SSLAcceptorHandshakeHelper.h
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  */
16 #pragma once
17 
18 #include <chrono>
19 #include <folly/SocketAddress.h>
25 
26 namespace wangle {
27 
30  public:
32  const folly::SocketAddress& clientAddr,
33  std::chrono::steady_clock::time_point acceptTime,
34  TransportInfo& tinfo) :
35  clientAddr_(clientAddr),
36  acceptTime_(acceptTime),
37  tinfo_(tinfo) {}
38 
39  void start(
41  AcceptorHandshakeHelper::Callback* callback) noexcept override;
42 
44  sslError_ = reason;
45  if (socket_) {
46  socket_->closeNow();
47  }
48  }
49 
50  static void fillSSLTransportInfoFields(
51  folly::AsyncSSLSocket* sock, TransportInfo& tinfo);
52 
53  protected:
54  // AsyncSSLSocket::HandshakeCallback API
55  void handshakeSuc(folly::AsyncSSLSocket* sock) noexcept override;
57  const folly::AsyncSocketException& ex) noexcept override;
58 
62  std::chrono::steady_clock::time_point acceptTime_;
65 };
66 
69  public:
71  PeekingAcceptorHandshakeHelper::PeekCallback(0) {}
72 
74  const std::vector<uint8_t>& /* bytes */,
75  const folly::SocketAddress& clientAddr,
76  std::chrono::steady_clock::time_point acceptTime,
77  TransportInfo& tinfo) override {
79  clientAddr, acceptTime, tinfo));
80  }
81 };
82 
83 }
void handshakeSuc(folly::AsyncSSLSocket *sock) noexceptoverride
SSLErrorEnum
Definition: SSLUtil.h:42
SSLAcceptorHandshakeHelper(const folly::SocketAddress &clientAddr, std::chrono::steady_clock::time_point acceptTime, TransportInfo &tinfo)
void dropConnection(SSLErrorEnum reason=SSLErrorEnum::NO_ERROR) override
void start(folly::AsyncSSLSocket::UniquePtr sock, AcceptorHandshakeHelper::Callback *callback) noexceptoverride
folly::AsyncSSLSocket::UniquePtr socket_
AcceptorHandshakeHelper::UniquePtr getHelper(const std::vector< uint8_t > &, const folly::SocketAddress &clientAddr, std::chrono::steady_clock::time_point acceptTime, TransportInfo &tinfo) override
requires E e noexcept(noexcept(s.error(std::move(e))))
std::unique_ptr< AsyncSSLSocket, Destructor > UniquePtr
void handshakeErr(folly::AsyncSSLSocket *sock, const folly::AsyncSocketException &ex) noexceptoverride
static void fillSSLTransportInfoFields(folly::AsyncSSLSocket *sock, TransportInfo &tinfo)
const folly::SocketAddress & clientAddr_
std::chrono::steady_clock::time_point acceptTime_
std::unique_ptr< AcceptorHandshakeHelper, folly::DelayedDestruction::Destructor > UniquePtr
AcceptorHandshakeHelper::Callback * callback_