From 08f64cbb466e2db910312d26beb4a2bf486367b6 Mon Sep 17 00:00:00 2001 From: Petr Lapukhov Date: Wed, 21 Jun 2017 07:41:46 -0700 Subject: [PATCH] Have reserved sockopt to disable TSOCKS Summary: as title, similar to TTLS Reviewed By: djwatson Differential Revision: D5284200 fbshipit-source-id: 7eb95668740b239349c6e73f3b152e6506671072 --- folly/io/async/AsyncSocket.cpp | 5 +++++ folly/io/async/AsyncSocket.h | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/folly/io/async/AsyncSocket.cpp b/folly/io/async/AsyncSocket.cpp index 2ecfbb49..46cc0d3b 100644 --- a/folly/io/async/AsyncSocket.cpp +++ b/folly/io/async/AsyncSocket.cpp @@ -520,6 +520,11 @@ int AsyncSocket::socketConnect(const struct sockaddr* saddr, socklen_t len) { // Ignore return value, errors are ok setsockopt(fd_, SOL_SOCKET, SO_NO_TRANSPARENT_TLS, nullptr, 0); } + if (noTSocks_) { + VLOG(4) << "Disabling TSOCKS for fd " << fd_; + // Ignore return value, errors are ok + setsockopt(fd_, SOL_SOCKET, SO_NO_TSOCKS, nullptr, 0); + } #endif int rv = fsp::connect(fd_, saddr, len); if (rv < 0) { diff --git a/folly/io/async/AsyncSocket.h b/folly/io/async/AsyncSocket.h index 1bf1b4de..4b0fd069 100644 --- a/folly/io/async/AsyncSocket.h +++ b/folly/io/async/AsyncSocket.h @@ -68,6 +68,10 @@ namespace folly { #define SO_NO_TRANSPARENT_TLS 200 #endif +#if defined __linux__ && !defined SO_NO_TSOCKS +#define SO_NO_TSOCKS 201 +#endif + #ifdef _MSC_VER // We do a dynamic_cast on this, in // AsyncTransportWrapper::getUnderlyingTransport so be safe and @@ -761,6 +765,10 @@ class AsyncSocket : virtual public AsyncTransportWrapper { noTransparentTls_ = true; } + void disableTSocks() { + noTSocks_ = true; + } + enum class StateEnum : uint8_t { UNINIT, CONNECTING, @@ -1157,6 +1165,7 @@ class AsyncSocket : virtual public AsyncTransportWrapper { bool tfoAttempted_{false}; bool tfoFinished_{false}; bool noTransparentTls_{false}; + bool noTSocks_{false}; // Whether to track EOR or not. bool trackEor_{false}; -- 2.34.1