mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-11-10 21:22:20 +03:00
Introduce new connection rate limits.
Summary: This introduces a rate limit to new connections created by a worker. Right now it will simply send a VN, but eventually this will only issue a RETRY for unverified initials. Reviewed By: udippant Differential Revision: D21614905 fbshipit-source-id: 1832fbdad525c53fb1cb810aa9d7bae868c267d6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
99e5aedc21
commit
30bff94e85
@@ -107,6 +107,11 @@ void QuicServerWorker::setCongestionControllerFactory(
|
||||
ccFactory_ = ccFactory;
|
||||
}
|
||||
|
||||
void QuicServerWorker::setRateLimiter(
|
||||
std::unique_ptr<RateLimiter> rateLimiter) {
|
||||
newConnRateLimiter_ = std::move(rateLimiter);
|
||||
}
|
||||
|
||||
void QuicServerWorker::start() {
|
||||
CHECK(socket_);
|
||||
if (!pacingTimer_) {
|
||||
@@ -490,6 +495,19 @@ void QuicServerWorker::dispatchPacketData(
|
||||
PacketDropReason::INVALID_PACKET);
|
||||
return;
|
||||
}
|
||||
if (newConnRateLimiter_ &&
|
||||
newConnRateLimiter_->check(networkData.receiveTimePoint)) {
|
||||
// TODO RETRY
|
||||
VersionNegotiationPacketBuilder builder(
|
||||
routingData.destinationConnId,
|
||||
routingData.sourceConnId.value_or(
|
||||
ConnectionId(std::vector<uint8_t>())),
|
||||
std::vector<QuicVersion>{QuicVersion::MVFST_INVALID});
|
||||
auto versionNegotiationPacket = std::move(builder).buildPacket();
|
||||
socket_->write(client, versionNegotiationPacket.second);
|
||||
QUIC_STATS(statsCallback_, onConnectionRateLimited);
|
||||
return;
|
||||
}
|
||||
// create 'accepting' transport
|
||||
auto sock = makeSocket(getEventBase());
|
||||
auto trans = transportFactory_->make(
|
||||
|
||||
Reference in New Issue
Block a user