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).
26 lines
816 B
C
26 lines
816 B
C
#ifndef _TTLTRACK_H
|
|
#define _TTLTRACK_H
|
|
#include <stdint.h>
|
|
#include "dnsredir.h"
|
|
|
|
typedef struct tcp_conntrack_info {
|
|
uint8_t is_ipv6;
|
|
uint8_t ttl;
|
|
uint32_t srcip[4];
|
|
uint16_t srcport;
|
|
uint32_t dstip[4];
|
|
uint16_t dstport;
|
|
} tcp_conntrack_info_t;
|
|
|
|
int tcp_handle_incoming(const uint32_t srcip[4], const uint32_t dstip[4],
|
|
const uint16_t srcport, const uint16_t dstport,
|
|
const uint8_t is_ipv6, const uint8_t ttl);
|
|
|
|
int tcp_handle_outgoing(const uint32_t srcip[4], const uint32_t dstip[4],
|
|
const uint16_t srcport, const uint16_t dstport,
|
|
tcp_conntrack_info_t *conn_info,
|
|
const uint8_t is_ipv6);
|
|
|
|
int tcp_get_auto_ttl(const uint8_t ttl, const uint8_t decrease_for);
|
|
#endif
|