From d88eadff136e264af4c2634ca21a489fff99b924 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 26 Aug 2021 18:21:59 +0900 Subject: [PATCH] nghttpx: Make sure each quic frontend endpoint has a unique address --- src/shrpx_worker.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/shrpx_worker.cc b/src/shrpx_worker.cc index 0a97674b..2e91b63d 100644 --- a/src/shrpx_worker.cc +++ b/src/shrpx_worker.cc @@ -683,12 +683,29 @@ uint32_t Worker::compute_sk_index() const { # endif // HAVE_LIBBPF int Worker::setup_quic_server_socket() { + size_t n = 0; + for (auto &addr : quic_upstream_addrs_) { assert(!addr.host_unix); if (create_quic_server_socket(addr) != 0) { return -1; } + // Make sure that each endpoint has a unique address. + for (size_t i = 0; i < n; ++i) { + const auto &a = quic_upstream_addrs_[i]; + + if (addr.hostport == a.hostport) { + LOG(FATAL) + << "QUIC frontend endpoint must be unique: a duplicate found for " + << addr.hostport; + + return -1; + } + } + + ++n; + quic_listeners_.emplace_back(std::make_unique(&addr, this)); }