nghttpx: Make sure each quic frontend endpoint has a unique address

This commit is contained in:
Tatsuhiro Tsujikawa 2021-08-26 18:21:59 +09:00
parent 0d35e8e15e
commit d88eadff13
1 changed files with 17 additions and 0 deletions

View File

@ -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<QUICListener>(&addr, this));
}