Require shibboleth match at start of connection.

This commit is contained in:
Bartosz Taudul 2018-09-09 18:26:53 +02:00
parent f55f2858c4
commit 270072b09e
3 changed files with 20 additions and 0 deletions

View File

@ -913,6 +913,21 @@ void Profiler::Worker()
if( m_sock ) break; if( m_sock ) break;
} }
{
timeval tv;
tv.tv_sec = 2;
tv.tv_usec = 0;
char shibboleth[HandshakeShibbolethSize];
const auto res = m_sock->ReadRaw( shibboleth, HandshakeShibbolethSize, &tv );
if( !res || memcmp( shibboleth, HandshakeShibboleth, HandshakeShibbolethSize ) != 0 )
{
m_sock->~Socket();
tracy_free( m_sock );
continue;
}
}
#ifdef TRACY_ON_DEMAND #ifdef TRACY_ON_DEMAND
ClearQueues( token ); ClearQueues( token );
m_isConnected.store( true, std::memory_order_relaxed ); m_isConnected.store( true, std::memory_order_relaxed );

View File

@ -27,6 +27,9 @@ enum ServerQuery : uint8_t
ServerQueryFrameName, ServerQueryFrameName,
}; };
enum { HandshakeShibbolethSize = 8 };
static const char HandshakeShibboleth[HandshakeShibbolethSize] = { 'T', 'r', 'a', 'c', 'y', 'P', 'r', 'f' };
enum { WelcomeMessageProgramNameSize = 64 }; enum { WelcomeMessageProgramNameSize = 64 };
enum { WelcomeMessageHostInfoSize = 1024 }; enum { WelcomeMessageHostInfoSize = 1024 };

View File

@ -1279,6 +1279,8 @@ void Worker::Exec()
if( m_sock.Connect( m_addr.c_str(), "8086" ) ) break; if( m_sock.Connect( m_addr.c_str(), "8086" ) ) break;
} }
m_sock.Send( HandshakeShibboleth, HandshakeShibbolethSize );
auto lz4buf = std::make_unique<char[]>( LZ4Size ); auto lz4buf = std::make_unique<char[]>( LZ4Size );
std::chrono::time_point<std::chrono::high_resolution_clock> t0; std::chrono::time_point<std::chrono::high_resolution_clock> t0;