From 50305ed1d89408c26067a970dcd5d9dbea19de9d Mon Sep 17 00:00:00 2001 From: Will Date: Sat, 26 Mar 2016 09:18:07 +0900 Subject: [PATCH] send hostname in TLS SNI extension --- CHANGES | 5 +++++ INSTALL | 29 +++++++++++++++++++++++++++++ src/net.c | 2 +- src/net.h | 4 ++-- src/ssl.c | 3 ++- src/ssl.h | 2 +- src/wrk.c | 5 ++++- 7 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 INSTALL diff --git a/CHANGES b/CHANGES index 5648234f..206a0959 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +wrk 4.0.2 + + * Send hostname using TLS SNI. + * Add optional WITH_OPENSSL and WITH_LUAJIT to use system libs. + * Bundle OpenSSL 1.0.2. * delay() can return milliseconds to delay sending next request. wrk 4.0.0 diff --git a/INSTALL b/INSTALL new file mode 100644 index 00000000..d130ddeb --- /dev/null +++ b/INSTALL @@ -0,0 +1,29 @@ +Overview + + wrk should build on most UNIX-like operating systems and + architectures that have GNU make and are supported by LuaJIT and + OpenSSL. Some systems may require additional CFLAGS or LDFLAGS, + see the top of the Makefile for examples + + In many cases simply running `make` (often `gmake` on *BSD) will + do the trick. + +Dependencies + + wrk requires LuaJIT and OpenSSL and is distributed with appropriate + versions that will be unpacked and built as necessary. + + If you are building wrk packages for an OS distribution or otherwise + prefer to use system versions of dependencies you may specify their + location when invoking make with one or more of: + + WITH_LUAJIT + WITH_OPENSSL + + For example to use the system version of both libraries on Linux: + + make WITH_LUAJIT=/usr WITH_OPENSSL=/usr + + Or to use the Homebrew version of OpenSSL on Mac OS X: + + make WITH_OPENSSL=/usr/local/opt/openssl diff --git a/src/net.c b/src/net.c index fb093bba..75916f78 100644 --- a/src/net.c +++ b/src/net.c @@ -6,7 +6,7 @@ #include "net.h" -status sock_connect(connection *c) { +status sock_connect(connection *c, char *host) { return OK; } diff --git a/src/net.h b/src/net.h index d8fcf112..ed9cbb2f 100644 --- a/src/net.h +++ b/src/net.h @@ -13,14 +13,14 @@ typedef enum { } status; struct sock { - status ( *connect)(connection *); + status ( *connect)(connection *, char *); status ( *close)(connection *); status ( *read)(connection *, size_t *); status ( *write)(connection *, char *, size_t, size_t *); size_t (*readable)(connection *); }; -status sock_connect(connection *); +status sock_connect(connection *, char *); status sock_close(connection *); status sock_read(connection *, size_t *); status sock_write(connection *, char *, size_t, size_t *); diff --git a/src/ssl.c b/src/ssl.c index 604bf0b3..a4a88c45 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -49,9 +49,10 @@ SSL_CTX *ssl_init() { return ctx; } -status ssl_connect(connection *c) { +status ssl_connect(connection *c, char *host) { int r; SSL_set_fd(c->ssl, c->fd); + SSL_set_tlsext_host_name(c->ssl, host); if ((r = SSL_connect(c->ssl)) != 1) { switch (SSL_get_error(c->ssl, r)) { case SSL_ERROR_WANT_READ: return RETRY; diff --git a/src/ssl.h b/src/ssl.h index efb3176b..181d5b31 100644 --- a/src/ssl.h +++ b/src/ssl.h @@ -5,7 +5,7 @@ SSL_CTX *ssl_init(); -status ssl_connect(connection *); +status ssl_connect(connection *, char *); status ssl_close(connection *); status ssl_read(connection *, size_t *); status ssl_write(connection *, char *, size_t, size_t *); diff --git a/src/wrk.c b/src/wrk.c index b20b14db..51f46f72 100644 --- a/src/wrk.c +++ b/src/wrk.c @@ -13,6 +13,7 @@ static struct config { bool delay; bool dynamic; bool latency; + char *host; char *script; SSL_CTX *ctx; } cfg; @@ -98,6 +99,8 @@ int main(int argc, char **argv) { exit(1); } + cfg.host = host; + for (uint64_t i = 0; i < cfg.threads; i++) { thread *t = &threads[i]; t->loop = aeCreateEventLoop(10 + cfg.connections * 3); @@ -359,7 +362,7 @@ static int response_complete(http_parser *parser) { static void socket_connected(aeEventLoop *loop, int fd, void *data, int mask) { connection *c = data; - switch (sock.connect(c)) { + switch (sock.connect(c, cfg.host)) { case OK: break; case ERROR: goto error; case RETRY: return;