From 66ed595c52f47e0911b035f1c875e6dd0c30765a Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 30 Mar 2018 01:14:44 -0700 Subject: [PATCH] Add back the SNI addr reconstructor --- src/local.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/local.c b/src/local.c index 2dea3a3d..84bd924c 100644 --- a/src/local.c +++ b/src/local.c @@ -826,6 +826,20 @@ server_recv_cb(EV_P_ ev_io *w, int revents) // Not bypass if (remote == NULL) { remote = create_remote(server->listener, NULL); + + if (sni_detected) { + // Reconstruct address buffer + abuf->len = 0; + abuf->data[abuf->len++] = 3; + abuf->data[abuf->len++] = ret; + memcpy(abuf->data + abuf->len, hostname, ret); + abuf->len += ret; + dst_port = htons(dst_port); + memcpy(abuf->data + abuf->len, &dst_port, 2); + abuf->len += 2; + + ss_free(hostname); + } } if (remote == NULL) {