proxygen
ServerSocketConfig.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 
22 #include <wangle/ssl/SSLUtil.h>
25 
26 #include <boost/optional.hpp>
27 #include <chrono>
28 #include <fcntl.h>
29 #include <folly/Random.h>
30 #include <folly/SocketAddress.h>
31 #include <folly/String.h>
34 #include <list>
35 #include <string>
36 #include <sys/stat.h>
37 #include <sys/types.h>
38 
39 namespace wangle {
40 
50  // generate a single random current seed
51  uint8_t seed[32];
52  folly::Random::secureRandom(seed, sizeof(seed));
54  SSLUtil::hexlify(std::string((char *)seed, sizeof(seed))));
55  }
56 
57  bool isSSL() const { return !(sslContextConfigs.empty()); }
58 
63  const folly::AsyncSocket::OptionMap& opts) {
65  }
68  return socketOptions_;
69  }
71  getSocketOptions() const {
72  return socketOptions_;
73  }
74 
75  bool hasExternalPrivateKey() const {
76  for (const auto& cfg : sslContextConfigs) {
77  if (!cfg.isLocalPrivateKey) {
78  return true;
79  }
80  }
81  return false;
82  }
83 
88 
93 
98 
102  std::chrono::milliseconds connectionIdleTimeout{600000};
103 
107  std::chrono::milliseconds sslHandshakeTimeout{60000};
108 
113 
117  SSLCacheOptions sslCacheOptions{std::chrono::seconds(0), 20480, 200};
118 
125 
130 
134  std::vector<SSLContextConfig> sslContextConfigs;
135 
140  bool strictSSL{true};
141 
146 
153  bool enableTCPFastOpen{false};
154 
159 
161 
162  private:
164 };
165 
166 } // namespace wangle
std::vector< std::string > currentSeeds
folly::AsyncSocket::OptionMap & getSocketOptions()
static std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value, T >::type secureRandom()
Definition: Random.h:112
std::chrono::milliseconds connectionIdleTimeout
static const int seed
const folly::AsyncSocket::OptionMap & getSocketOptions() const
std::map< OptionKey, int > OptionMap
Definition: AsyncSocket.h:376
folly::SocketAddress bindAddress
void setSocketOptions(const folly::AsyncSocket::OptionMap &opts)
sa_family_t getFamily() const
std::chrono::milliseconds sslHandshakeTimeout
folly::AsyncSocket::OptionMap socketOptions_
TLSTicketKeySeeds initialTicketSeeds
const char * string
Definition: Conv.cpp:212
static std::string hexlify(const std::string &binary)
Definition: SSLUtil.h:150
AsyncSocket::OptionMap filterIPSocketOptions(const AsyncSocket::OptionMap &allOptions, const int addrFamily)
std::vector< SSLContextConfig > sslContextConfigs