proxygen
wangle::TLSPlaintextPeekingCallback Class Reference

#include <TLSPlaintextPeekingCallback.h>

Inheritance diagram for wangle::TLSPlaintextPeekingCallback:
wangle::PeekingAcceptorHandshakeHelper::PeekCallback

Public Member Functions

 TLSPlaintextPeekingCallback ()
 
AcceptorHandshakeHelper::UniquePtr getHelper (const std::vector< uint8_t > &bytes, const folly::SocketAddress &clientAddr, std::chrono::steady_clock::time_point acceptTime, TransportInfo &tinfo) override
 
- Public Member Functions inherited from wangle::PeekingAcceptorHandshakeHelper::PeekCallback
 PeekCallback (size_t bytesRequired)
 
virtual ~PeekCallback ()=default
 
size_t getBytesRequired () const
 

Private Types

enum  { kPeekCount = 9 }
 

Static Private Member Functions

static bool looksLikeTLS (const std::vector< uint8_t > &peekBytes)
 

Detailed Description

A peeking callback that makes it convenient to create a server that will accept both TLS and plaintext traffic.

Definition at line 28 of file TLSPlaintextPeekingCallback.h.

Member Enumeration Documentation

anonymous enum
private
Enumerator
kPeekCount 

Definition at line 30 of file TLSPlaintextPeekingCallback.h.

Constructor & Destructor Documentation

wangle::TLSPlaintextPeekingCallback::TLSPlaintextPeekingCallback ( )
inline

Definition at line 32 of file TLSPlaintextPeekingCallback.h.

References getHelper(), and looksLikeTLS().

32  :
33  PeekingAcceptorHandshakeHelper::PeekCallback(kPeekCount) {}

Member Function Documentation

AcceptorHandshakeHelper::UniquePtr wangle::TLSPlaintextPeekingCallback::getHelper ( const std::vector< uint8_t > &  bytes,
const folly::SocketAddress clientAddr,
std::chrono::steady_clock::time_point  acceptTime,
TransportInfo tinfo 
)
overridevirtual

Implements wangle::PeekingAcceptorHandshakeHelper::PeekCallback.

Definition at line 36 of file TLSPlaintextPeekingCallback.cpp.

References looksLikeTLS().

Referenced by TLSPlaintextPeekingCallback().

40  {
43  new UnencryptedAcceptorHandshakeHelper());
44  }
45 
46  return nullptr;
47 }
static bool looksLikeTLS(const std::vector< uint8_t > &peekBytes)
std::unique_ptr< AcceptorHandshakeHelper, folly::DelayedDestruction::Destructor > UniquePtr
bool wangle::TLSPlaintextPeekingCallback::looksLikeTLS ( const std::vector< uint8_t > &  peekBytes)
staticprivate

Definition at line 20 of file TLSPlaintextPeekingCallback.cpp.

References kPeekCount.

Referenced by getHelper(), and TLSPlaintextPeekingCallback().

21  {
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 }

The documentation for this class was generated from the following files: