mirror of
https://github.com/ValdikSS/GoodbyeDPI.git
synced 2025-12-18 05:14:35 +03:00
This is a per-connection (per-destination) automatic TTL adjusting feature.
Basically a --set-ttl mode where you don't need to set specific TTL value.
It works as follows:
1. All incoming SYN/ACKs (the response to client's SYN) are intercepted
2. TTL value is extracted from SYN/ACK
3. New TTL is calculated with the simple formula:
128 > extracted_ttl > 64: // Server is running Windows
fakepacket_ttl = 128 - extracted_ttl - decrement
64 > extracted_ttl > 34: // Server is running Linux/FreeBSD/other
fakepacket_ttl = 64 - extracted_ttl - decrement
4. Fake packet is sent
To comply with the multi-path multi-hop server connections
where 1 hop dispersion is not rare, decrement should be at least of
value "2", which is the default.
The patch does not process "too strange" TTL values (bigger than 128,
less than 34).
40 lines
1.2 KiB
C
40 lines
1.2 KiB
C
#ifndef _DNSREDIR_H
|
|
#define _DNSREDIR_H
|
|
#include <stdint.h>
|
|
|
|
typedef struct conntrack_info {
|
|
uint8_t is_ipv6;
|
|
uint32_t srcip[4];
|
|
uint16_t srcport;
|
|
uint32_t dstip[4];
|
|
uint16_t dstport;
|
|
} conntrack_info_t;
|
|
|
|
inline static void ipv4_copy_addr(uint32_t dst[4], const uint32_t src[4]) {
|
|
dst[0] = src[0];
|
|
dst[1] = 0;
|
|
dst[2] = 0;
|
|
dst[3] = 0;
|
|
}
|
|
|
|
inline static void ipv6_copy_addr(uint32_t dst[4], const uint32_t src[4]) {
|
|
dst[0] = src[0];
|
|
dst[1] = src[1];
|
|
dst[2] = src[2];
|
|
dst[3] = src[3];
|
|
}
|
|
|
|
int dns_handle_incoming(const uint32_t srcip[4], const uint16_t srcport,
|
|
const char *packet_data, const UINT packet_dataLen,
|
|
conntrack_info_t *conn_info, const uint8_t is_ipv6);
|
|
|
|
int dns_handle_outgoing(const uint32_t srcip[4], const uint16_t srcport,
|
|
const uint32_t dstip[4], const uint16_t dstport,
|
|
const char *packet_data, const UINT packet_dataLen,
|
|
const uint8_t is_ipv6
|
|
);
|
|
|
|
void flush_dns_cache();
|
|
int dns_is_dns_packet(const char *packet_data, const UINT packet_dataLen, const int outgoing);
|
|
#endif
|