mirror of
https://github.com/hufrea/byedpi.git
synced 2024-12-30 14:44:56 +00:00
Add IPv4 to proto list
This commit is contained in:
parent
276073ddea
commit
890a66ee2f
@ -69,8 +69,8 @@ ciadpi --fake -1 --ttl 8
|
||||
Таймаут ожидания первого ответа от сервера в секундах
|
||||
В Linux переводится в миллисекунды, поэтому можно указать дробное число
|
||||
|
||||
-K, --proto <t,h,u>
|
||||
Белый список протоколов: tls,http,udp
|
||||
-K, --proto <t,h,u,i>
|
||||
Белый список протоколов: tls,http,udp,ipv4
|
||||
|
||||
-H, --hosts <file|:string>
|
||||
Ограничить область действия параметров списком доменов
|
||||
|
45
extend.c
45
extend.c
@ -117,13 +117,6 @@ static int cache_add(const struct sockaddr_ina *dst, int m)
|
||||
}
|
||||
|
||||
|
||||
static inline bool check_port(const uint16_t *p, const struct sockaddr_in6 *dst)
|
||||
{
|
||||
return (dst->sin6_port >= p[0]
|
||||
&& dst->sin6_port <= p[1]);
|
||||
}
|
||||
|
||||
|
||||
int connect_hook(struct poolhd *pool, struct eval *val,
|
||||
const struct sockaddr_ina *dst, int next)
|
||||
{
|
||||
@ -195,10 +188,10 @@ static bool check_host(
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool check_proto_tcp(int proto, const char *buffer, ssize_t n)
|
||||
{
|
||||
if (proto & IS_TCP) {
|
||||
if (!(proto & ~IS_IPV4)) {
|
||||
return 1;
|
||||
}
|
||||
else if ((proto & IS_HTTP) &&
|
||||
@ -213,6 +206,27 @@ static bool check_proto_tcp(int proto, const char *buffer, ssize_t n)
|
||||
}
|
||||
|
||||
|
||||
static bool check_l34(int proto, const uint16_t *pf, int st, const struct sockaddr_in6 *dst)
|
||||
{
|
||||
if ((proto & IS_UDP) && (st != SOCK_DGRAM)) {
|
||||
return 0;
|
||||
}
|
||||
if (proto & IS_IPV4) {
|
||||
static const char *pat = "\0\0\0\0\0\0\0\0\0\0\xff\xff";
|
||||
|
||||
if (dst->sin6_family != AF_INET
|
||||
&& memcmp(&dst->sin6_addr, pat, 12)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (pf[0] &&
|
||||
(dst->sin6_port < pf[0] || dst->sin6_port > pf[1])) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static bool check_round(const int *nr, int r)
|
||||
{
|
||||
return (!nr[1] && r <= 1) || (r >= nr[0] && r <= nr[1]);
|
||||
@ -325,10 +339,10 @@ static int setup_conn(struct eval *client, const char *buffer, ssize_t n)
|
||||
|
||||
if (!m) for (; m < params.dp_count; m++) {
|
||||
struct desync_params *dp = ¶ms.dp[m];
|
||||
if (!dp->detect &&
|
||||
(!dp->pf[0] || check_port(dp->pf, &client->pair->in6)) &&
|
||||
(!dp->proto || check_proto_tcp(dp->proto, buffer, n)) &&
|
||||
(!dp->hosts || check_host(dp->hosts, buffer, n))) {
|
||||
if (!dp->detect
|
||||
&& (check_l34(dp->proto, dp->pf, SOCK_STREAM, &client->pair->in6)
|
||||
&& check_proto_tcp(dp->proto, buffer, n))
|
||||
&& (!dp->hosts || check_host(dp->hosts, buffer, n))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -528,9 +542,8 @@ ssize_t udp_hook(struct eval *val,
|
||||
if (!m) {
|
||||
for (; m < params.dp_count; m++) {
|
||||
struct desync_params *dp = ¶ms.dp[m];
|
||||
if (!dp->detect &&
|
||||
(!dp->proto || (dp->proto & IS_UDP)) &&
|
||||
(!dp->pf[0] || check_port(dp->pf, &dst->in6))) {
|
||||
if (!dp->detect
|
||||
&& check_l34(dp->proto, dp->pf, SOCK_DGRAM, &dst->in6)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
5
main.c
5
main.c
@ -83,7 +83,7 @@ const static char help_text[] = {
|
||||
#ifdef TIMEOUT_SUPPORT
|
||||
" -T, --timeout <sec> Timeout waiting for response, after which trigger auto\n"
|
||||
#endif
|
||||
" -K, --proto <t,h,u> Protocol whitelist: tls,http,udp\n"
|
||||
" -K, --proto <t,h,u,i> Protocol whitelist: tls,http,udp,ipv4\n"
|
||||
" -H, --hosts <file|:str> Hosts whitelist, filename or :string\n"
|
||||
" -V, --pf <port[-portr]> Ports range whitelist\n"
|
||||
" -R, --round <num[-numr]> Number of request to which desync will be applied\n"
|
||||
@ -687,6 +687,9 @@ int main(int argc, char **argv)
|
||||
case 'u':
|
||||
dp->proto |= IS_UDP;
|
||||
break;
|
||||
case 'i':
|
||||
dp->proto |= IS_IPV4;
|
||||
break;
|
||||
default:
|
||||
invalid = 1;
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user