Browse Source

Add files via upload

pull/319/head
SashaXser 2 years ago
committed by GitHub
parent
commit
d7cc055037
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 38
      src/goodbyedpi.c

38
src/goodbyedpi.c

@ -136,18 +136,18 @@ static int running_from_service = 0;
static int exiting = 0; static int exiting = 0;
static HANDLE filters[MAX_FILTERS]; static HANDLE filters[MAX_FILTERS];
static int filter_num = 0; static int filter_num = 0;
static const char *http10_redirect_302 = "HTTP/1.0 302 "; static const char http10_redirect_302[] = "HTTP/1.0 302 ";
static const char *http11_redirect_302 = "HTTP/1.1 302 "; static const char http11_redirect_302[] = "HTTP/1.1 302 ";
static const char http_host_find[] = "\r\nHost: "; static const char http_host_find[] = "\r\nHost: ";
static const char http_host_replace[] = "\r\nhoSt: "; static const char http_host_replace[] = "\r\nhoSt: ";
static const char http_useragent_find[] = "\r\nUser-Agent: "; static const char http_useragent_find[] = "\r\nUser-Agent: ";
static const char location_http[] = "\r\nLocation: http://"; static const char location_http[] = "\r\nLocation: http://";
static const char connection_close[] = "\r\nConnection: close"; static const char connection_close[] = "\r\nConnection: close";
static const char *http_methods[] = { static const char *http_methods[] = {
"GET ", "GET ",
"HEAD ", "HEAD ",
"POST ", "POST ",
"PUT ", "PUT ",
"DELETE ", "DELETE ",
"CONNECT ", "CONNECT ",
"OPTIONS ", "OPTIONS ",
@ -156,7 +156,7 @@ static const char *http_methods[] = {
static struct option long_options[] = { static struct option long_options[] = {
{"port", required_argument, 0, 'z' }, {"port", required_argument, 0, 'z' },
{"dns-addr", required_argument, 0, 'd' }, {"dns-addr", required_argument, 0, 'd' },
{"dns-port", required_argument, 0, 'g' }, {"dns-port", required_argument, 0, 'g' },
{"dnsv6-addr", required_argument, 0, '!' }, {"dnsv6-addr", required_argument, 0, '!' },
{"dnsv6-port", required_argument, 0, '@' }, {"dnsv6-port", required_argument, 0, '@' },
{"dns-verb", no_argument, 0, 'v' }, {"dns-verb", no_argument, 0, 'v' },
@ -316,27 +316,19 @@ static void mix_case(char *pktdata, unsigned int pktlen) {
static int is_passivedpi_redirect(const char *pktdata, unsigned int pktlen) { static int is_passivedpi_redirect(const char *pktdata, unsigned int pktlen) {
/* First check if this is HTTP 302 redirect */
/* Check HTTP status code using hash table lookup */ if (memcmp(pktdata, http11_redirect_302, sizeof(http11_redirect_302)-1) == 0 ||
if (http_status_code_hash(pktdata) == 302) { memcmp(pktdata, http10_redirect_302, sizeof(http10_redirect_302)-1) == 0)
{
/* Search for location header using Boyer-Moore */ /* Then check if this is a redirect to new http site with Connection: close */
if (boyer_moore_search(pktdata, pktlen, location_http, sizeof(location_http)-1)) { if (dumb_memmem(pktdata, pktlen, location_http, sizeof(location_http)-1) &&
dumb_memmem(pktdata, pktlen, connection_close, sizeof(connection_close)-1)) {
/* Search for connection header using Boyer-Moore */ return TRUE;
if (boyer_moore_search(pktdata, pktlen, connection_close, sizeof(connection_close)-1)) { }
return TRUE;
}
} }
return FALSE;
}
return FALSE;
} }
static int find_header_and_get_info(const char *pktdata, unsigned int pktlen, static int find_header_and_get_info(const char *pktdata, unsigned int pktlen,
const char *hdrname, const char *hdrname,
char **hdrnameaddr, char **hdrnameaddr,

Loading…
Cancel
Save