31 Commits
v71.1 ... v71.2

Author SHA1 Message Date
bol-van
c60f9c9027 doc update ver 2025-07-08 10:01:58 +03:00
bol-van
951c980bec typo 2025-07-07 17:33:36 +03:00
bol-van
5eaec085dd install_easy: warn about --ipset 2025-07-07 15:53:46 +03:00
bol-van
721b353776 doc works 2025-07-07 15:38:51 +03:00
bol-van
e6d2051c87 doc works 2025-07-07 15:37:40 +03:00
bol-van
e665794ac4 doc works 2025-07-07 15:33:41 +03:00
bol-van
7db14a07c5 tpws: openbsd no more inits /dev/pf by default 2025-07-07 15:33:02 +03:00
bol-van
c14554c1f3 Merge pull request #1585 from artur-intech/patch-1
Fix filename
2025-06-30 07:46:10 +03:00
Artur
ced1682003 Fix filename 2025-06-29 21:45:50 +03:00
Artur
4701f27372 Fix filename
It is `zapret-hosts-user.txt`, not `*-users*`.
2025-06-29 20:18:37 +03:00
bol-van
a1699067b3 Merge pull request #1575 from dass79zh/ipv6less-curl-fix
Support curl compiled without IPv6 support.
2025-06-27 21:57:08 +03:00
Andrew Danshin
643fc0c456 Support curl compiled without IPv6 support.
modified:   blockcheck.sh
2025-06-27 21:07:32 +03:00
bol-van
09c07f6d21 winws: decrease wf-save buf 2025-06-23 08:17:52 +03:00
bol-van
dd72c68ae6 winws: increase windivert filter buffers 2025-06-23 08:14:36 +03:00
bol-van
9c1a3e77cc Makefiles: CC=cc 2025-06-22 21:39:27 +03:00
bol-van
ae957e9a73 doc fix 2025-06-22 19:27:20 +03:00
bol-van
bc47a13ba4 install_bin: no help text if getarch 2025-06-16 09:13:40 +03:00
bol-van
20b69cb63d install_bin: minor improve help text 2025-06-16 07:15:08 +03:00
bol-van
ef4f8a2b86 install_bin: display help text if no bins found 2025-06-16 07:11:59 +03:00
bol-van
d00d341505 blockcheck: display kernel ver 2025-06-15 16:22:38 +03:00
bol-van
0738d3980f blockcheck: curl version display 2025-06-15 15:56:25 +03:00
bol-van
34ff4630bf blockcheck: curl version display 2025-06-15 15:55:03 +03:00
bol-van
f8b5f602a4 nfqws: allow desync of replayed udp with reasm offset !=0 2025-06-15 09:18:25 +03:00
bol-van
8dacb57a86 OPTIMIZE in makefiles 2025-06-13 22:17:32 +03:00
bol-van
9776d5d8a9 nfqws: old gcc 4.x compat 2025-06-13 11:44:11 +03:00
bol-van
f88c9a662d nfqws: allow linux build without ssid 2025-06-13 11:31:50 +03:00
bol-van
97bcb9740d update docs 2025-06-13 11:12:37 +03:00
bol-van
b6e9fa3434 nfqws: check wext ssid len not zero 2025-06-12 13:22:54 +03:00
bol-van
32cfee705a nfqws: optimize wext 2025-06-12 11:58:20 +03:00
bol-van
1303bf0fef update changes.txt 2025-06-12 11:46:34 +03:00
bol-van
2417d4ee76 nfqws: use wireless ext in case nl80211 does not return ssid 2025-06-12 11:45:14 +03:00
21 changed files with 213 additions and 56 deletions

View File

