zapret2-fork/nfq2/winnative
Repository files (latest commit first)
Filename Latest commit message Latest commit date
loop-uh dc41b27493
Some checks failed
build.yml / winws2 native: send the held batch before the receive loop exits (push) Failing after 0s
winws2 native: send the held batch before the receive loop exits
Unmodified packets were held until the next receive. On quit and when the
logical network disappears upstream leaves windivert_recv() before receiving,
so the last run (up to 128 packets) never reached the network. Stress on win10:
20 of 20 stops lost a full run, 2548 packets in total; 0 after the fix.

usleep(0), which starts windivert_recv_exit(), now sends the run and polls the
control events, as cygwin delivered signals there. This also makes the term
event work while the engine waits for a logical network (it used to hang).
WinDivertClose forgets the run of the handle without reading the packets.
tests/check_upstream.py fails the sync if upstream drops that usleep call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 21:16:34 +03:00
..
include winws2 native: windows control events, persistent log handle, unlimited config file, host tests 2026-10-07 17:22:13 +03:00
tests winws2 native: send the held batch before the receive loop exits 2026-10-12 21:16:34 +03:00
args.c winws2 native: windows control events, persistent log handle, unlimited config file, host tests 2026-10-07 17:22:13 +03:00
args.h winws2 native: windows control events, persistent log handle, unlimited config file, host tests 2026-10-07 17:22:13 +03:00
batch.c winws2 native: send the held batch before the receive loop exits 2026-10-12 21:16:34 +03:00
build.sh winws2 native: build the old engine winws.exe (zapret1) by the same layer 2026-10-07 17:40:13 +03:00
compat.c winws2 native: build the old engine winws.exe (zapret1) by the same layer 2026-10-07 17:40:13 +03:00
compat.h winws2 native: send the held batch before the receive loop exits 2026-10-12 21:16:34 +03:00
luajit_compat.h winws2: native windows build without cygwin1.dll 2026-10-07 16:26:52 +03:00
README.md winws2 native: send the held batch before the receive loop exits 2026-10-12 21:16:34 +03:00
sync-upstream.sh sync-upstream: exit codes tell why nothing was synced; retry a push left from the previous run 2026-10-09 23:01:12 +03:00

winws2 без Cygwin

Это форк bol-van/zapret2. Отличие одно: winws2.exe собирается как обычная программа Windows и не требует cygwin1.dll. Файлы автора почти не тронуты, всё своё лежит в этой папке, поэтому правки оригинала подтягиваются автоматически.

Что добавлено

  • Сборка под Windows компилятором llvm-mingw прямо на Linux: nfq2/winnative/build.sh. Результат — binaries/my/winnative-x86_64/winws2.exe, рядом нужны только WinDivert.dll и драйвер.
  • Пакетная отправка. Пакеты, которые движок не менял, возвращаются в сеть пачкой одним вызовом. Отключается переменной окружения WINWS2_NO_BATCH=1.
  • Управление без сигналов Linux: winws2 --wn-signal=<hup|usr1|usr2|term>[:<pid>]. hup перечитывает списки, usr1 и usr2 печатают служебные таблицы, term аккуратно останавливает движок. Без номера процесса команда уходит всем запущенным winws2.
  • Файл конфигурации любого размера. @файл и $файл читаются целиком; путь может содержать пробелы и русские буквы.
  • Быстрый журнал отладки: файл журнала открывается один раз, а не на каждую строку.

Как устроено

  • compat.h подключается к каждому файлу автора и изображает для него окружение Cygwin.
  • compat.c заменяет функции Cygwin: файлы с путями в UTF-8, преобразование путей, сигналы.
  • args.c разбирает командную строку и @файл по тем же правилам, что Cygwin. Отличие: фигурные скобки без кавычек не раскрываются.
  • batch.c — пакетная отправка. Пачка уходит в сеть при следующем приёме, при любой другой отправке и в usleep: с него автор начинает выход из приёма, поэтому при остановке и пропаже сети пакеты не теряются. Там же usleep принимает команды управления, так что term работает и пока движок ждёт сеть (--ssid-filter, --nlm-filter).
  • tests/run.sh — проверки разбора аргументов и tests/check_upstream.py: на что в коде автора опирается эта папка. Запускаются на Linux.
  • tests/stop_race.py — серия «запуск — остановка» на Windows: ловит запись опоздавшего пакета в освобождённый буфер при остановке.
  • sync-upstream.sh — подтянуть оригинал, собрать, проверить, отправить.

Сборка

# один раз: распаковать llvm-mingw (вариант msvcrt) в ~/tools/llvm-mingw
nfq2/winnative/build.sh
nfq2/winnative/tests/run.sh

LuaJIT и zlib скрипт скачивает и собирает сам.