diff --git a/src/fakepackets.c b/src/fakepackets.c index adb261ab..945a3d23 100644 --- a/src/fakepackets.c +++ b/src/fakepackets.c @@ -7,7 +7,7 @@ #include "windivert.h" #include "goodbyedpi.h" -static const unsigned char fake_http_request[] = "GET / HTTP/1.1\r\nHost: www.w3.org\r\n" +static const unsigned char fake_http_request[] = "GET / HTTP/3.0\r\nHost: www.yandex.ru\r\n" "User-Agent: curl/8.2.1\r\nAccept: */*\r\n" "Accept-Encoding: deflate, gzip, br\r\n\r\n"; static const unsigned char fake_https_request[] = { diff --git a/src/goodbyedpi.c b/src/goodbyedpi.c index d6cbb5bc..2ed2db8e 100644 --- a/src/goodbyedpi.c +++ b/src/goodbyedpi.c @@ -1466,4 +1466,4 @@ int main(int argc, char *argv[]) { break; } } -} +} \ No newline at end of file diff --git a/src/ttltrack.c b/src/ttltrack.c index acac0612..69201e30 100644 --- a/src/ttltrack.c +++ b/src/ttltrack.c @@ -38,6 +38,8 @@ typedef struct tcp_connrecord { static time_t last_cleanup = 0; static tcp_connrecord_t *conntrack = NULL; +static tcp_connrecord_t connrecord_pool[CONNRECORD_POOL_SIZE]; +static int connrecord_pool_index = 0; inline static void fill_key_data(char *key, const uint8_t is_ipv6, const uint32_t srcip[4], const uint32_t dstip[4], const uint16_t srcport, const uint16_t dstport) @@ -145,7 +147,7 @@ static int add_tcp_conntrack(const uint32_t srcip[4], const uint32_t dstip[4], if (!(srcip && srcport && dstip && dstport)) return FALSE; - tcp_connrecord_t *tmp_connrecord = malloc(sizeof(tcp_connrecord_t)); + tcp_connrecord_t *tmp_connrecord = &connrecord_pool[connrecord_pool_index++]; construct_key(srcip, dstip, srcport, dstport, tmp_connrecord->key, is_ipv6); if (!check_get_tcp_conntrack_key(tmp_connrecord->key, NULL)) { @@ -156,7 +158,6 @@ static int add_tcp_conntrack(const uint32_t srcip[4], const uint32_t dstip[4], return TRUE; } debug("Not added TCP conntrack %u:%hu - %u:%hu\n", srcip[0], ntohs(srcport), dstip[0], ntohs(dstport)); - free(tmp_connrecord); return FALSE; } @@ -173,8 +174,7 @@ static void tcp_cleanup() { HASH_ITER(hh, conntrack, tmp_connrecord, tmp_connrecord2) { if (difftime(last_cleanup, tmp_connrecord->time) >= TCP_CLEANUP_INTERVAL_SEC) { - HASH_DEL(conntrack, tmp_connrecord); - free(tmp_connrecord); + HASH_DELETE(hh, conntrack, tmp_connrecord); } } } @@ -209,8 +209,7 @@ int tcp_handle_outgoing(uint32_t srcip[4], uint32_t dstip[4], if (check_get_tcp_conntrack_key(key, &tmp_connrecord) && tmp_connrecord) { /* Connection exists in conntrack, moving on */ deconstruct_key(key, tmp_connrecord, conn_info); - HASH_DEL(conntrack, tmp_connrecord); - free(tmp_connrecord); + HASH_DELETE(hh, conntrack, tmp_connrecord); debug("____tcp_handle_outgoing TRUE: srcport = %hu\n", ntohs(srcport)); return TRUE; } @@ -249,4 +248,4 @@ int tcp_get_auto_ttl(const uint8_t ttl, const uint8_t autottl1, } return ttl_of_fake_packet; -} \ No newline at end of file +} diff --git a/src/utils/uthash.h b/src/utils/uthash.h index 9a396b61..070f7b44 100644 --- a/src/utils/uthash.h +++ b/src/utils/uthash.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2021, Troy D. Hanson http://troydhanson.github.io/uthash/ +Copyright (c) 2003-2022, Troy D. Hanson https://troydhanson.github.io/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -51,6 +51,8 @@ typedef unsigned char uint8_t; #else /* VS2008 or older (or VS2010 in C mode) */ #define NO_DECLTYPE #endif +#elif defined(__MCST__) /* Elbrus C Compiler */ +#define DECLTYPE(x) (__typeof(x)) #elif defined(__BORLANDC__) || defined(__ICCARM__) || defined(__LCC__) || defined(__WATCOMC__) #define NO_DECLTYPE #else /* GNU, Sun and other compilers */ @@ -450,7 +452,7 @@ do { #define HASH_DELETE_HH(hh,head,delptrhh) \ do { \ - struct UT_hash_handle *_hd_hh_del = (delptrhh); \ + const struct UT_hash_handle *_hd_hh_del = (delptrhh); \ if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) { \ HASH_BLOOM_FREE((head)->hh.tbl); \ uthash_free((head)->hh.tbl->buckets, \ @@ -593,7 +595,9 @@ do { /* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at - * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */ + * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx + * (archive link: https://archive.is/Ivcan ) + */ #define HASH_SAX(key,keylen,hashv) \ do { \ unsigned _sx_i; \ @@ -1133,4 +1137,4 @@ typedef struct UT_hash_handle { unsigned hashv; /* result of hash-fcn(key) */ } UT_hash_handle; -#endif /* UTHASH_H */ +#endif /* UTHASH_H */ \ No newline at end of file