@@ -402,7 +402,15 @@ check_system()
exitp 5
esac
echo $UNAME${SUBSYS:+/$SUBSYS} detected
echo -n 'kernel: '
if [ -f "/proc/version" ]; then
cat /proc/version
else
uname -a
fi
echo firewall type is $FWTYPE
echo CURL=$CURL
$CURL --version
}
zp_already_running()
@@ -627,7 +635,11 @@ curl_with_subst_ip()
# $2 - port
# $3 - ip
# $4+ - curl params
local connect_to="--connect-to $1::[$3]${2:+:$2}" arg
local ip="$3"
case "$ip" in
*:*) ip="[$ip]" ;;
esac
local connect_to="--connect-to $1::$ip${2:+:$2}" arg
shift ; shift ; shift
[ "$CURL_VERBOSE" = 1 ] && arg="-v"
[ "$CURL_CMD" = 1 ] && echo $CURL ${arg:+$arg }$connect_to "$@"

View File

@@ -406,12 +406,15 @@ has_bad_ws_options()
{
# $1 - nfqws/tpws opts
# kernel or user mode ipset usage should be wise
# if all traffic is already intercepted it would be OK to use ip-based specialized profiles
# but if all traffic is intercepted only to filter a group of ip its BAD. kernel ipset should be used.
# I cannot insert brain to copy-pasters, I know they will misuse. But it's their problem.
# zapret is not made for newbies
#contains "$1" "--ipset"
contains "$1" "--ipset" && {
echo
echo "WARNING !!! --ipset parameter is present"
echo "It's OK if you only specialize already redirected traffic and also process the rest."
echo "If you redirect port X to process several IPs from the list and do nothing with the rest - IT'S VERY INEFFECTIVE !"
echo "Kernel ipsets should be used instead. Write custom scripts and filter IPs in kernel."
echo
}
return 1
}
check_bad_ws_options()
@@ -428,8 +431,5 @@ check_bad_ws_options()
}
help_bad_ws_options()
{
echo "WARNING ! you have specified --ipset option"
echo "WARNING ! it would work but on ${UNAME:-$(uname)} it's not the best option"
echo "WARNING ! you should use kernel mode sets. they are much more efficient."
echo "WARNING ! to use ipsets you have to write your own custom script"
echo "WARNING ! BAD options detected"
}

View File

@@ -312,7 +312,7 @@ In OpenBSD default `tpws` bind is ipv6 only. To bind to ipv4 specify
Use `--bind-addr=0.0.0.0 --bind-addr=::` to achieve the same default bind as in
others OSes.
`tpws` for forwarded traffic only :
`tpws` for forwarded traffic only (OLDER OS versions):
`/etc/pf.conf`:
```
@@ -323,13 +323,31 @@ pass in quick on em1 inet6 proto tcp to port {80,443} rdr-to ::1 port 988
Then:
```
pfctl -f /etc/pf.conf
tpws --port=988 --user=daemon --bind-addr=::1 --bind-addr=127.0.0.1
tpws --port=988 --user=daemon --bind-addr=::1 --bind-addr=127.0.0.1 --enable-pf
```
Its not clear how to do rdr-to outgoing traffic. I could not make route-to
scheme work. rdr-to support is done using /dev/pf, that's why transparent mode
requires root.
`tpws` for forwarded traffic only (NEWER OS versions):
```
pass on em1 inet proto tcp to port {80,443} divert-to 127.0.0.1 port 989
pass on em1 inet6 proto tcp to port {80,443} divert-to ::1 port 989
```
Then:
```
pfctl -f /etc/pf.conf
tpws --port=988 --user=daemon --bind-addr=::1 --bind-addr=127.0.0.1
```
tpws must be bound exactly to diverted IPs, not `0.0.0.0` or `::`.
It's also not clear how to divert connections from local system.
`dvtws` for all traffic:
`/etc/pf.conf`:

View File

@@ -19,7 +19,8 @@
* [pfsense](#pfsense)
* [OpenBSD](#openbsd)
* [tpws bind на ipv4](#tpws-bind-на-ipv4)
* [tpws для проходящего трафика](#tpws-для-проходящего-трафика)
* [tpws для проходящего трафика (старые системы)](#tpws-для-проходящего-трафика-старая-схема-не-работает-в-новых-версиях))
* [tpws для проходящего трафика (новые системы)](#tpws-для-проходящего-трафика-новые-системы))
* [Запуск dvtws](#запуск-dvtws)
* [Проблемы с badsum](#проблемы-с-badsum)
* [Особенность отправки fake пакетов](#особенность-отправки-fake-пакетов)
@@ -392,7 +393,11 @@ rdr pass on em1 inet6 proto tcp from any to any port = https -> fe80::20c:29ff:5
Но лучше все же так не делать, а сажать на определенные внутренние адреса или интерфейсы.
### tpws для проходящего трафика
### tpws для проходящего трафика (старая схема не работает в новых версиях)
В этом варианте tpws обращается явно к редиректору pf и пытается от него получить оригинальный адрес назначения.
Как показывает практика, это не работает на новых версиях OpenBSD. Возвращается ошибка ioctl.
Последняя проверенная версия, где это работает, - 6.8 . Между 6.8 и 7.4 разработчики сломали этот механизм.
`/etc/pf.conf`:
```
@@ -402,15 +407,35 @@ pass in quick on em1 inet6 proto tcp to port {80,443} rdr-to ::1 port 988
```sh
$ pfctl -f /etc/pf.conf
$ tpws --port=988 --user=daemon --bind-addr=::1 --bind-addr=127.0.0.1
$ tpws --port=988 --user=daemon --bind-addr=::1 --bind-addr=127.0.0.1 --enable-pf
```
> [!NOTE]
> [!NOTE]
> В PF не выходит делать rdr-to с той же системы, где работает proxy.
> Вариант с route-to не сохраняет мета информацию. Адрес назначения теряется.
> Поэтому этот вариант годится для squid, берущего адрес из протокола прикладного уровня, но не годится для tpws, полагающегося на метаданные ОС.
> Поддержка rdr-to реализована через `/dev/pf`, поэтому прозрачный режим **требует root**.
### tpws для проходящего трафика (новые системы)
В новых версиях предлагается использовать divert-to вместо rdr-to.
Минимально проверенная версия, где это работает, 7.4. Может работать или не работать на более старых - исследование не проводилось.
`/etc/pf.conf`:
```
pass on em1 inet proto tcp to port {80,443} divert-to 127.0.0.1 port 989
pass on em1 inet6 proto tcp to port {80,443} divert-to ::1 port 989
```
tpws должен иметь бинд на точно такой адрес, который указан в правилах pf. `0.0.0.0` или `::` не работает.
```sh
$ pfctl -f /etc/pf.conf
$ tpws --port=988 --user=daemon --bind-addr=::1 --bind-addr=127.0.0.1
```
> [!NOTE]
> Так же не понятно как делать divert с самой системы, где работает tpws.
### Запуск dvtws

View File

@@ -56,14 +56,27 @@ sysctl net.inet6.ip6.forwarding=1
OpenBSD PF :
(OLD OpenBSD versions)
; dont know how to rdr-to from local system. doesn't seem to work. only works for routed traffic.
/etc/pf.conf
pass in quick on em1 inet proto tcp to port {80,443} rdr-to 127.0.0.1 port 988
pass in quick on em1 inet6 proto tcp to port {80,443} rdr-to ::1 port 988
pfctl -f /etc/pf.conf
/opt/zapret/tpws/tpws --port=988 --user=daemon --bind-addr=::1 --bind-addr=127.0.0.1 --enable-pf
(NEW OpenBSD versions)
; dont know how to divert-to from local system
/etc/pf.conf
pass on em1 inet proto tcp to port {80,443} divert-to 127.0.0.1 port 989
pass on em1 inet6 proto tcp to port {80,443} divert-to ::1 port 989
pfctl -f /etc/pf.conf
/opt/zapret/tpws/tpws --port=988 --user=daemon --bind-addr=::1 --bind-addr=127.0.0.1
; dvtws works both for routed and local
pass in quick on em0 proto tcp from port {80,443} flags SA/SA divert-packet port 989 no state

View File

