Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SashaXser authored Sep 8, 2023
1 parent 5777405 commit 943c1ef
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/fakepackets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down
2 changes: 1 addition & 1 deletion src/goodbyedpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1466,4 +1466,4 @@ int main(int argc, char *argv[]) {
break;
}
}
}
}
13 changes: 6 additions & 7 deletions src/ttltrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)) {
Expand All @@ -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;
}

Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -249,4 +248,4 @@ int tcp_get_auto_ttl(const uint8_t ttl, const uint8_t autottl1,
}

return ttl_of_fake_packet;
}
}
12 changes: 8 additions & 4 deletions src/utils/uthash.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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, \
Expand Down Expand Up @@ -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; \
Expand Down Expand Up @@ -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 */

0 comments on commit 943c1ef

Please sign in to comment.