Skip to content

Commit

Permalink
send hostname in TLS SNI extension
Browse files Browse the repository at this point in the history
  • Loading branch information
wg committed Mar 26, 2016
1 parent 040db59 commit 50305ed
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
Expand Down
29 changes: 29 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "net.h"

status sock_connect(connection *c) {
status sock_connect(connection *c, char *host) {
return OK;
}

Expand Down
4 changes: 2 additions & 2 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
3 changes: 2 additions & 1 deletion src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
5 changes: 4 additions & 1 deletion src/wrk.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static struct config {
bool delay;
bool dynamic;
bool latency;
char *host;
char *script;
SSL_CTX *ctx;
} cfg;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 50305ed

Please sign in to comment.