@@ -513,3 +513,16 @@ nfqws: --filter-ssid (linux-only)
install_easy: stop if running embedded release on traditional linux system (some files missing)
install_bin: add "read elf" arch detection method
binaries: renamed arch dirs in binaries
v71.1.1
nfqws: use wireless ext in case nl80211 does not return SSID
v71.2
nfqws: apply udp desync to replayed packets with non-zero reasm offset (except fake)
blockcheck: display curl version and kernel version
install_bin: stop if no binaries found. display help text.
winws: increase buffers for port filter
tpws: tpws no more opens /dev/pf in OpenBSD by default. requires --enable-pf like in FreeBSD. this is migration from rdr-to to divert-to redirection scheme.
install_easy: warn if --ipset parameter is specified

View File

@@ -1,4 +1,4 @@
# zapret v71.1
# zapret v71.2
# SCAMMER WARNING
@@ -556,9 +556,9 @@ There is special support for all tcp split options for multi segment TLS. Split
### UDP support
UDP attacks are limited. Its not possible to fragment UDP on transport level, only on network (ip) level.
Only desync modes `fake`,`hopbyhop`,`destopt`,`ipfrag1` and `ipfrag2` are applicable.
`fake`,`hopbyhop`,`destopt` can be used in combo with `ipfrag2`.
`fake` can be used in combo with `udplen` and `tamper`.
Only desync modes `fake`,`fakeknown`,`hopbyhop`,`destopt`,`ipfrag1`,`ipfrag2`,`udplen` and `tamper` are applicable.
`fake`,`fakeknown`,`hopbyhop`,`destopt`,`ipfrag1` are 1st phase modes, others - 2nd phase.
As always it's possible to combine one mode from 1st phase with one mode from 2nd phase but not possible to mix same phase modes.
`udplen` increases udp payload size by `--dpi-desync-udplen-increment` bytes. Padding is filled with zeroes by default but can be overriden with a pattern.
This option can resist DPIs that track outgoing UDP packet sizes.
@@ -679,9 +679,11 @@ Instead, `nfqws` has per-profile `--filter-ssid` parameter. Like `--ssid-filter`
`nfqws` maintains ifname->SSID list which is updated not faster than once a second.
When a packet comes incoming or outgoing interface name is matched to the SSID and then used in profile selection algorithm.
SSID info is taken the same way as `iw dev <ifname> info` does.
In practice this command not always returns SSID name for reasons not known yet. If it does not display SSID then `--filter-ssid` will also not work.
Before using it check iw command output.
SSID info is taken the same way as `iw dev <ifname> info` does (nl80211).
Unfortunately it's broken since kernel 5.19 and still unfixed in 6.14.
In the latter case `iwgetid` way is used (wireless extensions).
Wireless extensions are deprecated. Some kernels can be built without wext support.
Before using `--filter-ssid` check that any of the mentioned commands can return SSID.
### Virtual machines

View File

