diff options
author | Vladislav Grishenko <themiron@mail.ru> | 2018-02-28 22:56:27 +0500 |
---|---|---|
committer | Vladislav Grishenko <themiron@mail.ru> | 2018-02-28 22:56:27 +0500 |
commit | 01e86fef006e29e2adc572331c2a31d81cce64e3 (patch) | |
tree | fb0ad5d788afc60df2cf18b97a9ae61ae7539e5a /accel-pppd/ctrl | |
parent | 1bf534037169274a4d27b72fc0639fe87eefb3ca (diff) | |
download | accel-ppp-01e86fef006e29e2adc572331c2a31d81cce64e3.tar.gz accel-ppp-01e86fef006e29e2adc572331c2a31d81cce64e3.zip |
sstp: http: improve http detection
no need to wait until timeout for non-http data (i.e https)
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/sstp/sstp.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/accel-pppd/ctrl/sstp/sstp.c b/accel-pppd/ctrl/sstp/sstp.c index 691928b0..d6262e8b 100644 --- a/accel-pppd/ctrl/sstp/sstp.c +++ b/accel-pppd/ctrl/sstp/sstp.c @@ -901,16 +901,23 @@ error: static int http_handler(struct sstp_conn_t *conn, struct buffer_t *buf) { - static const char *table[] = { "\r\n\r\n", "\n\n", NULL }; + static const char *table[] = { "\n\r\n", "\r\r\n", NULL }; const char **pptr; - char *ptr, *end; + uint8_t *ptr, *end = NULL; int n; if (conn->sstp_state != STATE_SERVER_CALL_DISCONNECTED) return -1; - end = NULL; - for (pptr = table; *pptr; pptr++) { + ptr = buf->head; + while (ptr < buf->tail && *ptr == ' ') + ptr++; + if (ptr == buf->tail) + return 0; + else if (strncasecmp((char *)ptr, SSTP_HTTP_METHOD, + min(buf->tail - ptr, sizeof(SSTP_HTTP_METHOD) - 1)) != 0) + end = buf->tail; + else for (pptr = table; *pptr; pptr++) { ptr = memmem(buf->head, buf->len, *pptr, strlen(*pptr)); if (ptr && (!end || ptr < end)) end = ptr + strlen(*pptr); @@ -921,7 +928,7 @@ static int http_handler(struct sstp_conn_t *conn, struct buffer_t *buf) log_ppp_error("recv [HTTP too long header]\n"); return -1; } else - n = end - (char *)buf->head; + n = end - buf->head; if (http_recv_request(conn, buf->head, n) < 0) return -1; |