Keep clang-tidy clean in the relay engine

This commit is contained in:
Max Lv
2026-10-15 00:30:46 +08:00
parent b30ae18a0b
commit e0047c9cef
3 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -280,7 +280,7 @@ std::size_t encode_socks_host(const char *host, std::uint16_t port, std::uint8_t
}
out[at++] = 3;
out[at++] = static_cast<std::uint8_t>(n);
std::memcpy(out + at, host, n);
std::memcpy(out + at, host, n); // NOLINT(bugprone-not-null-terminated-result): binary, length-prefixed
at += n;
}
std::memcpy(out + at, &be, 2);
+9 -2
View File
@@ -447,6 +447,9 @@ UdpSession *UdpRelay::session_for(std::uint8_t listener, const sockaddr_storage
std::memcpy(raw.data(), &family, sizeof(int));
std::memcpy(raw.data() + sizeof(int), &client, sizeof(sockaddr_storage));
auto key = Key::from(raw);
if (!key) {
return nullptr;
}
if (PoolPtr<UdpSession> *found = sessions_.find(*key)) {
return found->get();
}
@@ -486,8 +489,9 @@ void UdpRelay::expire(UdpSession &session) noexcept
if (verbose) {
LOGI("[udp] connection timeout");
}
auto key = Key::from(session.key_);
(void)sessions_.take(*key); // the PoolPtr dies here and closes the session
if (auto key = Key::from(session.key_)) {
(void)sessions_.take(*key); // the PoolPtr dies here and closes the session
}
}
void UdpRelay::client_packet(Listener &listener, const sockaddr_storage &from, std::span<std::uint8_t> packet,
@@ -567,6 +571,9 @@ void UdpRelay::client_packet(Listener &listener, const sockaddr_storage &from, s
RefPtr<Shared2022> UdpRelay::shared_for(const std::array<std::uint8_t, crypto::kSessionIdLen> &id) noexcept
{
auto key = FixedKey<crypto::kSessionIdLen>::from(std::as_bytes(std::span(id)));
if (!key) {
return nullptr;
}
std::uint64_t now = now_secs();
if (RefPtr<Shared2022> *found = shared_.find(*key)) {
(*found)->last_used = now;
+1 -1
View File
@@ -113,7 +113,7 @@ resolv_shutdown(struct ss_loop *)
static bool closed;
closed = false;
resolver->shutdown(ss::CloseCompletion([](void *, std::uint32_t) { closed = true; }, nullptr, 0));
while (!closed) {
while (!closed) { // NOLINT(bugprone-infinite-loop): the completion callback sets it
loop->run_nowait();
}
std::destroy_at(resolver);