mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
chore: reject TLS handshake when our listener is plain TCP (#2882)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
da5c51d1dd
commit
f2b6daa3c5
2 changed files with 11 additions and 1 deletions
|
@ -801,7 +801,14 @@ io::Result<bool> Connection::CheckForHttpProto(FiberSocketBase* peer) {
|
|||
return make_unexpected(recv_sz.error());
|
||||
}
|
||||
io_buf_.CommitWrite(*recv_sz);
|
||||
string_view ib = ToSV(io_buf_.InputBuffer().subspan(last_len));
|
||||
string_view ib = ToSV(io_buf_.InputBuffer());
|
||||
if (ib.size() >= 2 && ib[0] == 22 && ib[1] == 3) {
|
||||
// We matched the TLS handshake raw data, which means "peer" is a TCP socket.
|
||||
// Reject the connection.
|
||||
return make_unexpected(make_error_code(errc::protocol_not_supported));
|
||||
}
|
||||
|
||||
ib = ib.substr(last_len);
|
||||
size_t pos = ib.find('\n');
|
||||
if (pos != string_view::npos) {
|
||||
ib = ToSV(io_buf_.InputBuffer().first(last_len + pos));
|
||||
|
|
|
@ -336,6 +336,9 @@ void DflyCmd::StartStable(CmdArgList args, ConnectionContext* cntx) {
|
|||
return rb->SendOk();
|
||||
}
|
||||
|
||||
// DFLY TAKEOVER [timeout_sec] [SAVE]
|
||||
// timeout_sec - number of seconds to wait for TAKEOVER to converge. A float.
|
||||
// SAVE if create a snapshot before shutting down.
|
||||
void DflyCmd::TakeOver(CmdArgList args, ConnectionContext* cntx) {
|
||||
RedisReplyBuilder* rb = static_cast<RedisReplyBuilder*>(cntx->reply_builder());
|
||||
CmdArgParser parser{args};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue