mirror of
https://github.com/bol-van/zapret.git
synced 2024-12-02 14:40:52 +03:00
Compare commits
No commits in common. "3fc6b86cf5f095d4cbdbb40dadd2068f887abef7" and "abcfa611685c750e95aa186879099ea413562911" have entirely different histories.
3fc6b86cf5
...
abcfa61168
24
mdig/mdig.c
24
mdig/mdig.c
@ -74,16 +74,15 @@ static const char* eai_str(int r)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dom_valid(char *dom)
|
bool dom_valid(char *dom)
|
||||||
{
|
{
|
||||||
if (!dom || *dom=='.') return false;
|
if (!dom || *dom=='.') return false;
|
||||||
for (; *dom; dom++)
|
for (; *dom; dom++)
|
||||||
if (*dom < 0x20 || (*dom & 0x80) || !(*dom == '.' || *dom == '-' || *dom == '_' || (*dom >= '0' && *dom <= '9') || (*dom >= 'a' && *dom <= 'z') || (*dom >= 'A' && *dom <= 'Z')))
|
if (*dom < 0x20 || *dom>0x7F || !(*dom == '.' || *dom == '-' || *dom == '_' || *dom >= '0' && *dom <= '9' || *dom >= 'a' && *dom <= 'z' || *dom >= 'A' && *dom <= 'Z'))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
void invalid_domain_beautify(char *dom)
|
||||||
static void invalid_domain_beautify(char *dom)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; *dom && i < 64; i++, dom++)
|
for (int i = 0; *dom && i < 64; i++, dom++)
|
||||||
if (*dom < 0x20 || *dom>0x7F) *dom = '?';
|
if (*dom < 0x20 || *dom>0x7F) *dom = '?';
|
||||||
@ -160,14 +159,14 @@ static void stat_print(int ct, int ct_ok)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stat_plus(bool is_ok)
|
static void stat_plus(char is_ok)
|
||||||
{
|
{
|
||||||
int ct, ct_ok;
|
int ct, ct_ok;
|
||||||
if (glob.stats_every > 0)
|
if (glob.stats_every > 0)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&glob.slock);
|
pthread_mutex_lock(&glob.slock);
|
||||||
ct = ++glob.stats_ct;
|
ct = ++glob.stats_ct;
|
||||||
ct_ok = glob.stats_ct_ok += is_ok;
|
ct_ok = glob.stats_ct_ok += !!is_ok;
|
||||||
pthread_mutex_unlock(&glob.slock);
|
pthread_mutex_unlock(&glob.slock);
|
||||||
|
|
||||||
if (!(ct % glob.stats_every)) stat_print(ct, ct_ok);
|
if (!(ct % glob.stats_every)) stat_print(ct, ct_ok);
|
||||||
@ -190,8 +189,7 @@ static void *t_resolver(void *arg)
|
|||||||
{
|
{
|
||||||
int tid = (int)(size_t)arg;
|
int tid = (int)(size_t)arg;
|
||||||
int i, r;
|
int i, r;
|
||||||
char dom[256];
|
char dom[256], is_ok;
|
||||||
bool is_ok;
|
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
struct addrinfo *result;
|
struct addrinfo *result;
|
||||||
|
|
||||||
@ -203,9 +201,9 @@ static void *t_resolver(void *arg)
|
|||||||
|
|
||||||
while (interlocked_get_dom(dom, sizeof(dom)))
|
while (interlocked_get_dom(dom, sizeof(dom)))
|
||||||
{
|
{
|
||||||
is_ok = false;
|
|
||||||
if (*dom)
|
if (*dom)
|
||||||
{
|
{
|
||||||
|
is_ok = 0;
|
||||||
uint16_t family;
|
uint16_t family;
|
||||||
char *s_mask, s_ip[sizeof(dom)];
|
char *s_mask, s_ip[sizeof(dom)];
|
||||||
|
|
||||||
@ -215,7 +213,7 @@ static void *t_resolver(void *arg)
|
|||||||
family = GetAddrFamily(s_ip);
|
family = GetAddrFamily(s_ip);
|
||||||
if (family)
|
if (family)
|
||||||
{
|
{
|
||||||
if ((family == AF_INET && (glob.family & FAMILY4)) || (family == AF_INET6 && (glob.family & FAMILY6)))
|
if (family == AF_INET && (glob.family & FAMILY4) || family == AF_INET6 && (glob.family & FAMILY6))
|
||||||
{
|
{
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
bool mask_needed = false;
|
bool mask_needed = false;
|
||||||
@ -231,7 +229,7 @@ static void *t_resolver(void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
is_ok = true;
|
is_ok = 1;
|
||||||
if (is_ok)
|
if (is_ok)
|
||||||
interlocked_fprintf(stdout, mask_needed ? "%s/%u\n" : "%s\n", s_ip, mask);
|
interlocked_fprintf(stdout, mask_needed ? "%s/%u\n" : "%s\n", s_ip, mask);
|
||||||
else
|
else
|
||||||
@ -254,7 +252,7 @@ static void *t_resolver(void *arg)
|
|||||||
{
|
{
|
||||||
print_addrinfo(result);
|
print_addrinfo(result);
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
is_ok = true;
|
is_ok = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
27
nfq/desync.c
27
nfq/desync.c
@ -478,9 +478,6 @@ static uint8_t dpi_desync_tcp_packet_play(bool replay, size_t reasm_offset, uint
|
|||||||
{
|
{
|
||||||
uint8_t verdict=VERDICT_PASS;
|
uint8_t verdict=VERDICT_PASS;
|
||||||
|
|
||||||
// additional safety check
|
|
||||||
if (!!ip == !!ip6hdr) return verdict;
|
|
||||||
|
|
||||||
t_ctrack *ctrack=NULL, *ctrack_replay=NULL;
|
t_ctrack *ctrack=NULL, *ctrack_replay=NULL;
|
||||||
bool bReverse=false;
|
bool bReverse=false;
|
||||||
|
|
||||||
@ -603,12 +600,15 @@ static uint8_t dpi_desync_tcp_packet_play(bool replay, size_t reasm_offset, uint
|
|||||||
}
|
}
|
||||||
} // !replay
|
} // !replay
|
||||||
|
|
||||||
ttl_fake = (ctrack_replay && ctrack_replay->autottl) ? ctrack_replay->autottl : (ip6hdr ? (params.desync_ttl6 ? params.desync_ttl6 : ttl_orig) : (params.desync_ttl ? params.desync_ttl : ttl_orig));
|
if (params.desync_mode0!=DESYNC_NONE || params.desync_mode!=DESYNC_NONE) // save some cpu
|
||||||
flags_orig = *((uint8_t*)tcphdr+13);
|
{
|
||||||
scale_factor = tcp_find_scale_factor(tcphdr);
|
ttl_fake = (ctrack_replay && ctrack_replay->autottl) ? ctrack_replay->autottl : (ip6hdr ? (params.desync_ttl6 ? params.desync_ttl6 : ttl_orig) : (params.desync_ttl ? params.desync_ttl : ttl_orig));
|
||||||
timestamps = tcp_find_timestamps(tcphdr);
|
flags_orig = *((uint8_t*)tcphdr+13);
|
||||||
|
scale_factor = tcp_find_scale_factor(tcphdr);
|
||||||
|
timestamps = tcp_find_timestamps(tcphdr);
|
||||||
|
|
||||||
extract_endpoints(ip, ip6hdr, tcphdr, NULL, &src, &dst);
|
extract_endpoints(ip, ip6hdr, tcphdr, NULL, &src, &dst);
|
||||||
|
}
|
||||||
|
|
||||||
if (!replay)
|
if (!replay)
|
||||||
{
|
{
|
||||||
@ -955,10 +955,6 @@ static uint8_t dpi_desync_tcp_packet_play(bool replay, size_t reasm_offset, uint
|
|||||||
// this mode is final, no other options available
|
// this mode is final, no other options available
|
||||||
return VERDICT_DROP;
|
return VERDICT_DROP;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
// fix code analyzer warning
|
|
||||||
pkt1_len=0;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b)
|
if (b)
|
||||||
@ -1196,9 +1192,6 @@ static uint8_t dpi_desync_udp_packet_play(bool replay, size_t reasm_offset, uint
|
|||||||
{
|
{
|
||||||
uint8_t verdict=VERDICT_PASS;
|
uint8_t verdict=VERDICT_PASS;
|
||||||
|
|
||||||
// additional safety check
|
|
||||||
if (!!ip == !!ip6hdr) return verdict;
|
|
||||||
|
|
||||||
// no need to desync middle packets in reasm session
|
// no need to desync middle packets in reasm session
|
||||||
if (reasm_offset) return verdict;
|
if (reasm_offset) return verdict;
|
||||||
|
|
||||||
@ -1474,10 +1467,6 @@ static uint8_t dpi_desync_udp_packet_play(bool replay, size_t reasm_offset, uint
|
|||||||
}
|
}
|
||||||
desync_mode = params.desync_mode2;
|
desync_mode = params.desync_mode2;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
// fix code analyzer warning
|
|
||||||
pkt1_len=0;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b)
|
if (b)
|
||||||
|
@ -281,7 +281,7 @@ static bool TLSExtractHostFromExt(const uint8_t *ext, size_t elen, char *host, s
|
|||||||
size_t slen = pntoh16(ext + 3);
|
size_t slen = pntoh16(ext + 3);
|
||||||
ext += 5; elen -= 5;
|
ext += 5; elen -= 5;
|
||||||
if (slen < elen) return false;
|
if (slen < elen) return false;
|
||||||
if (host && len_host)
|
if (ext && len_host)
|
||||||
{
|
{
|
||||||
if (slen >= len_host) slen = len_host - 1;
|
if (slen >= len_host) slen = len_host - 1;
|
||||||
for (size_t i = 0; i < slen; i++) host[i] = tolower(ext[i]);
|
for (size_t i = 0; i < slen; i++) host[i] = tolower(ext[i]);
|
||||||
@ -342,8 +342,6 @@ static uint8_t tvb_get_varint(const uint8_t *tvb, uint64_t *value)
|
|||||||
if (value) *value = pntoh64(tvb) & 0x3FFFFFFFFFFFFFFF;
|
if (value) *value = pntoh64(tvb) & 0x3FFFFFFFFFFFFFFF;
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
// impossible case
|
|
||||||
if (*value) *value = 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static uint8_t tvb_get_size(uint8_t tvb)
|
static uint8_t tvb_get_size(uint8_t tvb)
|
||||||
|
@ -271,7 +271,7 @@ static bool TLSExtractHostFromExt(const uint8_t *ext, size_t elen, char *host, s
|
|||||||
size_t slen = pntoh16(ext + 3);
|
size_t slen = pntoh16(ext + 3);
|
||||||
ext += 5; elen -= 5;
|
ext += 5; elen -= 5;
|
||||||
if (slen < elen) return false;
|
if (slen < elen) return false;
|
||||||
if (host && len_host)
|
if (ext && len_host)
|
||||||
{
|
{
|
||||||
if (slen >= len_host) slen = len_host - 1;
|
if (slen >= len_host) slen = len_host - 1;
|
||||||
for (size_t i = 0; i < slen; i++) host[i] = tolower(ext[i]);
|
for (size_t i = 0; i < slen; i++) host[i] = tolower(ext[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user