diff --git a/uds/samples/encryptor/udss.ini b/uds/samples/encryptor/udss.ini index 4a60e40..f1aec47 100644 --- a/uds/samples/encryptor/udss.ini +++ b/uds/samples/encryptor/udss.ini @@ -8,7 +8,6 @@ inbound-port=10000 outbound-ip=:: outbound-port=20000 turbo=true -inversion=true backlog=511 fast-open=true keep-alived=true diff --git a/uds/samples/ssl/udss.ini b/uds/samples/ssl/udss.ini index d0a62e0..0802d31 100644 --- a/uds/samples/ssl/udss.ini +++ b/uds/samples/ssl/udss.ini @@ -8,7 +8,6 @@ inbound-port=10000 outbound-ip=:: outbound-port=20000 turbo=true -inversion=true backlog=511 fast-open=true keep-alived=true diff --git a/uds/samples/tcp/udss.ini b/uds/samples/tcp/udss.ini index 4f15631..6a075df 100644 --- a/uds/samples/tcp/udss.ini +++ b/uds/samples/tcp/udss.ini @@ -8,7 +8,6 @@ inbound-port=10000 outbound-ip=:: outbound-port=20000 turbo=true -inversion=true backlog=511 fast-open=true keep-alived=true diff --git a/uds/samples/tls/udss.ini b/uds/samples/tls/udss.ini index 096a30d..089988f 100644 --- a/uds/samples/tls/udss.ini +++ b/uds/samples/tls/udss.ini @@ -8,7 +8,6 @@ inbound-port=10000 outbound-ip=:: outbound-port=20000 turbo=true -inversion=true backlog=511 fast-open=true keep-alived=true diff --git a/uds/samples/websocket+ssl/udss.ini b/uds/samples/websocket+ssl/udss.ini index 8898592..faa8cb1 100644 --- a/uds/samples/websocket+ssl/udss.ini +++ b/uds/samples/websocket+ssl/udss.ini @@ -8,7 +8,6 @@ inbound-port=10000 outbound-ip=:: outbound-port=20000 turbo=true -inversion=true backlog=511 fast-open=true keep-alived=true diff --git a/uds/samples/websocket+tls/udss.ini b/uds/samples/websocket+tls/udss.ini index 477219e..b8bc63d 100644 --- a/uds/samples/websocket+tls/udss.ini +++ b/uds/samples/websocket+tls/udss.ini @@ -8,7 +8,6 @@ inbound-port=10000 outbound-ip=:: outbound-port=20000 turbo=true -inversion=true backlog=511 fast-open=true keep-alived=true diff --git a/uds/samples/websocket/udss.ini b/uds/samples/websocket/udss.ini index 41ae5a1..3bbacdd 100644 --- a/uds/samples/websocket/udss.ini +++ b/uds/samples/websocket/udss.ini @@ -8,7 +8,6 @@ inbound-port=10000 outbound-ip=:: outbound-port=20000 turbo=true -inversion=true backlog=511 fast-open=true keep-alived=true diff --git a/uds/uds/client/Router.cpp b/uds/uds/client/Router.cpp index 7086848..cc06fb3 100644 --- a/uds/uds/client/Router.cpp +++ b/uds/uds/client/Router.cpp @@ -156,17 +156,6 @@ namespace uds { uds::threading::ClearTimeout(constantof(timeout)); } }; - static const auto CloseIfNotSuccess = [](bool success, const TimeoutPtr& timeout, const AsioTcpSocket& network, const ITransmissionPtr& inbound, const ITransmissionPtr& outbound) noexcept { - if (!success) { - ClearTimeout(timeout); - if (outbound) { - outbound->Close(); - } - inbound->Close(); - Socket::Closesocket(network); - } - return success; - }; const std::shared_ptr references = GetReference(); const AsioTcpSocket network = socket; @@ -184,21 +173,9 @@ namespace uds { return ResolveAddress(configuration_->Outbound.Domain, configuration_->Outbound.IP, configuration_->Outbound.Port, [channelId, inbound, timeout, network, references, this](const boost::asio::ip::tcp::endpoint& remoteEP) noexcept { if (!ConnectConnection(inbound->GetContext(), channelId, remoteEP, - [inbound, timeout, network, references, this](const ITransmissionPtr& transmission, int channelId) noexcept { - ITransmissionPtr outbound = transmission; - return CloseIfNotSuccess(Connection::HelloAsync(outbound, - [channelId, inbound, outbound, timeout, network, references, this](bool success) noexcept { - ClearTimeout(timeout); - if (success) { - if (channelId >> 31) { - success = Accept(network, channelId, outbound, inbound); - } - else { - success = Accept(network, channelId, inbound, outbound); - } - } - CloseIfNotSuccess(success, timeout, network, inbound, outbound); - }), timeout, network, inbound, outbound); + [inbound, timeout, network, references, this](const ITransmissionPtr& outbound, int channelId) noexcept { + ClearTimeout(timeout); + return Accept(network, channelId, inbound, outbound); })) { ClearTimeout(timeout); inbound->Close(); diff --git a/uds/uds/configuration/AppConfiguration.cpp b/uds/uds/configuration/AppConfiguration.cpp index 0906283..9443333 100644 --- a/uds/uds/configuration/AppConfiguration.cpp +++ b/uds/uds/configuration/AppConfiguration.cpp @@ -185,7 +185,6 @@ namespace uds { configuration->Outbound.Port = section.GetValue("outbound-port"); configuration->FastOpen = section.GetValue("fast-open"); configuration->Turbo = section.GetValue("turbo"); - configuration->Inversion = section.GetValue("inversion"); configuration->Connect.Timeout = section.GetValue("connect.timeout"); configuration->Handshake.Timeout = section.GetValue("handshake.timeout"); configuration->Inbound.Domain = false; diff --git a/uds/uds/configuration/AppConfiguration.h b/uds/uds/configuration/AppConfiguration.h index 391d658..79fcfda 100644 --- a/uds/uds/configuration/AppConfiguration.h +++ b/uds/uds/configuration/AppConfiguration.h @@ -24,7 +24,6 @@ namespace uds { } Inbound, Outbound; int Alignment = 0; int Backlog = 511; - bool Inversion = false; bool FastOpen = false; bool Turbo = false; bool KeepAlived = false; diff --git a/uds/uds/server/Switches.cpp b/uds/uds/server/Switches.cpp index bd188db..ac547c9 100644 --- a/uds/uds/server/Switches.cpp +++ b/uds/uds/server/Switches.cpp @@ -20,7 +20,7 @@ namespace uds { namespace server { Switches::Switches(const std::shared_ptr& hosting, const std::shared_ptr& configuration) noexcept : disposed_(false) - , channel_(RandomNext(1, INT_MAX)) + , channel_(0) , hosting_(hosting) , configuration_(configuration) { if (hosting) { @@ -140,7 +140,6 @@ namespace uds { ClearTimeout(key); outbound->Close(); }, (UInt64)configuration_->Connect.Timeout * 1000)); - handshaked = handshaked && Connection::HelloAsync(outbound); handshaked = handshaked && Connection::AcceptAsync(transmission, [references, this, outbound](bool success, int channelId) noexcept -> void { ClearTimeout(outbound.get()); @@ -182,8 +181,7 @@ namespace uds { for (;;) { int channelId = ++channel_; - if (channelId < 1) { - channel_ = 0; + if (!channelId) { continue; } @@ -196,12 +194,6 @@ namespace uds { continue; } - if (configuration_->Inversion) { - int inversion = RandomNext() & 1; - if (inversion) { - channelId |= (int)(1 << 31); - } - } channel->channel_ = channelId; channel->inbound_ = inbound; channel->network_ = network; @@ -251,15 +243,10 @@ namespace uds { if (!link) { return false; } - + bool success = ClearTimeout(link->network_.get()); if (success) { - if (channel >> 31) { - success = Accept(channel, outbound, link->inbound_); - } - else { - success = Accept(channel, link->inbound_, outbound); - } + success = Accept(channel, link->inbound_, outbound); } if (!success) { diff --git a/uds/uds/tunnel/Connection.cpp b/uds/uds/tunnel/Connection.cpp index 93f2190..5585c66 100644 --- a/uds/uds/tunnel/Connection.cpp +++ b/uds/uds/tunnel/Connection.cpp @@ -355,10 +355,6 @@ namespace uds { } int channelId = (int)(v >> 32); - if (!channelId) { - callback(false, 0); - return; - } callback(true, channelId); }); } @@ -388,37 +384,6 @@ namespace uds { return HandshakeClient(inbound, std::forward(handler)); } - bool Connection::HelloAsync(const ITransmissionPtr& outbound) noexcept { - if (!outbound) { - return false; - } - - ITransmissionPtr transmission = outbound; - return HandshakeServer(outbound, UINT8_MAX << 1, RandomNext(1, INT_MAX), - [transmission](bool success, int) noexcept { - if (!success) { - transmission->Close(); - } - }); - } - - bool Connection::HelloAsync(const ITransmissionPtr& inbound, HelloAsyncCallback&& handler) noexcept { - if (!inbound || !handler) { - return false; - } - - HelloAsyncCallback callback = handler; - ITransmissionPtr transmission = inbound; - - return HandshakeClient(inbound, - [transmission, callback](bool success, int) noexcept { - if (!success) { - transmission->Close(); - } - callback(success); - }); - } - bool Connection::PackPlaintextHeaders(Stream& stream, int channelId, int alignment) noexcept { if (!stream.CanWrite()) { return false; diff --git a/uds/uds/tunnel/Connection.h b/uds/uds/tunnel/Connection.h index e07d680..06f288a 100644 --- a/uds/uds/tunnel/Connection.h +++ b/uds/uds/tunnel/Connection.h @@ -34,7 +34,6 @@ namespace uds { using AcceptAsyncCallback = std::function; using AcceptAsyncMeasureChannelId = std::function; using ConnectAsyncCallback = AcceptAsyncCallback; - using HelloAsyncCallback = std::function; public: const int ECONNECTION_MSS = uds::threading::Hosting::BufferSize; @@ -55,8 +54,6 @@ namespace uds { static bool AcceptAsync(const ITransmissionPtr& outbound, AcceptAsyncCallback&& handler) noexcept; static bool ConnectAsync(const ITransmissionPtr& outbound, int alignment, int channelId, ConnectAsyncCallback&& handler) noexcept; static bool ConnectAsync(const ITransmissionPtr& inbound, ConnectAsyncCallback&& handler) noexcept; - static bool HelloAsync(const ITransmissionPtr& outbound) noexcept; - static bool HelloAsync(const ITransmissionPtr& inbound, HelloAsyncCallback&& handler) noexcept; private: static bool PackPlaintextHeaders(Stream& stream, int channelId, int alignment) noexcept; diff --git a/uds/udss.ini b/uds/udss.ini index 4f15631..6a075df 100644 --- a/uds/udss.ini +++ b/uds/udss.ini @@ -8,7 +8,6 @@ inbound-port=10000 outbound-ip=:: outbound-port=20000 turbo=true -inversion=true backlog=511 fast-open=true keep-alived=true