nghttpx: Rename --frontend-quic-server-id to --quic-server-id

This commit is contained in:
Tatsuhiro Tsujikawa 2021-10-17 14:48:46 +09:00
parent 18d4a9e4ff
commit 9d41896663
5 changed files with 25 additions and 30 deletions

View File

@ -192,7 +192,7 @@ OPTIONS = [
"frontend-quic-qlog-dir", "frontend-quic-qlog-dir",
"frontend-quic-require-token", "frontend-quic-require-token",
"frontend-quic-congestion-controller", "frontend-quic-congestion-controller",
"frontend-quic-server-id", "quic-server-id",
"frontend-quic-secret-file", "frontend-quic-secret-file",
"rlimit-memlock", "rlimit-memlock",
"max-worker-processes", "max-worker-processes",

View File

@ -1450,8 +1450,7 @@ int generate_cid_prefix(
cid_prefixes.resize(num_cid_prefix); cid_prefixes.resize(num_cid_prefix);
for (auto &cid_prefix : cid_prefixes) { for (auto &cid_prefix : cid_prefixes) {
if (create_cid_prefix(cid_prefix.data(), if (create_cid_prefix(cid_prefix.data(), quicconf.server_id.data()) != 0) {
quicconf.upstream.server_id.data()) != 0) {
return -1; return -1;
} }
} }
@ -1953,16 +1952,15 @@ void fill_default_config(Config *config) {
upstreamconf.congestion_controller = NGTCP2_CC_ALGO_CUBIC; upstreamconf.congestion_controller = NGTCP2_CC_ALGO_CUBIC;
if (RAND_bytes(upstreamconf.server_id.data(),
upstreamconf.server_id.size()) != 1) {
assert(0);
abort();
}
upstreamconf.initial_rtt = upstreamconf.initial_rtt =
static_cast<ev_tstamp>(NGTCP2_DEFAULT_INITIAL_RTT) / NGTCP2_SECONDS; static_cast<ev_tstamp>(NGTCP2_DEFAULT_INITIAL_RTT) / NGTCP2_SECONDS;
} }
if (RAND_bytes(quicconf.server_id.data(), quicconf.server_id.size()) != 1) {
assert(0);
abort();
}
auto &http3conf = config->http3; auto &http3conf = config->http3;
{ {
auto &upstreamconf = http3conf.upstream; auto &upstreamconf = http3conf.upstream;
@ -3394,7 +3392,7 @@ HTTP/3 and QUIC:
option is not given or an error occurred while opening option is not given or an error occurred while opening
or reading a file, a keying material is generated or reading a file, a keying material is generated
internally on startup and reload. internally on startup and reload.
--frontend-quic-server-id=<HEXSTRING> --quic-server-id=<HEXSTRING>
Specify server ID encoded in Connection ID to identify Specify server ID encoded in Connection ID to identify
this particular server instance. Connection ID is this particular server instance. Connection ID is
encrypted and this part is not visible in public. It encrypted and this part is not visible in public. It
@ -4217,8 +4215,7 @@ int main(int argc, char **argv) {
182}, 182},
{SHRPX_OPT_FRONTEND_QUIC_CONGESTION_CONTROLLER.c_str(), {SHRPX_OPT_FRONTEND_QUIC_CONGESTION_CONTROLLER.c_str(),
required_argument, &flag, 183}, required_argument, &flag, 183},
{SHRPX_OPT_FRONTEND_QUIC_SERVER_ID.c_str(), required_argument, &flag, {SHRPX_OPT_QUIC_SERVER_ID.c_str(), required_argument, &flag, 185},
185},
{SHRPX_OPT_FRONTEND_QUIC_SECRET_FILE.c_str(), required_argument, &flag, {SHRPX_OPT_FRONTEND_QUIC_SECRET_FILE.c_str(), required_argument, &flag,
186}, 186},
{SHRPX_OPT_RLIMIT_MEMLOCK.c_str(), required_argument, &flag, 187}, {SHRPX_OPT_RLIMIT_MEMLOCK.c_str(), required_argument, &flag, 187},
@ -5105,9 +5102,8 @@ int main(int argc, char **argv) {
StringRef{optarg}); StringRef{optarg});
break; break;
case 185: case 185:
// --frontend-quic-server-id // --quic-server-id
cmdcfgs.emplace_back(SHRPX_OPT_FRONTEND_QUIC_SERVER_ID, cmdcfgs.emplace_back(SHRPX_OPT_QUIC_SERVER_ID, StringRef{optarg});
StringRef{optarg});
break; break;
case 186: case 186:
// --frontend-quic-secret-file // --frontend-quic-secret-file

View File

@ -2054,6 +2054,11 @@ int option_lookup_token(const char *name, size_t namelen) {
break; break;
case 14: case 14:
switch (name[13]) { switch (name[13]) {
case 'd':
if (util::strieq_l("quic-server-i", name, 13)) {
return SHRPX_OPTID_QUIC_SERVER_ID;
}
break;
case 'e': case 'e':
if (util::strieq_l("accesslog-fil", name, 13)) { if (util::strieq_l("accesslog-fil", name, 13)) {
return SHRPX_OPTID_ACCESSLOG_FILE; return SHRPX_OPTID_ACCESSLOG_FILE;
@ -2352,11 +2357,6 @@ int option_lookup_token(const char *name, size_t namelen) {
break; break;
case 23: case 23:
switch (name[22]) { switch (name[22]) {
case 'd':
if (util::strieq_l("frontend-quic-server-i", name, 22)) {
return SHRPX_OPTID_FRONTEND_QUIC_SERVER_ID;
}
break;
case 'e': case 'e':
if (util::strieq_l("client-private-key-fil", name, 22)) { if (util::strieq_l("client-private-key-fil", name, 22)) {
return SHRPX_OPTID_CLIENT_PRIVATE_KEY_FILE; return SHRPX_OPTID_CLIENT_PRIVATE_KEY_FILE;
@ -4118,14 +4118,14 @@ int parse_config(Config *config, int optid, const StringRef &opt,
#endif // ENABLE_HTTP3 #endif // ENABLE_HTTP3
return 0; return 0;
case SHRPX_OPTID_FRONTEND_QUIC_SERVER_ID: case SHRPX_OPTID_QUIC_SERVER_ID:
#ifdef ENABLE_HTTP3 #ifdef ENABLE_HTTP3
if (optarg.size() != config->quic.upstream.server_id.size() * 2 || if (optarg.size() != config->quic.server_id.size() * 2 ||
!util::is_hex_string(optarg)) { !util::is_hex_string(optarg)) {
LOG(ERROR) << opt << ": must be a hex-string"; LOG(ERROR) << opt << ": must be a hex-string";
return -1; return -1;
} }
util::decode_hex(std::begin(config->quic.upstream.server_id), optarg); util::decode_hex(std::begin(config->quic.server_id), optarg);
#endif // ENABLE_HTTP3 #endif // ENABLE_HTTP3
return 0; return 0;

View File

@ -391,8 +391,7 @@ constexpr auto SHRPX_OPT_FRONTEND_QUIC_REQUIRE_TOKEN =
StringRef::from_lit("frontend-quic-require-token"); StringRef::from_lit("frontend-quic-require-token");
constexpr auto SHRPX_OPT_FRONTEND_QUIC_CONGESTION_CONTROLLER = constexpr auto SHRPX_OPT_FRONTEND_QUIC_CONGESTION_CONTROLLER =
StringRef::from_lit("frontend-quic-congestion-controller"); StringRef::from_lit("frontend-quic-congestion-controller");
constexpr auto SHRPX_OPT_FRONTEND_QUIC_SERVER_ID = constexpr auto SHRPX_OPT_QUIC_SERVER_ID = StringRef::from_lit("quic-server-id");
StringRef::from_lit("frontend-quic-server-id");
constexpr auto SHRPX_OPT_FRONTEND_QUIC_SECRET_FILE = constexpr auto SHRPX_OPT_FRONTEND_QUIC_SECRET_FILE =
StringRef::from_lit("frontend-quic-secret-file"); StringRef::from_lit("frontend-quic-secret-file");
constexpr auto SHRPX_OPT_RLIMIT_MEMLOCK = StringRef::from_lit("rlimit-memlock"); constexpr auto SHRPX_OPT_RLIMIT_MEMLOCK = StringRef::from_lit("rlimit-memlock");
@ -780,7 +779,6 @@ struct QUICConfig {
ngtcp2_cc_algo congestion_controller; ngtcp2_cc_algo congestion_controller;
bool early_data; bool early_data;
bool require_token; bool require_token;
std::array<uint8_t, SHRPX_QUIC_SERVER_IDLEN> server_id;
StringRef secret_file; StringRef secret_file;
ev_tstamp initial_rtt; ev_tstamp initial_rtt;
} upstream; } upstream;
@ -788,6 +786,7 @@ struct QUICConfig {
StringRef prog_file; StringRef prog_file;
bool disabled; bool disabled;
} bpf; } bpf;
std::array<uint8_t, SHRPX_QUIC_SERVER_IDLEN> server_id;
}; };
struct Http3Config { struct Http3Config {
@ -1249,7 +1248,6 @@ enum {
SHRPX_OPTID_FRONTEND_QUIC_QLOG_DIR, SHRPX_OPTID_FRONTEND_QUIC_QLOG_DIR,
SHRPX_OPTID_FRONTEND_QUIC_REQUIRE_TOKEN, SHRPX_OPTID_FRONTEND_QUIC_REQUIRE_TOKEN,
SHRPX_OPTID_FRONTEND_QUIC_SECRET_FILE, SHRPX_OPTID_FRONTEND_QUIC_SECRET_FILE,
SHRPX_OPTID_FRONTEND_QUIC_SERVER_ID,
SHRPX_OPTID_FRONTEND_READ_TIMEOUT, SHRPX_OPTID_FRONTEND_READ_TIMEOUT,
SHRPX_OPTID_FRONTEND_WRITE_TIMEOUT, SHRPX_OPTID_FRONTEND_WRITE_TIMEOUT,
SHRPX_OPTID_HEADER_FIELD_BUFFER, SHRPX_OPTID_HEADER_FIELD_BUFFER,
@ -1292,6 +1290,7 @@ enum {
SHRPX_OPTID_PRIVATE_KEY_PASSWD_FILE, SHRPX_OPTID_PRIVATE_KEY_PASSWD_FILE,
SHRPX_OPTID_PSK_SECRETS, SHRPX_OPTID_PSK_SECRETS,
SHRPX_OPTID_QUIC_BPF_PROGRAM_FILE, SHRPX_OPTID_QUIC_BPF_PROGRAM_FILE,
SHRPX_OPTID_QUIC_SERVER_ID,
SHRPX_OPTID_READ_BURST, SHRPX_OPTID_READ_BURST,
SHRPX_OPTID_READ_RATE, SHRPX_OPTID_READ_RATE,
SHRPX_OPTID_REDIRECT_HTTPS_PORT, SHRPX_OPTID_REDIRECT_HTTPS_PORT,

View File

@ -456,9 +456,9 @@ int QUICConnectionHandler::send_retry(
ngtcp2_cid retry_scid; ngtcp2_cid retry_scid;
if (generate_quic_retry_connection_id( if (generate_quic_retry_connection_id(retry_scid, SHRPX_QUIC_SCIDLEN,
retry_scid, SHRPX_QUIC_SCIDLEN, quicconf.upstream.server_id.data(), quicconf.server_id.data(), qkm.id,
qkm.id, qkm.cid_encryption_key.data()) != 0) { qkm.cid_encryption_key.data()) != 0) {
return -1; return -1;
} }