@@ -1,4 +1,4 @@
# zapret v71.1
# zapret v71.2
# ВНИМАНИЕ, остерегайтесь мошенников
@@ -662,8 +662,11 @@ chrome рандомизирует фингерпринт TLS. SNI может о
### ПОДДЕРЖКА UDP
Атаки на udp более ограничены в возможностях. udp нельзя фрагментировать иначе, чем на уровне ip.
Для UDP действуют только режимы десинхронизации `fake`, `hopbyhop`, `destopt`, `ipfrag1`, `ipfrag2`, `udplen`, `tamper`.
Возможно сочетание `fake`, `hopbyhop`, `destopt` с `ipfrag2`, `fake`, `fakeknown` с udplen и tamper.
Для UDP действуют только режимы десинхронизации `fake`, `fakeknown`, `hopbyhop`, `destopt`, `ipfrag1`, `ipfrag2`, `udplen`, `tamper`.
Режимами первой фазы являются `fake`, `fakeknown`, `hopbyhop`, `destopt`, `ipfrag1`. Второй фазы - `ipfrag2`, `udplen`, `tamper`.
Как обычно, возможно сочетание режимов первой и второй фазы, но не двух режимов одной фазы.
`udplen` увеличивает размер udp пакета на указанное в `--dpi-desync-udplen-increment` количество байтов.
Паддинг заполняется нулями по умолчанию, но можно задать свой паттерн.
Предназначено для обмана DPI, ориентирующегося на размеры пакетов.
@@ -794,9 +797,12 @@ L7 протокол становится известен обычно посл
При выборе профиля имеет значение куда идет конкретный обрабатываемый пакет. На какой интерфейс. Или с какого интерфейса пакет пришел, если он считается входящим.
Поэтому даже если у вас часть трафика идет на одну сеть, часть на другую, а часть вообще не идет по wifi, то все это можно настроить.
Информация о подключенных сетях берется способом, используемым командой `iw dev <ifname> info`.
Как показывает опыт, не всегда возвращается SSID. Пока не выяснено с чем это связано.
Перед использованием `--filter-ssid` удостоверьтесь, что iw возвращает имя сети. Иначе работать не будет.
Информация о подключенных сетях берется способом, используемым командой `iw dev <ifname> info` (nl80211).
К сожалению, на ядрах с 5.19 до самых последних (6.14 не работает) этот способ сломан.
В этом случае используется способ iwgetid (wireless extensions).
wireless extensions считаются deprecated и на новых ядрах реализованы как прослойка совместимости.
Некоторые ядра могут быть собраны без wireless extensions.
Перед использованием `--filter-ssid` удостоверьтесь, что любая из этих команд возвращает SSID.
Сканируются все wifi интерфейсы, составляется список interface->SSID. Он обновляется по мере поступления
пакетов, но не чаще 1 раза в секунду.
@@ -1488,7 +1494,7 @@ LISTS_RELOAD=- отключает перезагрузку листов.
`ipset/zapret-hosts-users.txt.gz` или `ipset/zapret-hosts-users.txt`,
`ipset/zapret-hosts.txt.gz` или `ipset/zapret-hosts.txt`
и 1 exclude список
`ipset/zapret-hosts-users-exclude.txt.gz` или `ipset/zapret-hosts-users-exclude.txt`
`ipset/zapret-hosts-user-exclude.txt.gz` или `ipset/zapret-hosts-user-exclude.txt`
При режимах фильтрации `MODE_FILTER=hostlist` или `MODE_FILTER=autohostlist` система запуска передает **nfqws** или **tpws** все листы, файлы которых присутствуют.
Передача происходит через замену маркеров `<HOSTLIST>` и `<HOSTLIST_NOAUTO>` на реальные параметры `--hostlist`, `--hostlist-exclude`, `--hostlist-auto`.

View File

@@ -84,7 +84,7 @@ SubInterface используется windivert, но практически в
autottl и autohostlist. При включении autohostlist так же перенаправляются пакеты данных с http redirect с кодами 302 и 307.
Всегда добавляется фильтр на исключение не-интернет адресов ipv4 и ipv6.
Для сложных нестандартных сценариев могут потребоваться свои фильтры. Логично будет начать со стандартного шаблона,
сохраненного через `--wf-save`. Нужно править файл и подсовывать его в параметре `--wf-raw`. Максимальный размер фильтра - **8 Kb**.
сохраненного через `--wf-save`. Нужно править файл и подсовывать его в параметре `--wf-raw`. Максимальный размер фильтра - **16 Kb**.
Можно запускать несколько процессов **winws** с разными стратегиями. Однако, не следует делать пересекающиеся фильтры.

View File

