Skip to content

Commit a8b5f71

Browse files
committed
client: add ipv6 option
1 parent ea731a7 commit a8b5f71

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

wss-proxy-client.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
struct wss_server_info {
1717
uint8_t tls: 1;
1818
uint8_t ws: 1;
19+
uint8_t ipv6: 1;
1920
uint16_t port;
2021
const char *addr;
2122
const char *host;
@@ -150,6 +151,11 @@ static int init_wss_addr(struct wss_server_info *server) {
150151
server->ws = 1;
151152
}
152153

154+
// ipv6
155+
if ((value = find_option(options, "ipv6", "1")) != NULL) {
156+
server->ipv6 = (int) strtol(value, NULL, 10);
157+
}
158+
153159
// strip
154160
server->host = strdup(server->host);
155161
if ((end = strchr(server->host, ';')) != NULL) {
@@ -173,7 +179,7 @@ static int init_wss_addr(struct wss_server_info *server) {
173179
wss = "ss";
174180
}
175181
}
176-
LOGI("wss client %s:%d (%s://%s%s)", remote_host, port, wss, server->host, server->path);
182+
LOGI("wss client%s %s:%d (%s://%s%s)", server->ipv6 ? "6" : "", remote_host, port, wss, server->host, server->path);
177183
if (server->ws && mux) {
178184
LOGW("mux %d is unsupported", mux);
179185
}
@@ -303,6 +309,10 @@ static struct evhttp_connection *connect_wss(struct wss_proxy_context *context,
303309
goto error;
304310
}
305311

312+
if (context->server.ipv6) {
313+
evhttp_connection_set_family(wss, AF_INET6);
314+
}
315+
306316
evhttp_connection_set_timeout(wss, WSS_TIMEOUT);
307317
if (raw->be_ops) {
308318
bufferevent_setcb(raw, NULL, NULL, raw_event_cb, wss);

0 commit comments

Comments
 (0)