Browse Source

Update goodbyedpi.c

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

83
src/goodbyedpi.c

@ -184,17 +184,12 @@ static void add_filter_str(int proto, int port) {
size_t new_filter_size = strlen(filter_string) + (proto == IPPROTO_UDP ? strlen(udp) : strlen(tcp)) + 16; size_t new_filter_size = strlen(filter_string) + (proto == IPPROTO_UDP ? strlen(udp) : strlen(tcp)) + 16;
char *new_filter = malloc(new_filter_size); char *new_filter = malloc(new_filter_size);
if (proto == IPPROTO_UDP) { sprintf(new_filter, proto == IPPROTO_UDP ? udp : tcp, port, port);
snprintf(new_filter, new_filter_size, udp, port, port);
} else {
snprintf(new_filter, new_filter_size, tcp, port, port);
}
free(filter_string); free(filter_string);
filter_string = new_filter; filter_string = new_filter;
} }
static void add_ip_id_str(int id) { static void add_ip_id_str(int id) {
const char *ipid = " or ip.Id == %d"; const char *ipid = " or ip.Id == %d";
char *addfilter = malloc(strlen(ipid) + 16); char *addfilter = malloc(strlen(ipid) + 16);
@ -420,93 +415,43 @@ static const char *find_http_method_end(const char *pkt, unsigned int http_frag,
const char *method_end = NULL; const char *method_end = NULL;
int fragmented = 0; int fragmented = 0;
switch (*pkt) {
case 'G':
if (strncmp(pkt, "GET", 3) == 0) { if (strncmp(pkt, "GET", 3) == 0) {
method_end = pkt + 3; method_end = pkt + 3;
} } else if (strncmp(pkt, "POST", 4) == 0) {
break;
case 'P':
if (strncmp(pkt, "POST", 4) == 0) {
method_end = pkt + 4; method_end = pkt + 4;
} } else if (strncmp(pkt, "HEAD", 4) == 0) {
break;
case 'H':
if (strncmp(pkt, "HEAD", 4) == 0) {
method_end = pkt + 4; method_end = pkt + 4;
} } else if (strncmp(pkt, "OPTIONS", 7) == 0) {
break;
case 'O':
if (strncmp(pkt, "OPTIONS", 7) == 0) {
method_end = pkt + 7; method_end = pkt + 7;
} } else if (strncmp(pkt, "DELETE", 6) == 0) {
break;
case 'D':
if (strncmp(pkt, "DELETE", 6) == 0) {
method_end = pkt + 6; method_end = pkt + 6;
} } else if (strncmp(pkt, "TRACE", 5) == 0) {
break;
case 'T':
if (strncmp(pkt, "TRACE", 5) == 0) {
method_end = pkt + 5; method_end = pkt + 5;
} } else if (strncmp(pkt, "CONNECT", 7) == 0) {
break;
case 'C':
if (strncmp(pkt, "CONNECT", 7) == 0) {
method_end = pkt + 7; method_end = pkt + 7;
} } else if ((http_frag == 1 || http_frag == 2)) {
break;
default:
break;
}
if (method_end == NULL && (http_frag == 1 || http_frag == 2)) {
switch (*pkt) {
case 'E':
if (strncmp(pkt, "ET", http_frag) == 0) { if (strncmp(pkt, "ET", http_frag) == 0) {
method_end = pkt + http_frag - 1; method_end = pkt + http_frag - 1;
fragmented = 1; fragmented = 1;
} } else if (strncmp(pkt, "ST", http_frag) == 0) {
break;
case 'S':
if (strncmp(pkt, "ST", http_frag) == 0) {
method_end = pkt + http_frag - 1; method_end = pkt + http_frag - 1;
fragmented = 1; fragmented = 1;
} } else if (strncmp(pkt, "AD", http_frag) == 0) {
break;
case 'A':
if (strncmp(pkt, "AD", http_frag) == 0) {
method_end = pkt + http_frag - 1; method_end = pkt + http_frag - 1;
fragmented = 1; fragmented = 1;
} } else if (strncmp(pkt, "NS", http_frag) == 0) {
break;
case 'N':
if (strncmp(pkt, "NS", http_frag) == 0) {
method_end = pkt + http_frag - 1; method_end = pkt + http_frag - 1;
fragmented = 1; fragmented = 1;
} } else if (strncmp(pkt, "LE", http_frag) == 0) {
break;
case 'L':
if (strncmp(pkt, "LE", http_frag) == 0) {
method_end = pkt + http_frag - 1; method_end = pkt + http_frag - 1;
fragmented = 1; fragmented = 1;
} } else if (strncmp(pkt, "RACE", http_frag + 1) == 0) {
break;
case 'R':
if (strncmp(pkt, "RACE", http_frag + 1) == 0) {
method_end = pkt + http_frag - 1; method_end = pkt + http_frag - 1;
fragmented = 1; fragmented = 1;
} } else if (strncmp(pkt, "ONNECT", http_frag + 1) == 0) {
break;
case 'O':
if (strncmp(pkt, "ONNECT", http_frag + 1) == 0) {
method_end = pkt + http_frag - 1; method_end = pkt + http_frag - 1;
fragmented = 1; fragmented = 1;
} }
break;
default:
break;
}
} }
if (method_end != NULL && is_fragmented != NULL) { if (method_end != NULL && is_fragmented != NULL) {

Loading…
Cancel
Save