quic: fixup linting/formatting issues

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus 4.6
PR-URL: https://github.com/nodejs/node/pull/62387
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
This commit is contained in:
James M Snell authored and Antoine du Hamel committed 2026-05-07 17:32:44 +02:00
1 parent edeed4303b
commit 21e9239e2a
12 files changed
+84 -110

No files matched your search

+1 -2
View File
@@ -411,8 +411,7 @@ void Blob::Reader::Pull(const FunctionCallbackInfo<Value>& args) {
std::move(next), node::bob::OPTIONS_END, nullptr, 0));
}
void Blob::Reader::SetWakeup(
const FunctionCallbackInfo<Value>& args) {
void Blob::Reader::SetWakeup(const FunctionCallbackInfo<Value>& args) {
Blob::Reader* reader;
ASSIGN_OR_RETURN_UNWRAP(&reader, args.This());
CHECK(args[0]->IsFunction());
+1 -3
View File
@@ -452,7 +452,7 @@ ssize_t Session::Application::WriteVStream(PathStorage* path,
if (stream_data.fin) flags |= NGTCP2_WRITE_STREAM_FLAG_FIN;
return ngtcp2_conn_writev_stream(*session_,
&path->path,
// TODO(@jasnell): ECN blocked on libuv
// TODO(@jasnell): ECN blocked on libuv
nullptr,
dest,
max_packet_size,
@@ -583,7 +583,6 @@ class DefaultApplication final : public Session::Application {
void ResumeStream(int64_t id) override { ScheduleStream(id); }
void BlockStream(int64_t id) override {
if (auto stream = session().FindStream(id)) [[likely]] {
stream->EmitBlocked();
@@ -608,7 +607,6 @@ class DefaultApplication final : public Session::Application {
}
}
Stream::Queue stream_queue_;
};
+3 -3
View File
@@ -155,9 +155,9 @@ struct Session::Application::StreamData final {
BaseObjectPtr<Stream> stream;
static_assert(sizeof(ngtcp2_vec) == sizeof(nghttp3_vec) &&
alignof(ngtcp2_vec) == alignof(nghttp3_vec) &&
offsetof(ngtcp2_vec, base) == offsetof(nghttp3_vec, base) &&
offsetof(ngtcp2_vec, len) == offsetof(nghttp3_vec, len),
alignof(ngtcp2_vec) == alignof(nghttp3_vec) &&
offsetof(ngtcp2_vec, base) == offsetof(nghttp3_vec, base) &&
offsetof(ngtcp2_vec, len) == offsetof(nghttp3_vec, len),
"ngtcp2_vec and nghttp3_vec must have identical layout");
inline operator nghttp3_vec*() {
return reinterpret_cast<nghttp3_vec*>(data);
+1 -1
View File
@@ -43,7 +43,7 @@ class Packet;
V(session_datagram_status, SessionDatagramStatus) \
V(session_handshake, SessionHandshake) \
V(session_new, SessionNew) \
V(session_new_token, SessionNewToken) \
V(session_new_token, SessionNewToken) \
V(session_path_validation, SessionPathValidation) \
V(session_ticket, SessionTicket) \
V(session_version_negotiation, SessionVersionNegotiation) \
+5 -9
View File
@@ -324,8 +324,7 @@ class Endpoint::UDP::Impl final : public HandleWrap {
DCHECK_NOT_NULL(impl->endpoint_);
auto release_buf = [&]() {
if (buf->base != nullptr)
impl->env()->release_managed_buffer(*buf);
if (buf->base != nullptr) impl->env()->release_managed_buffer(*buf);
};
// Nothing to do in these cases. Specifically, if the nread
@@ -343,9 +342,8 @@ class Endpoint::UDP::Impl final : public HandleWrap {
return;
}
impl->endpoint_->Receive(
uv_buf_init(buf->base, static_cast<size_t>(nread)),
SocketAddress(addr));
impl->endpoint_->Receive(uv_buf_init(buf->base, static_cast<size_t>(nread)),
SocketAddress(addr));
}
uv_udp_t handle_;
@@ -999,7 +997,6 @@ void Endpoint::Destroy(CloseContext context, int status) {
this, "Destroying endpoint due to \"%s\" with status %d", ctx, status);
}
state_->listening = 0;
close_context_ = context;
@@ -1365,9 +1362,8 @@ void Endpoint::Receive(const uv_buf_t& buf,
// trusted networks), we skip the Retry and allow 0-RTT to
// proceed without additional validation.
if (options_.validate_address) {
Debug(this,
"Sending retry to %s due to 0RTT packet",
remote_address);
Debug(
this, "Sending retry to %s due to 0RTT packet", remote_address);
SendRetry(PathDescriptor{
version,
dcid,
-1
View File
@@ -311,7 +311,6 @@ class Endpoint final : public AsyncWrap, public Packet::Listener {
// be prevented.
void CloseGracefully();
void PacketDone(int status) override;
void EmitNewSession(const BaseObjectPtr<Session>& session);
+28 -37
View File
@@ -455,8 +455,8 @@ class Http3ApplicationImpl final : public Session::Application {
}
void SetStreamPriority(const Stream& stream,
StreamPriority priority,
StreamPriorityFlags flags) override {
StreamPriority priority,
StreamPriorityFlags flags) override {
nghttp3_pri pri;
pri.inc = (flags == StreamPriorityFlags::NON_INCREMENTAL) ? 0 : 1;
switch (priority) {
@@ -471,8 +471,7 @@ class Http3ApplicationImpl final : public Session::Application {
break;
}
if (session().is_server()) {
nghttp3_conn_set_server_stream_priority(
*this, stream.id(), &pri);
nghttp3_conn_set_server_stream_priority(*this, stream.id(), &pri);
}
// Client-side priority is set at request submission time via
// nghttp3_conn_submit_request and is not typically changed
@@ -536,12 +535,10 @@ class Http3ApplicationImpl final : public Session::Application {
nghttp3_err_infer_quic_app_error_code(err)));
return false;
}
if (data->stream)
data->stream->Commit(datalen, data->fin);
if (data->stream) data->stream->Commit(datalen, data->fin);
return true;
}
SET_NO_MEMORY_INFO()
SET_MEMORY_INFO_NAME(Http3ApplicationImpl)
SET_SELF_SIZE(Http3ApplicationImpl)
@@ -724,9 +721,7 @@ class Http3ApplicationImpl final : public Session::Application {
//
// This can be called multiple times with a decreasing id as the
// peer progressively reduces the set of streams it will process.
Debug(&session(),
"HTTP/3 received GOAWAY (id=%" PRIi64 ")",
id);
Debug(&session(), "HTTP/3 received GOAWAY (id=%" PRIi64 ")", id);
session().Close(Session::CloseMethod::GRACEFUL);
}
@@ -799,42 +794,38 @@ class Http3ApplicationImpl final : public Session::Application {
return 0;
}
size_t max_count = std::min(veccnt,
static_cast<size_t>(kMaxVectorCount));
size_t max_count = std::min(veccnt, static_cast<size_t>(kMaxVectorCount));
nghttp3_ssize result = 0;
auto next = [&](int status,
const ngtcp2_vec* data,
size_t count,
bob::Done done) {
switch (status) {
case bob::Status::STATUS_BLOCK:
case bob::Status::STATUS_WAIT:
result = NGHTTP3_ERR_WOULDBLOCK;
return;
case bob::Status::STATUS_EOS:
*pflags |= NGHTTP3_DATA_FLAG_EOF;
break;
}
count = std::min(count, max_count);
for (size_t n = 0; n < count; n++) {
vec[n].base = data[n].base;
vec[n].len = data[n].len;
}
result = static_cast<nghttp3_ssize>(count);
};
auto next =
[&](int status, const ngtcp2_vec* data, size_t count, bob::Done done) {
switch (status) {
case bob::Status::STATUS_BLOCK:
case bob::Status::STATUS_WAIT:
result = NGHTTP3_ERR_WOULDBLOCK;
return;
case bob::Status::STATUS_EOS:
*pflags |= NGHTTP3_DATA_FLAG_EOF;
break;
}
count = std::min(count, max_count);
for (size_t n = 0; n < count; n++) {
vec[n].base = data[n].base;
vec[n].len = data[n].len;
}
result = static_cast<nghttp3_ssize>(count);
};
ngtcp2_vec data[kMaxVectorCount];
stream->Pull(std::move(next),
bob::Options::OPTIONS_SYNC,
data,
max_count,
max_count);
bob::Options::OPTIONS_SYNC,
data,
max_count,
max_count);
return result;
}
static int on_acked_stream_data(nghttp3_conn* conn,
int64_t stream_id,
uint64_t datalen,
+7 -4
View File
@@ -30,14 +30,17 @@ std::optional<const PreferredAddress::AddressInfo> get_address_info(
if constexpr (FAMILY == AF_INET) {
if (!paddr.ipv4_present) return std::nullopt;
address.port = paddr.ipv4.sin_port;
if (uv_inet_ntop(FAMILY, &paddr.ipv4.sin_addr,
address.host, sizeof(address.host)) != 0)
if (uv_inet_ntop(
FAMILY, &paddr.ipv4.sin_addr, address.host, sizeof(address.host)) !=
0)
return std::nullopt;
} else {
if (!paddr.ipv6_present) return std::nullopt;
address.port = paddr.ipv6.sin6_port;
if (uv_inet_ntop(FAMILY, &paddr.ipv6.sin6_addr,
address.host, sizeof(address.host)) != 0)
if (uv_inet_ntop(FAMILY,
&paddr.ipv6.sin6_addr,
address.host,
sizeof(address.host)) != 0)
return std::nullopt;
}
return address;
+21 -26
View File
@@ -475,8 +475,7 @@ Maybe<Session::Options> Session::Options::From(Environment* env,
// Parse the optional NEW_TOKEN for address validation on reconnection.
Local<Value> token_val;
if (params->Get(env->context(), state.token_string())
.ToLocal(&token_val) &&
if (params->Get(env->context(), state.token_string()).ToLocal(&token_val) &&
token_val->IsArrayBufferView()) {
Store token_store;
if (Store::From(token_val.As<ArrayBufferView>()).To(&token_store)) {
@@ -897,9 +896,8 @@ struct Session::Impl final : public MemoryRetainer {
uint64_t max_streams,
void* user_data) {
NGTCP2_CALLBACK_SCOPE(session)
Debug(session,
"Max remote bidi streams increased to %" PRIu64,
max_streams);
Debug(
session, "Max remote bidi streams increased to %" PRIu64, max_streams);
return NGTCP2_SUCCESS;
}
@@ -1630,11 +1628,14 @@ bool Session::Receive(Store&& store,
// ngtcp2_conn_read_pkt here, we will need to double check that the
// session is not destroyed before we try doing anything with it
// (like updating stats, sending pending data, etc).
int err = ngtcp2_conn_read_pkt(
*this, &path,
// TODO(@jasnell): ECN pkt_info blocked on libuv
nullptr,
vec.base, vec.len, uv_hrtime());
int err =
ngtcp2_conn_read_pkt(*this,
&path,
// TODO(@jasnell): ECN pkt_info blocked on libuv
nullptr,
vec.base,
vec.len,
uv_hrtime());
switch (err) {
case 0: {
@@ -2477,10 +2478,8 @@ void Session::SelectPreferredAddress(PreferredAddress* preferredAddress) {
auto ipv4 = preferredAddress->ipv4();
if (ipv4.has_value()) {
if (ipv4->host[0] == '\0' || ipv4->port == 0) return;
CHECK(SocketAddress::New(AF_INET,
ipv4->host,
ipv4->port,
&impl_->remote_address_));
CHECK(SocketAddress::New(
AF_INET, ipv4->host, ipv4->port, &impl_->remote_address_));
preferredAddress->Use(ipv4.value());
}
break;
@@ -2490,10 +2489,8 @@ void Session::SelectPreferredAddress(PreferredAddress* preferredAddress) {
auto ipv6 = preferredAddress->ipv6();
if (ipv6.has_value()) {
if (ipv6->host[0] == '\0' || ipv6->port == 0) return;
CHECK(SocketAddress::New(AF_INET6,
ipv6->host,
ipv6->port,
&impl_->remote_address_));
CHECK(SocketAddress::New(
AF_INET6, ipv6->host, ipv6->port, &impl_->remote_address_));
preferredAddress->Use(ipv6.value());
}
break;
@@ -2767,16 +2764,14 @@ void Session::EmitNewToken(const uint8_t* token, size_t len) {
CallbackScope<Session> cb_scope(this);
Local<Value> argv[2];
auto buf = Buffer::Copy(
env(), reinterpret_cast<const char*>(token), len);
auto buf = Buffer::Copy(env(), reinterpret_cast<const char*>(token), len);
if (!buf.ToLocal(&argv[0])) return;
argv[1] = SocketAddressBase::Create(
env(),
std::make_shared<SocketAddress>(remote_address()))->object();
MakeCallback(
BindingData::Get(env()).session_new_token_callback(),
arraysize(argv),
argv);
env(), std::make_shared<SocketAddress>(remote_address()))
->object();
MakeCallback(BindingData::Get(env()).session_new_token_callback(),
arraysize(argv),
argv);
}
void Session::EmitStream(const BaseObjectWeakPtr<Stream>& stream) {
+4 -4
View File
@@ -1,15 +1,15 @@
#if HAVE_OPENSSL
#include "guard.h"
#ifndef OPENSSL_NO_QUIC
#include "sessionticket.h"
#include "tlscontext.h"
#include "session.h"
#include <node_sockaddr-inl.h>
#include <env-inl.h>
#include <memory_tracker-inl.h>
#include <ngtcp2/ngtcp2_crypto.h>
#include <node_buffer.h>
#include <node_errors.h>
#include <node_sockaddr-inl.h>
#include "session.h"
#include "sessionticket.h"
#include "tlscontext.h"
namespace node {
+9 -14
View File
@@ -83,9 +83,9 @@ namespace quic {
V(ResetStream, resetStream, false) \
V(SetPriority, setPriority, false) \
V(GetPriority, getPriority, true) \
V(GetReader, getReader, false) \
V(InitStreamingSource, initStreamingSource, false) \
V(Write, write, false) \
V(GetReader, getReader, false) \
V(InitStreamingSource, initStreamingSource, false) \
V(Write, write, false) \
V(EndWrite, endWrite, false)
// ============================================================================
@@ -149,10 +149,7 @@ namespace {
// possible (e.g., SharedArrayBuffer-backed or non-detachable).
// Returns nullptr on failure (error already thrown if allocation failed).
std::unique_ptr<DataQueue::Entry> CreateEntryFromBuffer(
Environment* env,
Local<ArrayBuffer> buffer,
size_t offset,
size_t length) {
Environment* env, Local<ArrayBuffer> buffer, size_t offset, size_t length) {
if (length == 0) return nullptr;
std::shared_ptr<v8::BackingStore> backing;
if (buffer->IsDetachable()) {
@@ -1111,8 +1108,8 @@ void Stream::set_outbound(std::shared_ptr<DataQueue> source) {
void Stream::InitStreaming() {
auto env = this->env();
if (outbound_ != nullptr) {
return THROW_ERR_INVALID_STATE(env,
"Outbound data source is already initialized");
return THROW_ERR_INVALID_STATE(
env, "Outbound data source is already initialized");
}
if (!is_writable()) {
return THROW_ERR_INVALID_STATE(env, "Stream is not writable");
@@ -1126,8 +1123,7 @@ void Stream::InitStreaming() {
void Stream::WriteStreamData(const v8::FunctionCallbackInfo<v8::Value>& args) {
auto env = this->env();
if (outbound_ == nullptr || !outbound_->is_streaming()) {
return THROW_ERR_INVALID_STATE(env,
"Streaming source is not initialized");
return THROW_ERR_INVALID_STATE(env, "Streaming source is not initialized");
}
if (!is_writable()) {
@@ -1142,8 +1138,8 @@ void Stream::WriteStreamData(const v8::FunctionCallbackInfo<v8::Value>& args) {
auto view = value.As<Uint8Array>();
auto length = view->ByteLength();
if (length == 0) return true;
auto entry = CreateEntryFromBuffer(
env, view->Buffer(), view->ByteOffset(), length);
auto entry =
CreateEntryFromBuffer(env, view->Buffer(), view->ByteOffset(), length);
if (!entry) {
return false;
}
@@ -1462,7 +1458,6 @@ void Stream::Schedule(Queue* queue) {
if (outbound_ && stream_queue_.IsEmpty()) queue->PushBack(this);
}
} // namespace quic
} // namespace node
+4 -6
View File
@@ -89,7 +89,7 @@ void EnableTrace(Environment* env, BIOPointer* bio, SSL* ssl) {
#endif
}
template <typename T, typename Opt, std::vector<T> Opt::* member>
template <typename T, typename Opt, std::vector<T> Opt::*member>
bool SetOption(Environment* env,
Opt* options,
const Local<Object>& object,
@@ -417,16 +417,14 @@ SSLCtxPointer TLSContext::Initialize() {
}
if (SSL_CTX_set_max_early_data(
ctx.get(),
options_.enable_early_data ? UINT32_MAX : 0) != 1) {
ctx.get(), options_.enable_early_data ? UINT32_MAX : 0) != 1) {
validation_error_ = "Failed to set max early data";
return {};
}
// ngtcp2 handles replay protection at the QUIC layer,
// so we disable OpenSSL's built-in anti-replay.
SSL_CTX_set_options(ctx.get(),
(SSL_OP_ALL &
~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) |
(SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) |
SSL_OP_SINGLE_ECDH_USE |
SSL_OP_CIPHER_SERVER_PREFERENCE |
SSL_OP_NO_ANTI_REPLAY);
@@ -451,7 +449,7 @@ SSLCtxPointer TLSContext::Initialize() {
SessionTicket::GenerateCallback,
SessionTicket::DecryptedCallback,
nullptr),
1);
1);
break;
}
case Side::CLIENT: {