Skip to content

Commit 50305ed

Browse files
committed
send hostname in TLS SNI extension
1 parent 040db59 commit 50305ed

7 files changed

Lines changed: 44 additions & 6 deletions

File tree

CHANGES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
wrk 4.0.2
2+
3+
* Send hostname using TLS SNI.
4+
* Add optional WITH_OPENSSL and WITH_LUAJIT to use system libs.
5+
* Bundle OpenSSL 1.0.2.
16
* delay() can return milliseconds to delay sending next request.
27

38
wrk 4.0.0

INSTALL

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Overview
2+
3+
wrk should build on most UNIX-like operating systems and
4+
architectures that have GNU make and are supported by LuaJIT and
5+
OpenSSL. Some systems may require additional CFLAGS or LDFLAGS,
6+
see the top of the Makefile for examples
7+
8+
In many cases simply running `make` (often `gmake` on *BSD) will
9+
do the trick.
10+
11+
Dependencies
12+
13+
wrk requires LuaJIT and OpenSSL and is distributed with appropriate
14+
versions that will be unpacked and built as necessary.
15+
16+
If you are building wrk packages for an OS distribution or otherwise
17+
prefer to use system versions of dependencies you may specify their
18+
location when invoking make with one or more of:
19+
20+
WITH_LUAJIT
21+
WITH_OPENSSL
22+
23+
For example to use the system version of both libraries on Linux:
24+
25+
make WITH_LUAJIT=/usr WITH_OPENSSL=/usr
26+
27+
Or to use the Homebrew version of OpenSSL on Mac OS X:
28+
29+
make WITH_OPENSSL=/usr/local/opt/openssl

src/net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include "net.h"
88

9-
status sock_connect(connection *c) {
9+
status sock_connect(connection *c, char *host) {
1010
return OK;
1111
}
1212

src/net.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ typedef enum {
1313
} status;
1414

1515
struct sock {
16-
status ( *connect)(connection *);
16+
status ( *connect)(connection *, char *);
1717
status ( *close)(connection *);
1818
status ( *read)(connection *, size_t *);
1919
status ( *write)(connection *, char *, size_t, size_t *);
2020
size_t (*readable)(connection *);
2121
};
2222

23-
status sock_connect(connection *);
23+
status sock_connect(connection *, char *);
2424
status sock_close(connection *);
2525
status sock_read(connection *, size_t *);
2626
status sock_write(connection *, char *, size_t, size_t *);

src/ssl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ SSL_CTX *ssl_init() {
4949
return ctx;
5050
}
5151

52-
status ssl_connect(connection *c) {
52+
status ssl_connect(connection *c, char *host) {
5353
int r;
5454
SSL_set_fd(c->ssl, c->fd);
55+
SSL_set_tlsext_host_name(c->ssl, host);
5556
if ((r = SSL_connect(c->ssl)) != 1) {
5657
switch (SSL_get_error(c->ssl, r)) {
5758
case SSL_ERROR_WANT_READ: return RETRY;

src/ssl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
SSL_CTX *ssl_init();
77

8-
status ssl_connect(connection *);
8+
status ssl_connect(connection *, char *);
99
status ssl_close(connection *);
1010
status ssl_read(connection *, size_t *);
1111
status ssl_write(connection *, char *, size_t, size_t *);

src/wrk.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ static struct config {
1313
bool delay;
1414
bool dynamic;
1515
bool latency;
16+
char *host;
1617
char *script;
1718
SSL_CTX *ctx;
1819
} cfg;
@@ -98,6 +99,8 @@ int main(int argc, char **argv) {
9899
exit(1);
99100
}
100101

102+
cfg.host = host;
103+
101104
for (uint64_t i = 0; i < cfg.threads; i++) {
102105
thread *t = &threads[i];
103106
t->loop = aeCreateEventLoop(10 + cfg.connections * 3);
@@ -359,7 +362,7 @@ static int response_complete(http_parser *parser) {
359362
static void socket_connected(aeEventLoop *loop, int fd, void *data, int mask) {
360363
connection *c = data;
361364

362-
switch (sock.connect(c)) {
365+
switch (sock.connect(c, cfg.host)) {
363366
case OK: break;
364367
case ERROR: goto error;
365368
case RETRY: return;

0 commit comments

Comments
 (0)