@@ -127,8 +127,41 @@ ccp()
#cp -f "../$BINS/$1" "$ZAPRET_BASE/$2" && echo copying : "../$BINS/$1" =\> "$ZAPRET_BASE/$2"
}
UNAME=$(uname)
[ "$1" = getarch ] ||
if [ ! -d "$BINDIR" ] || ! dir_is_not_empty "$BINDIR" ]; then
echo "no binaries found"
case $UNAME in
Linux)
echo "you need to download release from github or build binaries from source"
echo "building from source requires debian/ubuntu packages : make gcc zlib1g-dev libcap-dev libnetfilter-queue-dev libmnl-dev libsystemd-dev"
echo "libsystemd-dev required only on systemd based systems"
echo "on distributions with other package manager find dev package analogs"
echo "to compile on systems with systemd : make systemd"
echo "to compile on other systems : make"
;;
Darwin)
echo "you need to download release from github or build binaries from source"
echo "to compile : make mac"
;;
FreeBSD)
echo "you need to download release from github or build binaries from source"
echo "to compile : make"
;;
OpenBSD)
echo "to compile : make bsd"
;;
CYGWIN*)
echo "you need to download release from github or build binaries from source"
echo "to compile : read docs"
echo "to make things easier use zapret-win-bundle"
;;
esac
exit 1
fi
unset PKTWS
case $UNAME in
Linux)

View File

