mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add PROXY TestPeer client
This commit is contained in:
@@ -86,6 +86,7 @@
|
|||||||
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogic.h" />
|
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogic.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicAsyncClient.h" />
|
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicAsyncClient.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicAsyncServer.h" />
|
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicAsyncServer.h" />
|
||||||
|
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicProxyClient.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicSyncClient.h" />
|
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicSyncClient.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicSyncServer.h" />
|
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicSyncServer.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_asio\tests\beast_PeerTest.h" />
|
<ClInclude Include="..\..\modules\beast_asio\tests\beast_PeerTest.h" />
|
||||||
@@ -334,6 +335,10 @@
|
|||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicProxyClient.cpp">
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicSyncClient.cpp">
|
<ClCompile Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicSyncClient.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
|
|||||||
@@ -815,6 +815,9 @@
|
|||||||
<ClInclude Include="..\..\modules\beast_asio\protocol\beast_ProxyHandshake.h">
|
<ClInclude Include="..\..\modules\beast_asio\protocol\beast_ProxyHandshake.h">
|
||||||
<Filter>beast_asio\protocol</Filter>
|
<Filter>beast_asio\protocol</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicProxyClient.h">
|
||||||
|
<Filter>beast_asio\tests</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\modules\beast_core\beast_core.cpp">
|
<ClCompile Include="..\..\modules\beast_core\beast_core.cpp">
|
||||||
@@ -1270,6 +1273,9 @@
|
|||||||
<ClCompile Include="..\..\modules\beast_asio\protocol\beast_ProxyHandshake.cpp">
|
<ClCompile Include="..\..\modules\beast_asio\protocol\beast_ProxyHandshake.cpp">
|
||||||
<Filter>beast_asio\protocol</Filter>
|
<Filter>beast_asio\protocol</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\modules\beast_asio\tests\beast_TestPeerLogicProxyClient.cpp">
|
||||||
|
<Filter>beast_asio\tests</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="..\..\TODO.txt" />
|
<Text Include="..\..\TODO.txt" />
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ namespace beast
|
|||||||
#include "tests/beast_TestPeerLogic.h"
|
#include "tests/beast_TestPeerLogic.h"
|
||||||
#include "tests/beast_TestPeerLogicSyncServer.h"
|
#include "tests/beast_TestPeerLogicSyncServer.h"
|
||||||
#include "tests/beast_TestPeerLogicSyncClient.h"
|
#include "tests/beast_TestPeerLogicSyncClient.h"
|
||||||
|
#include "tests/beast_TestPeerLogicProxyClient.h"
|
||||||
#include "tests/beast_TestPeerLogicAsyncServer.h"
|
#include "tests/beast_TestPeerLogicAsyncServer.h"
|
||||||
#include "tests/beast_TestPeerLogicAsyncClient.h"
|
#include "tests/beast_TestPeerLogicAsyncClient.h"
|
||||||
#include "tests/beast_TestPeerType.h"
|
#include "tests/beast_TestPeerType.h"
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ public:
|
|||||||
|
|
||||||
expect (h.getStatus () == ProxyHandshake::statusHandshake);
|
expect (h.getStatus () == ProxyHandshake::statusHandshake);
|
||||||
|
|
||||||
for (int i = 0; i < s.size () && h.getStatus () == ProxyHandshake::statusHandshake ; ++i)
|
for (std::size_t i = 0; i < s.size () && h.getStatus () == ProxyHandshake::statusHandshake ; ++i)
|
||||||
{
|
{
|
||||||
std::size_t const bytesConsumed = h.feed (& s[i], 1);
|
std::size_t const bytesConsumed = h.feed (& s[i], 1);
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ public:
|
|||||||
unexpected (p.parse (s.c_str (), s.size ()));
|
unexpected (p.parse (s.c_str (), s.size ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < s.size () - 1; ++i)
|
for (std::size_t i = 1; i < s.size () - 1; ++i)
|
||||||
{
|
{
|
||||||
String const partial = String (s).dropLastCharacters (i);
|
String const partial = String (s).dropLastCharacters (i);
|
||||||
std::string ss (partial.toStdString ());
|
std::string ss (partial.toStdString ());
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||||
|
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
TestPeerLogicProxyClient::TestPeerLogicProxyClient (Socket& socket)
|
||||||
|
: TestPeerLogicSyncClient (socket)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestPeerLogicProxyClient::on_pre_handshake ()
|
||||||
|
{
|
||||||
|
ProxyHandshake h;
|
||||||
|
|
||||||
|
static std::string line (
|
||||||
|
"PROXY TCP4 255.255.255.255 255.255.255.255 65535 65535\r\n"
|
||||||
|
// 56 chars
|
||||||
|
);
|
||||||
|
|
||||||
|
std::size_t const amount = boost::asio::write (
|
||||||
|
socket (), boost::asio::buffer (line), error ());
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||||
|
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
#ifndef BEAST_TESTPEERLOGICPROXYCLIENT_H_INCLUDED
|
||||||
|
#define BEAST_TESTPEERLOGICPROXYCLIENT_H_INCLUDED
|
||||||
|
|
||||||
|
/** A synchronous client logic that sends a PROXY protocol pre-handshake. */
|
||||||
|
class TestPeerLogicProxyClient : public TestPeerLogicSyncClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit TestPeerLogicProxyClient (Socket& socket);
|
||||||
|
void on_pre_handshake ();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -34,6 +34,13 @@ TestPeerBasics::Model TestPeerLogicSyncClient::get_model () const noexcept
|
|||||||
|
|
||||||
void TestPeerLogicSyncClient::on_connect ()
|
void TestPeerLogicSyncClient::on_connect ()
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
// pre-handshake hook is optional
|
||||||
|
on_pre_handshake ();
|
||||||
|
if (failure (error ()))
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
if (socket ().requires_handshake ())
|
if (socket ().requires_handshake ())
|
||||||
{
|
{
|
||||||
if (failure (socket ().handshake (get_role (), error ())))
|
if (failure (socket ().handshake (get_role (), error ())))
|
||||||
@@ -95,3 +102,7 @@ void TestPeerLogicSyncClient::on_connect ()
|
|||||||
if (failure (socket ().close (error ())))
|
if (failure (socket ().close (error ())))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestPeerLogicSyncClient::on_pre_handshake ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
Role get_role () const noexcept;
|
Role get_role () const noexcept;
|
||||||
Model get_model () const noexcept;
|
Model get_model () const noexcept;
|
||||||
void on_connect ();
|
void on_connect ();
|
||||||
|
virtual void on_pre_handshake ();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user