Skip to content

Commit

Permalink
traffic_quic: Add an option to specify a server name for SNI
Browse files Browse the repository at this point in the history
  • Loading branch information
maskit committed Feb 26, 2020
1 parent eeff49a commit e4ac336
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/traffic_quic/quic_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ QUICClient::start(int, void *)
opt.socket_recv_bufsize = 1048576;
opt.socket_send_bufsize = 1048576;
opt.alpn_protos = alpn_protos;
opt.set_sni_servername(this->_config->addr, strnlen(this->_config->addr, 1023));
if (strlen(this->_config->server_name) == 0) {
opt.set_sni_servername(this->_config->addr, strnlen(this->_config->addr, 1023));
} else {
opt.set_sni_servername(this->_config->server_name, strnlen(this->_config->server_name, 1023));
}

SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());

Expand Down Expand Up @@ -319,7 +323,13 @@ Http3ClientApp::_do_http_request()
format = "GET https://%s/%s HTTP/1.1\r\n\r\n";
}

int request_len = snprintf(request, sizeof(request), format.c_str(), this->_config->addr, this->_config->path);
const char *authority;
if (strlen(this->_config->server_name) == 0) {
authority = this->_config->addr;
} else {
authority = this->_config->server_name;
}
int request_len = snprintf(request, sizeof(request), format.c_str(), authority, this->_config->path);

Http09ClientAppDebug("\n%s", request);

Expand Down
1 change: 1 addition & 0 deletions src/traffic_quic/quic_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct QUICClientConfig {
char output[1024] = {0};
char port[16] = "4433";
char path[1018] = "/";
char server_name[128] = "";
char debug_tags[1024] = "quic|vv_quic_crypto|http3|qpack";
int close = false;
int reset = false;
Expand Down
1 change: 1 addition & 0 deletions src/traffic_quic/traffic_quic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ main(int argc, const char **argv)
{"output", 'o', "Write to FILE instead of stdout", "S1023", config.output, nullptr, nullptr},
{"port", 'p', "Port", "S15", config.port, nullptr, nullptr},
{"path", 'P', "Path", "S1017", config.path, nullptr, nullptr},
{"server", 's', "Server name", "S127", config.server_name, nullptr, nullptr},
{"debug", 'T', "Vertical-bar-separated Debug Tags", "S1023", config.debug_tags, nullptr, nullptr},
{"close", 'c', "Enable connection close excercise", "F", &config.close, nullptr, nullptr},
{"reset", 'r', "Enable stateless reset excercise", "F", &config.reset, nullptr, nullptr},
Expand Down

0 comments on commit e4ac336

Please sign in to comment.