@@ -102,7 +102,7 @@ check_bins()
make_target=systemd
;;
esac
CFLAGS="${cf:+$cf }${CFLAGS}" make -C "$EXEDIR" $make_target || {
CFLAGS="${cf:+$cf }${CFLAGS}" OPTIMIZE=-O2 make -C "$EXEDIR" $make_target || {
echo could not compile
make -C "$EXEDIR" clean
exitp 8

View File

@@ -1,5 +1,6 @@
CC ?= gcc
CFLAGS += -std=gnu99 -Os -flto=auto
CC ?= cc
OPTIMIZE ?= -Os
CFLAGS += -std=gnu99 $(OPTIMIZE) -flto=auto
CFLAGS_BSD = -Wno-address-of-packed-member
CFLAGS_WIN = -static
LIBS =

View File

@@ -1,5 +1,6 @@
CC ?= gcc
CFLAGS += -std=gnu99 -Os
CC ?= cc
OPTIMIZE ?= -Os
CFLAGS += -std=gnu99 $(OPTIMIZE)
CFLAGS_BSD = -Wno-address-of-packed-member
CFLAGS_WIN = -static
LIBS = -lpthread

View File

@@ -1,5 +1,6 @@
CC ?= cc
CFLAGS += -std=gnu99 -s -Os -Wno-address-of-packed-member -flto=auto
OPTIMIZE ?= -Os
CFLAGS += -std=gnu99 -s $(OPTIMIZE) -flto=auto -Wno-address-of-packed-member
LIBS = -lz
SRC_FILES = *.c crypto/*.c

View File

@@ -1,5 +1,6 @@
CC ?= gcc
CFLAGS += -std=gnu99 -Os -flto=auto
CC ?= cc
OPTIMIZE ?= -Os
CFLAGS += -std=gnu99 $(OPTIMIZE) -flto=auto
CFLAGS_SYSTEMD = -DUSE_SYSTEMD
CFLAGS_BSD = -Wno-address-of-packed-member
CFLAGS_CYGWIN = -Wno-address-of-packed-member -static

View File

@@ -34,6 +34,9 @@
#include <linux/genetlink.h>
#include <libmnl/libmnl.h>
#include <net/if.h>
#define _LINUX_IF_H // prevent conflict between linux/if.h and net/if.h in old gcc 4.x
#include <linux/wireless.h>
#include <sys/ioctl.h>
#endif
uint32_t net32_add(uint32_t netorder_value, uint32_t cpuorder_increment)
@@ -1959,8 +1962,28 @@ static int wlan_info_cb(const struct nlmsghdr *nlh, void *data)
if (wc->count>=WLAN_INTERFACE_MAX) return MNL_CB_OK;
memset(wc->wlan+wc->count,0,sizeof(wc->wlan[0]));
ret = mnl_attr_parse(nlh, sizeof(struct genlmsghdr), wlan_info_attr_cb, wc->wlan+wc->count);
if (ret>=0 && *wc->wlan[wc->count].ssid && *wc->wlan[wc->count].ifname && wc->wlan[wc->count].ifindex)
wc->count++;
if (ret>=0 && *wc->wlan[wc->count].ifname && wc->wlan[wc->count].ifindex)
{
if (*wc->wlan[wc->count].ssid)
wc->count++;
else
{
// sometimes nl80211 does not return SSID but wireless ext does
int wext_fd = socket(AF_INET, SOCK_DGRAM, 0);
if (wext_fd!=-1)
{
struct iwreq req;
snprintf(req.ifr_ifrn.ifrn_name,sizeof(req.ifr_ifrn.ifrn_name),"%s",wc->wlan[wc->count].ifname);
req.u.essid.pointer = wc->wlan[wc->count].ssid;
req.u.essid.length = sizeof(wc->wlan[wc->count].ssid);
req.u.essid.flags = 0;
if (ioctl(wext_fd, SIOCGIWESSID, &req)!=-1)
if (*wc->wlan[wc->count].ssid)
wc->count++;
close(wext_fd);
}
}
}
return ret;
}
static bool wlan_info(struct mnl_socket* nl, uint16_t wlan_family_id, struct wlan_interface_collection* w)

View File

@@ -2421,9 +2421,6 @@ static uint8_t dpi_desync_udp_packet_play(bool replay, size_t reasm_offset, uint
DLOG("matching desync profile not found\n");
return verdict;
}
// no need to desync middle packets in reasm session
if (reasm_offset) goto send_orig;
}
else
{
@@ -2839,6 +2836,7 @@ static uint8_t dpi_desync_udp_packet_play(bool replay, size_t reasm_offset, uint
break;
}
case DESYNC_FAKE:
if (!reasm_offset)
{
struct blob_item *fake_item;
int n=0;
@@ -2862,8 +2860,8 @@ static uint8_t dpi_desync_udp_packet_play(bool replay, size_t reasm_offset, uint
goto send_orig;
ip_id=IP4_IP_ID_NEXT(ip_id);
}
bFake = true;
}
bFake = true;
break;
case DESYNC_HOPBYHOP:
case DESYNC_DESTOPT:

View File

@@ -306,6 +306,7 @@ static int nfq_main(void)
if (!nfq_init(&h,&qh))
goto err;
#ifdef HAS_FILTER_SSID
if (params.filter_ssid_present)
{
if (!wlan_info_init())
@@ -315,6 +316,7 @@ static int nfq_main(void)
}
DLOG("wlan info capture initialized\n");
}
#endif
if (params.daemon) daemonize();
@@ -340,9 +342,11 @@ static int nfq_main(void)
while ((rd = recv(fd, buf, sizeof(buf), 0)) >= 0)
{
ReloadCheck();
#ifdef HAS_FILTER_SSID
if (params.filter_ssid_present)
if (!wlan_info_get_rate_limited())
DLOG_ERR("cannot get wlan info\n");
#endif
if (rd)
{
int r = nfq_handle_packet(h, (char *)buf, (int)rd);
@@ -359,12 +363,16 @@ static int nfq_main(void)
} while(e==ENOBUFS);
nfq_deinit(&h,&qh);
#ifdef HAS_FILTER_SSID
wlan_info_deinit();
#endif
return 0;
err:
if (Fpid) fclose(Fpid);
nfq_deinit(&h,&qh);
#ifdef HAS_FILTER_SSID
wlan_info_deinit();
#endif
return 1;
}
@@ -1441,7 +1449,7 @@ static bool wf_make_filter(
const char *pf_tcp_src, const char *pf_tcp_dst,
const char *pf_udp_src, const char *pf_udp_dst)
{
char pf_dst_buf[512],iface[64];
char pf_dst_buf[8192],iface[64];
const char *pf_dst;
const char *f_tcpin = *pf_tcp_src ? dp_list_have_autohostlist(&params.desync_profiles) ? "(" DIVERT_TCP_INBOUNDS " or (" DIVERT_HTTP_REDIRECT "))" : DIVERT_TCP_INBOUNDS : "";
const char *f_tcp_not_empty = (*pf_tcp_src && !dp_list_need_all_out(&params.desync_profiles)) ? DIVERT_TCP_NOT_EMPTY " and " : "";
@@ -1979,7 +1987,7 @@ int main(int argc, char **argv)
struct hostlist_file *anon_hl = NULL, *anon_hl_exclude = NULL;
struct ipset_file *anon_ips = NULL, *anon_ips_exclude = NULL;
#ifdef __CYGWIN__
char windivert_filter[8192], wf_pf_tcp_src[256], wf_pf_tcp_dst[256], wf_pf_udp_src[256], wf_pf_udp_dst[256], wf_save_file[256];
char windivert_filter[16384], wf_pf_tcp_src[4096], wf_pf_tcp_dst[4096], wf_pf_udp_src[4096], wf_pf_udp_dst[4096], wf_save_file[256];
bool wf_ipv4=true, wf_ipv6=true;
unsigned int IfIdx=0, SubIfIdx=0;
unsigned int hash_wf_tcp=0,hash_wf_udp=0,hash_wf_raw=0,hash_ssid_filter=0,hash_nlm_filter=0;

View File

@@ -1,5 +1,6 @@
CC ?= cc
CFLAGS += -std=gnu99 -s -Os -flto=auto
OPTIMIZE ?= -Os
CFLAGS += -std=gnu99 -s $(OPTIMIZE) -flto=auto
LIBS = -lz -lpthread
SRC_FILES = *.c

View File

@@ -1,5 +1,6 @@
CC ?= gcc
CFLAGS += -std=gnu99 -Os -flto=auto
CC ?= cc
OPTIMIZE ?= -Os
CFLAGS += -std=gnu99 $(OPTIMIZE) -flto=auto
CFLAGS_SYSTEMD = -DUSE_SYSTEMD
CFLAGS_BSD = -Wno-address-of-packed-member
LDFLAGS_ANDROID = -llog

View File

@@ -216,7 +216,7 @@ static void exithelp(void)
" --pidfile=<filename>\t\t\t; write pid to file\n"
" --user=<username>\t\t\t; drop root privs\n"
" --uid=uid[:gid1,gid2,...]\t\t; drop root privs\n"
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__OpenBSD__)
" --enable-pf\t\t\t\t; enable PF redirector support. required in FreeBSD when used with PF firewall.\n"
#endif
#if defined(__linux__)
@@ -711,7 +711,7 @@ enum opt_indices {
IDX_IPSET_EXCLUDE,
IDX_IPSET_EXCLUDE_IP,
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__OpenBSD__)
IDX_ENABLE_PF,
#elif defined(__APPLE__)
IDX_LOCAL_TCP_USER_TIMEOUT,
@@ -804,7 +804,7 @@ static const struct option long_options[] = {
[IDX_IPSET_EXCLUDE] = {"ipset-exclude", required_argument, 0, 0},
[IDX_IPSET_EXCLUDE_IP] = {"ipset-exclude-ip", required_argument, 0, 0},
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__OpenBSD__)
[IDX_ENABLE_PF] = {"enable-pf", no_argument, 0, 0},
#elif defined(__APPLE__)
[IDX_LOCAL_TCP_USER_TIMEOUT] = {"local-tcp-user-timeout", required_argument, 0, 0},
@@ -840,7 +840,7 @@ void parse_params(int argc, char *argv[])
params.tcp_user_timeout_remote = DEFAULT_TCP_USER_TIMEOUT_REMOTE;
#endif
#if defined(__OpenBSD__) || defined(__APPLE__)
#if defined(__APPLE__)
params.pf_enable = true; // OpenBSD and MacOS have no other choice
#endif
@@ -1554,7 +1554,7 @@ void parse_params(int argc, char *argv[])
params.tamper = true;
break;
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__OpenBSD__)
case IDX_ENABLE_PF:
params.pf_enable = true;
break;