mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-06 11:36:50 +03:00
Compare commits
93 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3040ce7286 | ||
|
|
e025271a14 | ||
|
|
2b8208186d | ||
|
|
17fb11baf0 | ||
|
|
3c1b041b52 | ||
|
|
38acac1a31 | ||
|
|
2939229df3 | ||
|
|
26c3d0bc7e | ||
|
|
b364363b1b | ||
|
|
d85caf0c0c | ||
|
|
65f72e1e04 | ||
|
|
e59ef6dd6f | ||
|
|
05272de650 | ||
|
|
48716e7156 | ||
|
|
f29b97e495 | ||
|
|
41c21cebcd | ||
|
|
238e99a547 | ||
|
|
4f44fcfe99 | ||
|
|
9fd2fb9b6e | ||
|
|
c0591b25b9 | ||
|
|
97fd392334 | ||
|
|
848c784cc0 | ||
|
|
ab971dcd36 | ||
|
|
b8d96f28cd | ||
|
|
f2268fd494 | ||
|
|
19897afcdd | ||
|
|
0e2ea60f01 | ||
|
|
2dc5944961 | ||
|
|
f65de36804 | ||
|
|
19541f8bb3 | ||
|
|
aa42c707fe | ||
|
|
bf96f93987 | ||
|
|
ff9aad8947 | ||
|
|
d9718617bd | ||
|
|
e865c9f324 | ||
|
|
7df8bb5826 | ||
|
|
f960358eb6 | ||
|
|
ba44966c02 | ||
|
|
615241aa37 | ||
|
|
9a3220d226 | ||
|
|
ec8d28857e | ||
|
|
26b49f5bbb | ||
|
|
0a7efb3169 | ||
|
|
468e51ee8e | ||
|
|
3b93a914de | ||
|
|
76c5baf1e2 | ||
|
|
c752c46abf | ||
|
|
1df1defa5e | ||
|
|
3cb4be6427 | ||
|
|
25bfdce5ce | ||
|
|
6d0f097a07 | ||
|
|
5f780955eb | ||
|
|
389def9056 | ||
|
|
e816da5133 | ||
|
|
e57adbe042 | ||
|
|
d78c51360d | ||
|
|
c2357337fc | ||
|
|
bc6490b56e | ||
|
|
2f645d9151 | ||
|
|
94cc65001b | ||
|
|
87caa70e97 | ||
|
|
90d7c60fcb | ||
|
|
3f114b4710 | ||
|
|
b821abe82c | ||
|
|
732cab2ef3 | ||
|
|
3b4ce9e7a3 | ||
|
|
69c4445c85 | ||
|
|
dcebc3d67d | ||
|
|
1be31eaf59 | ||
|
|
023210e0f0 | ||
|
|
5ff832533e | ||
|
|
5d2163515e | ||
|
|
5865706d0c | ||
|
|
aabe1c53dc | ||
|
|
8e91b582ad | ||
|
|
62ce1f5acc | ||
|
|
93727ddeb5 | ||
|
|
98797d93b1 | ||
|
|
66c6e998a2 | ||
|
|
3d9f82b571 | ||
|
|
38d082e236 | ||
|
|
9f5abcae6d | ||
|
|
7836d2c6ec | ||
|
|
f46c934c59 | ||
|
|
23ed10d393 | ||
|
|
26488baad3 | ||
|
|
c79016e456 | ||
|
|
884bbfee42 | ||
|
|
1263b9b1b8 | ||
|
|
23203fd7a1 | ||
|
|
25c887a952 | ||
|
|
e7a3c7adf1 | ||
|
|
3e96b9a1af |
16
.github/workflows/build.yml
vendored
16
.github/workflows/build.yml
vendored
@@ -11,6 +11,22 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.1
|
||||
|
||||
- name: Check version match
|
||||
run: |
|
||||
PODKOP_VERSION=$(grep '^PKG_VERSION:=' podkop/Makefile | cut -d '=' -f 2)
|
||||
LUCI_APP_PODKOP_VERSION=$(grep '^PKG_VERSION:=' luci-app-podkop/Makefile | cut -d '=' -f 2)
|
||||
|
||||
TAG_VERSION=${GITHUB_REF#refs/tags/v}
|
||||
|
||||
echo "Podkop version: $PODKOP_VERSION"
|
||||
echo "Luci-app-podkop version: $LUCI_APP_PODKOP_VERSION"
|
||||
echo "Tag version: $TAG_VERSION"
|
||||
|
||||
if [ "$PODKOP_VERSION" != "$TAG_VERSION" ] || [ "$LUCI_APP_PODKOP_VERSION" != "$TAG_VERSION" ]; then
|
||||
echo "Error: Version mismatch"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6.9.0
|
||||
with:
|
||||
|
||||
42
README.md
42
README.md
@@ -39,9 +39,9 @@ sh <(wget -O - https://raw.githubusercontent.com/itdoginfo/podkop/refs/heads/mai
|
||||
Скачать пакеты `podkop_*.ipk` и `luci-app-podkop_*.ipk` из релиза. `opkg install` сначала первый, потом второй.
|
||||
|
||||
# Обновление
|
||||
Та же самая команда, что для установки. Скрипт обнаружит уже установленный podkop и предложит обновиться.
|
||||
Та же самая команда, что для установки. Но с флагом **upgrade** сразу передёт к обновлению.
|
||||
```
|
||||
sh <(wget -O - https://raw.githubusercontent.com/itdoginfo/podkop/refs/heads/main/install.sh)
|
||||
sh <(wget -qO- https://raw.githubusercontent.com/itdoginfo/podkop/refs/heads/main/install.sh) --upgrade
|
||||
```
|
||||
|
||||
# Удаление
|
||||
@@ -73,19 +73,10 @@ Luci: Services/podkop
|
||||
|
||||
**Custom subnets enable** - Добавить подсети или IP-адреса. Для подсетей задать маску.
|
||||
|
||||
# Известные баги
|
||||
- [x] Не отрабатывает service podkop stop, если podkop запущен и не может, к пример, зарезолвить домен с сломанным DNS
|
||||
- [x] Update list из remote url domain не удаляет старые домены. А добавляет новые. Для подсетей тоже самое скорее всего. Пересоздавать ruleset?
|
||||
|
||||
# ToDo
|
||||
Этот раздел не означает задачи, которые нужно брать и делать. Это общий список хотелок. Если вы хотите помочь, пожалуйста, спросите сначала в телеграмме.
|
||||
|
||||
- [ ] Проверка, что версия в makefile совпадает с тегом
|
||||
- [ ] Сделать галку запрещающую подкопу редачить dhcp. Допилить в исключение вместе с пустыми полями proxy и vpn
|
||||
- [x] Обработка ошибки `sing-box[9345]: FATAL[0000] start service: initialize DNS rule[2]: rule-set not found: main`. Когда не задана строка\интерфейс
|
||||
- [x] Проверка `/etc/resolv.conf` на наличие DNS-серверов
|
||||
- [x] Отслеживание интерфейса wan в sing-box
|
||||
- [ ] Рестарт сервиса без рестарта dnsmasq
|
||||
Основные задачи в issues.
|
||||
|
||||
Низкий приоритет
|
||||
- [ ] Галочка, которая режет доступ к doh серверам
|
||||
@@ -97,6 +88,33 @@ Luci: Services/podkop
|
||||
- [ ] Unit тесты (BATS)
|
||||
- [ ] Интеграционые тесты бекенда (OpenWrt rootfs + BATS)
|
||||
|
||||
# Don't touch my dhcp
|
||||
Нужно в первую очередь, чтоб использовать опцию `server`.
|
||||
|
||||
В случае если опция активна, podkop не трогает /etc/config/dhcp. И вам требуется самостоятельно указать следующие значения:
|
||||
```
|
||||
option noresolv '1'
|
||||
option cachesize '0'
|
||||
list server '127.0.0.42'
|
||||
```
|
||||
Без этого podkop работать не будет.
|
||||
|
||||
Если нужно до определённых доменов ходить через определённый DNS-сервер, то конфиг выглядит так
|
||||
```
|
||||
option noresolv '1'
|
||||
option cachesize '0'
|
||||
list server '/itdog.info/1.1.1.1'
|
||||
list server '127.0.0.42'
|
||||
```
|
||||
|
||||
В этом случае домен и все субдомены ресурса itdog.info будут резолвится через DNS-сервер 1.1.1.1
|
||||
|
||||
# Bad WAN
|
||||
При использовании опции **Interface monitoring** необходимо рестартовать podkop, чтоб init.d подхватил это
|
||||
```
|
||||
service podkop restart
|
||||
```
|
||||
|
||||
# Разработка
|
||||
Есть два варианта:
|
||||
- Просто поставить пакет на роутер или виртуалку и прям редактировать через SFTP (opkg install openssh-sftp-server)
|
||||
|
||||
87
install.sh
87
install.sh
@@ -5,10 +5,17 @@ REPO="https://api.github.com/repos/itdoginfo/podkop/releases/latest"
|
||||
IS_SHOULD_RESTART_NETWORK=
|
||||
DOWNLOAD_DIR="/tmp/podkop"
|
||||
COUNT=3
|
||||
UPGRADE=0
|
||||
|
||||
rm -rf "$DOWNLOAD_DIR"
|
||||
mkdir -p "$DOWNLOAD_DIR"
|
||||
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "--upgrade" ]; then
|
||||
UPGRADE=1
|
||||
fi
|
||||
done
|
||||
|
||||
main() {
|
||||
check_system
|
||||
sing_box
|
||||
@@ -16,32 +23,47 @@ main() {
|
||||
opkg update
|
||||
|
||||
if [ -f "/etc/init.d/podkop" ]; then
|
||||
printf "\033[32;1mPodkop is already installed. Just upgrade it? (y/n)\033[0m\n"
|
||||
printf "\033[32;1my - Only upgrade podkop\033[0m\n"
|
||||
printf "\033[32;1mn - Upgrade and install tunnels (WG, AWG, OpenVPN, OC)\033[0m\n"
|
||||
if [ "$UPGRADE" -eq 1 ]; then
|
||||
echo "Upgraded podkop with flag..."
|
||||
break
|
||||
else
|
||||
printf "\033[32;1mPodkop is already installed. Just upgrade it?\033[0m\n"
|
||||
printf "\033[32;1my - Only upgrade podkop\033[0m\n"
|
||||
printf "\033[32;1mn - Upgrade and install tunnels (WG, AWG, OpenVPN, OC)\033[0m\n"
|
||||
|
||||
while true; do
|
||||
read -r -p '' UPDATE
|
||||
case $UPDATE in
|
||||
y)
|
||||
echo "Upgraded podkop..."
|
||||
break
|
||||
;;
|
||||
while true; do
|
||||
printf "\033[32;1mEnter (y/n): \033[0m"
|
||||
read -r -p '' UPDATE
|
||||
case $UPDATE in
|
||||
y)
|
||||
echo "Upgraded podkop..."
|
||||
break
|
||||
;;
|
||||
|
||||
n)
|
||||
add_tunnel
|
||||
break
|
||||
;;
|
||||
n)
|
||||
add_tunnel
|
||||
break
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Please enter y or n"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
*)
|
||||
echo "Please enter y or n"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo "Installed podkop..."
|
||||
add_tunnel
|
||||
fi
|
||||
|
||||
if command -v curl &> /dev/null; then
|
||||
check_response=$(curl -s "https://api.github.com/repos/itdoginfo/podkop/releases/latest")
|
||||
|
||||
if echo "$check_response" | grep -q 'API rate limit '; then
|
||||
echo "You've reached rate limit from GitHub. Repeat in five minutes."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
download_success=0
|
||||
while read -r url; do
|
||||
@@ -151,13 +173,13 @@ add_tunnel() {
|
||||
;;
|
||||
|
||||
3)
|
||||
opkg install opkg install openvpn-openssl luci-app-openvpn
|
||||
opkg install openvpn-openssl luci-app-openvpn
|
||||
printf "\e[1;32mUse these instructions to configure https://itdog.info/nastrojka-klienta-openvpn-na-openwrt/\e[0m\n"
|
||||
break
|
||||
;;
|
||||
|
||||
4)
|
||||
opkg install opkg install openconnect luci-proto-openconnect
|
||||
opkg install openconnect luci-proto-openconnect
|
||||
printf "\e[1;32mUse these instructions to configure https://itdog.info/nastrojka-klienta-openconnect-na-openwrt/\e[0m\n"
|
||||
break
|
||||
;;
|
||||
@@ -239,8 +261,8 @@ install_awg_packages() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if opkg list-installed | grep -q luci-app-amneziawg; then
|
||||
echo "luci-app-amneziawg already installed"
|
||||
if opkg list-installed | grep -qE 'luci-app-amneziawg|luci-proto-amneziawg'; then
|
||||
echo "luci-app-amneziawg or luci-proto-amneziawg already installed"
|
||||
else
|
||||
LUCI_APP_AMNEZIAWG_FILENAME="luci-app-amneziawg${PKGPOSTFIX}"
|
||||
DOWNLOAD_URL="${BASE_URL}v${VERSION}/${LUCI_APP_AMNEZIAWG_FILENAME}"
|
||||
@@ -416,6 +438,25 @@ check_system() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if opkg list-installed | grep -q https-dns-proxy; then
|
||||
printf "\033[31;1mСonflicting package detected: https-dns-proxy. Remove? yes/no\033[0m\n"
|
||||
|
||||
while true; do
|
||||
read -r -p '' DNSPROXY
|
||||
case $DNSPROXY in
|
||||
|
||||
yes|y|Y|yes)
|
||||
opkg remove --force-depends luci-app-https-dns-proxy https-dns-proxy luci-i18n-https-dns-proxy*
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Exit"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if opkg list-installed | grep -qE "iptables|kmod-iptab"; then
|
||||
printf "\033[31;1mFound incompatible iptables packages. If you're using FriendlyWrt: https://t.me/itdogchat/44512/181082\033[0m\n"
|
||||
fi
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-podkop
|
||||
PKG_VERSION:=0.3.26
|
||||
PKG_VERSION:=0.3.43
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LUCI_TITLE:=LuCI podkop app
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -40,8 +40,8 @@ msgstr "Конфигурация Outbound"
|
||||
msgid "Proxy Configuration URL"
|
||||
msgstr "URL конфигурации прокси"
|
||||
|
||||
msgid "Enter connection string starting with vless:// or ss:// for proxy configuration"
|
||||
msgstr "Введите строку подключения, начинающуюся с vless:// или ss:// для настройки прокси"
|
||||
msgid "Enter connection string starting with vless:// or ss:// for proxy configuration. Add comments with // for saving other configs"
|
||||
msgstr "Введите строку подключения, начинающуюся с vless:// или ss:// для настройки прокси. Добавляйте комментарии с // для сохранения других конфигураций"
|
||||
|
||||
msgid "Outbound Configuration"
|
||||
msgstr "Конфигурация исходящего соединения"
|
||||
@@ -88,8 +88,8 @@ msgstr "Введите имена доменов без протоколов (п
|
||||
msgid "User Domains List"
|
||||
msgstr "Список пользовательских доменов"
|
||||
|
||||
msgid "Enter domain names separated by comma, space or newline (example: sub.example.com, example.com or one domain per line)"
|
||||
msgstr "Введите имена доменов через запятую, пробел или новую строку (пример: sub.example.com, example.com или один домен на строку)"
|
||||
msgid "Enter domain names separated by comma, space or newline. You can add comments after //"
|
||||
msgstr "Введите имена доменов, разделяя их запятой, пробелом или с новой строки. Вы можете добавлять комментарии после //"
|
||||
|
||||
msgid "Local Domain Lists"
|
||||
msgstr "Локальные списки доменов"
|
||||
@@ -556,6 +556,9 @@ msgstr "Путь должен содержать хотя бы одну дире
|
||||
msgid "Invalid path format. Must be like /tmp/cache.db"
|
||||
msgstr "Неверный формат пути. Пример: /tmp/cache.db"
|
||||
|
||||
msgid "Select the network interface from which the traffic will originate"
|
||||
msgstr "Выберите сетевой интерфейс, с которого будет исходить трафик"
|
||||
|
||||
msgid "Copy to Clipboard"
|
||||
msgstr "Копировать в буфер обмена"
|
||||
|
||||
@@ -746,4 +749,97 @@ msgid "not works in browser"
|
||||
msgstr "не работает в браузере"
|
||||
|
||||
msgid "not works on router"
|
||||
msgstr "не работает на роутере"
|
||||
msgstr "не работает на роутере"
|
||||
|
||||
msgid "Diagnostics"
|
||||
msgstr "Диагностика"
|
||||
|
||||
msgid "DNS Status"
|
||||
msgstr "Статус DNS"
|
||||
|
||||
msgid "Bypass Status"
|
||||
msgstr "Статус обхода"
|
||||
|
||||
msgid "proxy working correctly"
|
||||
msgstr "прокси работает корректно"
|
||||
|
||||
msgid "vpn working correctly"
|
||||
msgstr "vpn работает корректно"
|
||||
|
||||
msgid "proxy not working"
|
||||
msgstr "прокси не работает"
|
||||
|
||||
msgid "vpn not working"
|
||||
msgstr "vpn не работает"
|
||||
|
||||
msgid "proxy not running"
|
||||
msgstr "прокси не запущен"
|
||||
|
||||
msgid "vpn not running"
|
||||
msgstr "vpn не запущен"
|
||||
|
||||
msgid "proxy routing incorrect"
|
||||
msgstr "маршрутизация прокси некорректна"
|
||||
|
||||
msgid "vpn routing incorrect"
|
||||
msgstr "маршрутизация vpn некорректна"
|
||||
|
||||
msgid "First endpoint check failed"
|
||||
msgstr "Проверка первой конечной точки не удалась"
|
||||
|
||||
msgid "IP comparison failed"
|
||||
msgstr "Сравнение IP-адресов не удалось"
|
||||
|
||||
msgid "Bypass check error"
|
||||
msgstr "Ошибка проверки обхода"
|
||||
|
||||
msgid "Main config"
|
||||
msgstr "Основная конфигурация"
|
||||
|
||||
msgid "Config without description"
|
||||
msgstr "Конфигурация без описания"
|
||||
|
||||
msgid "DNS working"
|
||||
msgstr "DNS работает"
|
||||
|
||||
msgid "Router DNS working"
|
||||
msgstr "DNS роутера работает"
|
||||
|
||||
msgid "Router DNS not working"
|
||||
msgstr "DNS роутера не работает"
|
||||
|
||||
msgid "DNS check error"
|
||||
msgstr "Ошибка проверки DNS"
|
||||
|
||||
msgid "available"
|
||||
msgstr "доступен"
|
||||
|
||||
msgid "unavailable"
|
||||
msgstr "недоступен"
|
||||
|
||||
msgid "Apply for SS2022"
|
||||
msgstr "Применить для SS2022"
|
||||
|
||||
msgid "PODKOP CONFIGURATION"
|
||||
msgstr "КОНФИГУРАЦИЯ PODKOP"
|
||||
|
||||
msgid "FAKEIP ROUTER TEST"
|
||||
msgstr "ПРОВЕРКА FAKEIP НА РОУТЕРЕ"
|
||||
|
||||
msgid "FAKEIP BROWSER TEST"
|
||||
msgstr "ПРОВЕРКА FAKEIP В БРАУЗЕРЕ"
|
||||
|
||||
msgid "FakeIP is working correctly on router (198.18.x.x)"
|
||||
msgstr "FakeIP работает корректно на роутере (198.18.x.x)"
|
||||
|
||||
msgid "Click here for all the info"
|
||||
msgstr "Нажмите для просмотра всей информации"
|
||||
|
||||
msgid "Check DNS server on current device (PC, phone)"
|
||||
msgstr "Проверьте DNS сервер на текущем устройстве (ПК, телефон)"
|
||||
|
||||
msgid "Its must be router!"
|
||||
msgstr "Это должен быть роутер!"
|
||||
|
||||
msgid "Global check"
|
||||
msgstr "Глобальная проверка"
|
||||
@@ -1100,4 +1100,97 @@ msgid "not works in browser"
|
||||
msgstr ""
|
||||
|
||||
msgid "not works on router"
|
||||
msgstr ""
|
||||
|
||||
msgid "Diagnostics"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNS Status"
|
||||
msgstr ""
|
||||
|
||||
msgid "Bypass Status"
|
||||
msgstr ""
|
||||
|
||||
msgid "proxy working correctly"
|
||||
msgstr ""
|
||||
|
||||
msgid "vpn working correctly"
|
||||
msgstr ""
|
||||
|
||||
msgid "proxy not working"
|
||||
msgstr ""
|
||||
|
||||
msgid "vpn not working"
|
||||
msgstr ""
|
||||
|
||||
msgid "proxy not running"
|
||||
msgstr ""
|
||||
|
||||
msgid "vpn not running"
|
||||
msgstr ""
|
||||
|
||||
msgid "proxy routing incorrect"
|
||||
msgstr ""
|
||||
|
||||
msgid "vpn routing incorrect"
|
||||
msgstr ""
|
||||
|
||||
msgid "First endpoint check failed"
|
||||
msgstr ""
|
||||
|
||||
msgid "IP comparison failed"
|
||||
msgstr ""
|
||||
|
||||
msgid "Bypass check error"
|
||||
msgstr ""
|
||||
|
||||
msgid "Main config"
|
||||
msgstr ""
|
||||
|
||||
msgid "Enter connection string starting with vless:// or ss:// for proxy configuration. Add comments with // for backup configs"
|
||||
msgstr ""
|
||||
|
||||
msgid "Config without description"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNS working"
|
||||
msgstr ""
|
||||
|
||||
msgid "Router DNS working"
|
||||
msgstr ""
|
||||
|
||||
msgid "Router DNS not working"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNS check error"
|
||||
msgstr ""
|
||||
|
||||
msgid "available"
|
||||
msgstr ""
|
||||
|
||||
msgid "unavailable"
|
||||
msgstr ""
|
||||
|
||||
msgid "PODKOP CONFIGURATION"
|
||||
msgstr ""
|
||||
|
||||
msgid "FAKEIP ROUTER TEST"
|
||||
msgstr ""
|
||||
|
||||
msgid "FAKEIP BROWSER TEST"
|
||||
msgstr ""
|
||||
|
||||
msgid "FakeIP is working correctly on router (198.18.x.x)"
|
||||
msgstr ""
|
||||
|
||||
msgid "Click here for all the info"
|
||||
msgstr ""
|
||||
|
||||
msgid "Check DNS server on current device (PC, phone)"
|
||||
msgstr ""
|
||||
|
||||
msgid "Its must be router!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Global check"
|
||||
msgstr ""
|
||||
@@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=podkop
|
||||
PKG_VERSION:=0.3.26
|
||||
PKG_VERSION:=0.3.43
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=ITDog <podkop@itdog.info>
|
||||
@@ -13,6 +13,7 @@ define Package/podkop
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+sing-box +curl +jq +kmod-nft-tproxy +coreutils-base64
|
||||
CONFLICTS:=https-dns-proxy
|
||||
TITLE:=Domain routing app
|
||||
URL:=https://itdog.info
|
||||
PKGARCH:=all
|
||||
|
||||
@@ -34,4 +34,8 @@ config main 'main'
|
||||
option dns_type 'doh'
|
||||
option dns_server '8.8.8.8'
|
||||
option dns_rewrite_ttl '60'
|
||||
option cache_file '/tmp/cache.db'
|
||||
option cache_file '/tmp/cache.db'
|
||||
list iface 'br-lan'
|
||||
option mon_restart_ifaces '0'
|
||||
#list restart_ifaces 'wan'
|
||||
option ss_uot '0'
|
||||
@@ -6,38 +6,16 @@ USE_PROCD=1
|
||||
script=$(readlink "$initscript")
|
||||
NAME="$(basename ${script:-$initscript})"
|
||||
config_load "$NAME"
|
||||
resolv_conf="/etc/resolv.conf"
|
||||
|
||||
start_service() {
|
||||
echo "Start podkop"
|
||||
|
||||
sing_box_version=$(sing-box version | head -n 1 | awk '{print $3}')
|
||||
required_version="1.11.1"
|
||||
config_get mon_restart_ifaces "main" "mon_restart_ifaces"
|
||||
config_get restart_ifaces "main" "restart_ifaces"
|
||||
|
||||
if [ "$(echo -e "$sing_box_version\n$required_version" | sort -V | head -n 1)" != "$required_version" ]; then
|
||||
echo "The version of sing-box ($sing_box_version) is lower than the minimum version. Update sing-box: opkg update && opkg remove sing-box && opkg install sing-box"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep -q FriendlyWrt /etc/banner; then
|
||||
printf "\033[31;1mYou use FriendlyWrt. If you have problems, check out: https://t.me/itdogchat/44512/181082\033[0m\n"
|
||||
fi
|
||||
|
||||
if grep -qE 'doh_backup_noresolv|doh_backup_server|doh_server' /etc/config/dhcp; then
|
||||
printf "\033[31;1mDetected https-dns-proxy. Disable or uninstall it for correct functionality.\033[0m\n"
|
||||
fi
|
||||
|
||||
if ! ip addr | grep -q "br-lan"; then
|
||||
echo "Interface br-lan not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "search lan" "$resolv_conf" || ! grep -q "nameserver 127.0.0.1" "$resolv_conf"; then
|
||||
echo "/etc/resolv.conf does not contain 'search lan' or 'nameserver 127.0.0.1' entries"
|
||||
fi
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command /bin/sh -c "/usr/bin/podkop start"
|
||||
procd_set_param command /usr/bin/podkop start
|
||||
[ "$mon_restart_ifaces" = "1" ] && [ -n "$restart_ifaces" ] && procd_set_param netdev $restart_ifaces
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
@@ -47,17 +25,23 @@ stop_service() {
|
||||
/usr/bin/podkop stop
|
||||
}
|
||||
|
||||
restart_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
/usr/bin/podkop reload > /dev/null 2>&1
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
echo "service_triggers start"
|
||||
procd_add_config_trigger "config.change" "$NAME" "$initscript" reload 'on_config_change'
|
||||
|
||||
config_get mon_restart_ifaces "main" "mon_restart_ifaces"
|
||||
config_get restart_ifaces "main" "restart_ifaces"
|
||||
|
||||
procd_open_trigger
|
||||
procd_add_config_trigger "config.change" "$NAME" "$initscript" restart 'on_config_change'
|
||||
|
||||
if [ "$mon_restart_ifaces" = "1" ]; then
|
||||
for iface in $restart_ifaces; do
|
||||
procd_add_reload_interface_trigger $iface
|
||||
done
|
||||
fi
|
||||
procd_close_trigger
|
||||
}
|
||||
@@ -15,11 +15,16 @@ SUBNETS_TWITTER="${GITHUB_RAW_URL}/Subnets/IPv4/twitter.lst"
|
||||
SUBNETS_META="${GITHUB_RAW_URL}/Subnets/IPv4/meta.lst"
|
||||
SUBNETS_DISCORD="${GITHUB_RAW_URL}/Subnets/IPv4/discord.lst"
|
||||
SUBNETS_TELERAM="${GITHUB_RAW_URL}/Subnets/IPv4/telegram.lst"
|
||||
SUBNETS_CLOUDFLARE="${GITHUB_RAW_URL}/Subnets/IPv4/cloudflare.lst"
|
||||
SING_BOX_CONFIG="/etc/sing-box/config.json"
|
||||
FAKEIP="198.18.0.0/15"
|
||||
VALID_SERVICES="russia_inside russia_outside ukraine_inside geoblock block porn news anime youtube discord meta twitter hdrezka tiktok telegram"
|
||||
VALID_SERVICES="russia_inside russia_outside ukraine_inside geoblock block porn news anime youtube discord meta twitter hdrezka tiktok telegram cloudflare"
|
||||
DNS_RESOLVERS="1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 9.9.9.9 9.9.9.11 94.140.14.14 94.140.15.15 208.67.220.220 208.67.222.222 77.88.8.1 77.88.8.8"
|
||||
TEST_DOMAIN="google.com"
|
||||
TEST_DOMAIN="fakeip.tech-domain.club"
|
||||
INTERFACES_LIST=""
|
||||
SRC_INTERFACE=""
|
||||
RESOLV_CONF="/etc/resolv.conf"
|
||||
CLOUDFLARE_OCTETS="103.21 103.22 103.31 104.16 104.17 104.18 104.19 104.20 104.21 104.22 104.23 104.24 104.25 104.26 104.27 104.28 108.162 131.0 141.101 162.158 162.159 172.64 172.65 172.66 172.67 172.68 172.69 172.70 172.71 173.245 188.114 190.93 197.234 198.41"
|
||||
|
||||
log() {
|
||||
local message="$1"
|
||||
@@ -42,7 +47,26 @@ nolog() {
|
||||
echo -e "${CYAN}[$timestamp]${RESET} ${GREEN}$message${RESET}"
|
||||
}
|
||||
|
||||
start() {
|
||||
start_main() {
|
||||
log "Starting podkop"
|
||||
|
||||
# checking
|
||||
sing_box_version=$(sing-box version | head -n 1 | awk '{print $3}')
|
||||
required_version="1.11.1"
|
||||
|
||||
if [ "$(echo -e "$sing_box_version\n$required_version" | sort -V | head -n 1)" != "$required_version" ]; then
|
||||
log "[critical] The version of sing-box ($sing_box_version) is lower than the minimum version. Update sing-box: opkg update && opkg remove sing-box && opkg install sing-box"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if opkg list-installed | grep -q iptables-mod-extra; then
|
||||
log "[critical] Conflicting package detected: iptables-mod-extra"
|
||||
fi
|
||||
|
||||
if grep -qE 'doh_backup_noresolv|doh_backup_server|doh_server' /etc/config/dhcp; then
|
||||
log "[critical] Detected https-dns-proxy in dhcp config. Edit /etc/config/dhcp"
|
||||
fi
|
||||
|
||||
migration
|
||||
|
||||
config_foreach process_validate_service
|
||||
@@ -50,7 +74,7 @@ start() {
|
||||
sleep 3
|
||||
|
||||
mkdir -p /tmp/podkop
|
||||
|
||||
|
||||
# base
|
||||
route_table_rule_mark
|
||||
create_nft_table
|
||||
@@ -61,6 +85,7 @@ start() {
|
||||
sing_box_dns
|
||||
sing_box_dns_rule_fakeip
|
||||
sing_box_rule_dns
|
||||
sing_box_create_bypass_ruleset
|
||||
sing_box_add_secure_dns_probe_domain
|
||||
sing_box_cache_file
|
||||
process_socks5
|
||||
@@ -108,8 +133,13 @@ start() {
|
||||
fi
|
||||
|
||||
sing_box_config_check
|
||||
/etc/init.d/sing-box restart
|
||||
/etc/init.d/sing-box enable
|
||||
/etc/init.d/sing-box start
|
||||
#/etc/init.d/sing-box enable
|
||||
log "Nice"
|
||||
}
|
||||
|
||||
start() {
|
||||
start_main
|
||||
|
||||
config_get proxy_string "main" "proxy_string"
|
||||
config_get interface "main" "interface"
|
||||
@@ -123,13 +153,13 @@ start() {
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
stop_main() {
|
||||
log "Stopping the podkop"
|
||||
|
||||
if [ -f /var/run/podkop_list_update.pid ]; then
|
||||
pid=$(cat /var/run/podkop_list_update.pid)
|
||||
if kill -0 "$pid"; then
|
||||
kill "$pid"
|
||||
kill "$pid" 2>/dev/null
|
||||
log "Stopped list_update"
|
||||
fi
|
||||
rm -f /var/run/podkop_list_update.pid
|
||||
@@ -137,11 +167,6 @@ stop() {
|
||||
|
||||
remove_cron_job
|
||||
|
||||
config_get_bool dont_touch_dhcp "main" "dont_touch_dhcp" "0"
|
||||
if [ "$dont_touch_dhcp" -eq 0 ]; then
|
||||
dnsmasq_restore
|
||||
fi
|
||||
|
||||
rm -rf /tmp/podkop/*.lst
|
||||
|
||||
log "Flush nft"
|
||||
@@ -161,8 +186,22 @@ stop() {
|
||||
|
||||
log "Stop sing-box"
|
||||
/etc/init.d/sing-box stop
|
||||
/etc/init.d/sing-box disable
|
||||
#/etc/init.d/sing-box disable
|
||||
}
|
||||
|
||||
stop() {
|
||||
config_get_bool dont_touch_dhcp "main" "dont_touch_dhcp" "0"
|
||||
if [ "$dont_touch_dhcp" -eq 0 ]; then
|
||||
dnsmasq_restore
|
||||
fi
|
||||
|
||||
stop_main
|
||||
}
|
||||
|
||||
reload() {
|
||||
log "Podkop reload"
|
||||
stop_main
|
||||
start_main
|
||||
}
|
||||
|
||||
# Migrations and validation funcs
|
||||
@@ -261,20 +300,54 @@ route_table_rule_mark() {
|
||||
fi
|
||||
}
|
||||
|
||||
process_interfaces() {
|
||||
local iface="$1"
|
||||
INTERFACES_LIST="$INTERFACES_LIST $iface"
|
||||
iface_flag=1
|
||||
}
|
||||
|
||||
nft_interfaces() {
|
||||
local table=PodkopTable
|
||||
iface_flag=0
|
||||
|
||||
config_list_foreach "main" "iface" "process_interfaces"
|
||||
if [ "$iface_flag" -eq 0 ]; then
|
||||
SRC_INTERFACE="br-lan"
|
||||
elif [ $(echo "$INTERFACES_LIST" | wc -w) -eq 1 ]; then
|
||||
SRC_INTERFACE=$INTERFACES_LIST
|
||||
else
|
||||
local set_name="interfaces"
|
||||
if ! nft list set inet $table $set_name &>/dev/null; then
|
||||
nft add set inet $table $set_name { type ifname\; flags interval\; }
|
||||
fi
|
||||
|
||||
for interface in $INTERFACES_LIST; do
|
||||
if ! nft list element inet $table $set_name { $interface } &>/dev/null; then
|
||||
nft add element inet $table $set_name { $interface }
|
||||
fi
|
||||
done
|
||||
|
||||
SRC_INTERFACE=@$set_name
|
||||
fi
|
||||
}
|
||||
|
||||
create_nft_table() {
|
||||
local table="PodkopTable"
|
||||
|
||||
nft add table inet $table
|
||||
|
||||
nft_interfaces
|
||||
|
||||
log "Create nft rules"
|
||||
nft add chain inet $table mangle { type filter hook prerouting priority -150 \; policy accept \;}
|
||||
nft add chain inet $table proxy { type filter hook prerouting priority -100 \; policy accept \;}
|
||||
|
||||
nft add set inet $table podkop_subnets { type ipv4_addr\; flags interval\; auto-merge\; }
|
||||
|
||||
nft add rule inet $table mangle iifname "br-lan" ip daddr @podkop_subnets meta l4proto tcp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "br-lan" ip daddr @podkop_subnets meta l4proto udp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "br-lan" ip daddr "$FAKEIP" meta l4proto tcp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "br-lan" ip daddr "$FAKEIP" meta l4proto udp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "$SRC_INTERFACE" ip daddr @podkop_subnets meta l4proto tcp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "$SRC_INTERFACE" ip daddr @podkop_subnets meta l4proto udp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "$SRC_INTERFACE" ip daddr "$FAKEIP" meta l4proto tcp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "$SRC_INTERFACE" ip daddr "$FAKEIP" meta l4proto udp meta mark set 0x105 counter
|
||||
|
||||
nft add rule inet $table proxy meta mark 0x105 meta l4proto tcp tproxy ip to :1602 counter
|
||||
nft add rule inet $table proxy meta mark 0x105 meta l4proto udp tproxy ip to :1602 counter
|
||||
@@ -300,7 +373,8 @@ dnsmasq_add_resolver() {
|
||||
uci -q delete dhcp.@dnsmasq[0].podkop_server
|
||||
for server in $(uci get dhcp.@dnsmasq[0].server 2>/dev/null); do
|
||||
if [[ "$server" == "127.0.0.42" ]]; then
|
||||
log "Dnsmasq save config error: server=127.0.0.42"
|
||||
log "Dnsmasq save config error: server=127.0.0.42 is already configured. Skip editing DHCP"
|
||||
return
|
||||
else
|
||||
uci add_list dhcp.@dnsmasq[0].podkop_server="$server"
|
||||
fi
|
||||
@@ -511,12 +585,11 @@ list_update() {
|
||||
find_working_resolver() {
|
||||
local resolver_found=""
|
||||
for resolver in $DNS_RESOLVERS; do
|
||||
if nslookup $TEST_DOMAIN $resolver >/dev/null 2>&1; then
|
||||
if nslookup -timeout=2 $TEST_DOMAIN $resolver >/dev/null 2>&1; then
|
||||
echo "$resolver"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
echo "8.8.8.8"
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -532,10 +605,12 @@ sing_box_uci() {
|
||||
log "Change sing-box UCI config"
|
||||
fi
|
||||
|
||||
if grep -q '#\s*list ifaces' "$config"; then
|
||||
sed -i '/ifaces/s/#//g' $config
|
||||
log "Uncommented list ifaces"
|
||||
fi
|
||||
[ -f /etc/rc.d/S99sing-box ] && log "Disable sing-box" && /etc/init.d/sing-box disable
|
||||
|
||||
# if grep -q '#\s*list ifaces' "$config"; then
|
||||
# sed -i '/ifaces/s/#//g' $config
|
||||
# log "Uncommented list ifaces"
|
||||
# fi
|
||||
}
|
||||
|
||||
add_socks5_for_section() {
|
||||
@@ -627,7 +702,12 @@ sing_box_dns() {
|
||||
if [ "$is_ip" = "0" ]; then
|
||||
log "Finding working DNS resolver"
|
||||
local dns_resolver=$(find_working_resolver)
|
||||
log "Found working resolver: $dns_resolver"
|
||||
if [ -z "$dns_resolver" ]; then
|
||||
log "No working resolver found, using default DNS server"
|
||||
dns_resolver="1.1.1.1"
|
||||
else
|
||||
log "Found working resolver: $dns_resolver"
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Configure DNS in sing-box"
|
||||
@@ -686,6 +766,42 @@ sing_box_dns() {
|
||||
}' $SING_BOX_CONFIG > /tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
}
|
||||
|
||||
sing_box_create_bypass_ruleset() {
|
||||
log "Creating bypass ruleset for direct access"
|
||||
|
||||
jq '
|
||||
.route.rule_set += [{
|
||||
"tag": "bypass",
|
||||
"type": "inline",
|
||||
"rules": [
|
||||
{
|
||||
"domain_suffix": [
|
||||
"ip.tech-domain.club"
|
||||
]
|
||||
}
|
||||
]
|
||||
}]' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
|
||||
# Add a rule to route bypass domains to direct-out outbound
|
||||
jq '
|
||||
.route.rules += [{
|
||||
"inbound": ["tproxy-in"],
|
||||
"rule_set": ["bypass"],
|
||||
"outbound": "main",
|
||||
"action": "route"
|
||||
}]' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
|
||||
# Make sure the bypass ruleset is in the fakeip DNS rule
|
||||
jq '
|
||||
.dns.rules = (.dns.rules | map(
|
||||
if .server == "fakeip-server" then
|
||||
.rule_set += ["bypass"]
|
||||
else
|
||||
.
|
||||
end
|
||||
))' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
}
|
||||
|
||||
sing_box_dns_rule_fakeip() {
|
||||
local rewrite_ttl
|
||||
config_get rewrite_ttl "main" "dns_rewrite_ttl" "600"
|
||||
@@ -765,7 +881,7 @@ sing_box_outdound() {
|
||||
config_get interface "$section" "interface"
|
||||
|
||||
if [ -z "$interface" ]; then
|
||||
log "VPN interface is not set. Exit"
|
||||
log "[critical] VPN interface is not set. Exit"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -791,12 +907,13 @@ sing_box_outdound() {
|
||||
active_proxy_string=$(echo "$proxy_string" | grep -v "^[[:space:]]*\/\/" | head -n 1)
|
||||
|
||||
if [ -z "$active_proxy_string" ]; then
|
||||
log "Proxy string is not set. Exit"
|
||||
log "[critical] Proxy string is not set. Exit"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$active_proxy_string" =~ ^ss:// ]]; then
|
||||
sing_box_config_shadowsocks "$section" "$active_proxy_string"
|
||||
config_get ss_uot $section "ss_uot"
|
||||
sing_box_config_shadowsocks "$section" "$active_proxy_string" "$ss_uot"
|
||||
elif [[ "$active_proxy_string" =~ ^vless:// ]]; then
|
||||
sing_box_config_vless "$section" "$active_proxy_string"
|
||||
else
|
||||
@@ -863,7 +980,7 @@ sing_box_rule_dns() {
|
||||
|
||||
sing_box_config_check() {
|
||||
if ! sing-box -c $SING_BOX_CONFIG check >/dev/null 2>&1; then
|
||||
log "Sing-box configuration is invalid"
|
||||
log "[critical] Sing-box configuration is invalid"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@@ -903,6 +1020,7 @@ sing_box_config_outbound_json() {
|
||||
sing_box_config_shadowsocks() {
|
||||
local section="$1"
|
||||
local STRING="$2"
|
||||
ss_uot="${3:-0}"
|
||||
|
||||
if echo "$STRING" | cut -d'/' -f3 | cut -d'@' -f1 | base64 -d 2>/dev/null | grep -q ":"; then
|
||||
local encrypted_part=$(echo "$STRING" | cut -d'/' -f3 | cut -d'@' -f1 | base64 -d 2>/dev/null )
|
||||
@@ -926,6 +1044,7 @@ sing_box_config_shadowsocks() {
|
||||
--argjson port "$port" \
|
||||
--arg method "$method" \
|
||||
--arg password "$password" \
|
||||
--argjson ss_uot "$ss_uot" \
|
||||
'. |
|
||||
.outbounds |= (
|
||||
map(
|
||||
@@ -935,9 +1054,8 @@ sing_box_config_shadowsocks() {
|
||||
"server": $server,
|
||||
"server_port": ($port | tonumber),
|
||||
"method": $method,
|
||||
"password": $password,
|
||||
"udp_over_tcp": { "enabled": true, "version": 2 }
|
||||
}
|
||||
"password": $password
|
||||
} + (if $ss_uot == 1 then { "udp_over_tcp": { "enabled": true, "version": 2 } } else {} end)
|
||||
else . end
|
||||
) +
|
||||
(
|
||||
@@ -948,9 +1066,8 @@ sing_box_config_shadowsocks() {
|
||||
"server": $server,
|
||||
"server_port": ($port | tonumber),
|
||||
"method": $method,
|
||||
"password": $password,
|
||||
"udp_over_tcp": { "enabled": true, "version": 2 }
|
||||
}]
|
||||
"password": $password
|
||||
} + (if $ss_uot == 1 then { "udp_over_tcp": { "enabled": true, "version": 2 } } else {} end)]
|
||||
else [] end
|
||||
)
|
||||
)' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
@@ -1283,10 +1400,13 @@ list_subnets_download() {
|
||||
"telegram")
|
||||
URL=$SUBNETS_TELERAM
|
||||
;;
|
||||
"cloudflare")
|
||||
URL=$SUBNETS_CLOUDFLARE
|
||||
;;
|
||||
"discord")
|
||||
URL=$SUBNETS_DISCORD
|
||||
nft add set inet $table podkop_discord_subnets { type ipv4_addr\; flags interval\; auto-merge\; }
|
||||
nft add rule inet $table mangle iifname "br-lan" ip daddr @podkop_discord_subnets udp dport { 50000-65535 } meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "$SRC_INTERFACE" ip daddr @podkop_discord_subnets udp dport { 50000-65535 } meta mark set 0x105 counter
|
||||
;;
|
||||
*)
|
||||
return
|
||||
@@ -1526,9 +1646,11 @@ sing_box_rules_source_ip_cidr() {
|
||||
## nftables
|
||||
list_all_traffic_from_ip() {
|
||||
local ip="$1"
|
||||
if ! nft list chain inet PodkopTable mangle | grep -q "ip saddr $ip"; then
|
||||
nft add set inet PodkopTable localv4 { type ipv4_addr\; flags interval\; }
|
||||
nft add element inet PodkopTable localv4 { \
|
||||
local table="PodkopTable"
|
||||
|
||||
if ! nft list chain inet $table mangle | grep -q "ip saddr $ip"; then
|
||||
nft add set inet $table localv4 { type ipv4_addr\; flags interval\; }
|
||||
nft add element inet $table localv4 { \
|
||||
0.0.0.0/8, \
|
||||
10.0.0.0/8, \
|
||||
127.0.0.0/8, \
|
||||
@@ -1542,8 +1664,8 @@ list_all_traffic_from_ip() {
|
||||
203.0.113.0/24, \
|
||||
224.0.0.0/4, \
|
||||
240.0.0.0-255.255.255.255 }
|
||||
nft insert rule inet PodkopTable mangle iifname "br-lan" ip saddr $ip meta l4proto { tcp, udp } meta mark set 0x105 counter
|
||||
nft insert rule inet PodkopTable mangle ip saddr $ip ip daddr @localv4 return
|
||||
nft insert rule inet $table mangle iifname "$SRC_INTERFACE" ip saddr $ip meta l4proto { tcp, udp } meta mark set 0x105 counter
|
||||
nft insert rule inet $table mangle ip saddr $ip ip daddr @localv4 return
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1710,6 +1832,7 @@ check_sing_box_logs() {
|
||||
}
|
||||
|
||||
check_fakeip() {
|
||||
# Not used
|
||||
nolog "Checking fakeip functionality..."
|
||||
|
||||
if ! command -v nslookup >/dev/null 2>&1; then
|
||||
@@ -1717,28 +1840,30 @@ check_fakeip() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
local test_domain="fakeip.tech-domain.club"
|
||||
local test_domain="$TEST_DOMAIN"
|
||||
|
||||
# Additional DNS checks with different servers
|
||||
nolog "Testing DNS resolution with default DNS server"
|
||||
echo "=== Testing with default DNS server ==="
|
||||
nslookup $test_domain
|
||||
nslookup -timeout=2 $test_domain
|
||||
echo ""
|
||||
|
||||
nolog "Testing DNS resolution with Google DNS (8.8.8.8)"
|
||||
echo "=== Testing with Google DNS (8.8.8.8) ==="
|
||||
nslookup $test_domain 8.8.8.8
|
||||
echo ""
|
||||
|
||||
nolog "Testing DNS resolution with Cloudflare DNS (1.1.1.1)"
|
||||
echo "=== Testing with Cloudflare DNS (1.1.1.1) ==="
|
||||
nslookup $test_domain 1.1.1.1
|
||||
echo ""
|
||||
nolog "Finding a working DNS resolver..."
|
||||
local working_resolver=$(find_working_resolver)
|
||||
if [ -z "$working_resolver" ]; then
|
||||
nolog "No working resolver found, skipping resolver check"
|
||||
else
|
||||
nolog "Using resolver: $working_resolver"
|
||||
|
||||
nolog "Testing DNS resolution with working resolver ($working_resolver)"
|
||||
echo "=== Testing with working resolver ($working_resolver) ==="
|
||||
nslookup -timeout=2 $test_domain $working_resolver
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Main FakeIP check
|
||||
nolog "Testing DNS resolution for $test_domain using 127.0.0.42"
|
||||
echo "=== Testing with FakeIP DNS (127.0.0.42) ==="
|
||||
local result=$(nslookup $test_domain 127.0.0.42 2>&1)
|
||||
local result=$(nslookup -timeout=2 $test_domain 127.0.0.42 2>&1)
|
||||
echo "$result"
|
||||
|
||||
if echo "$result" | grep -q "198.18"; then
|
||||
@@ -1775,12 +1900,24 @@ check_fakeip() {
|
||||
check_logs() {
|
||||
nolog "Showing podkop logs from system journal..."
|
||||
|
||||
if command -v logread >/dev/null 2>&1; then
|
||||
logread -e podkop | tail -n 50
|
||||
else
|
||||
if ! command -v logread >/dev/null 2>&1; then
|
||||
nolog "Error: logread command not found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Get all logs first
|
||||
local all_logs=$(logread)
|
||||
|
||||
# Find the last occurrence of "Starting podkop"
|
||||
local start_line=$(echo "$all_logs" | grep -n "podkop.*Starting podkop" | tail -n 1 | cut -d: -f1)
|
||||
|
||||
if [ -z "$start_line" ]; then
|
||||
nolog "No 'Starting podkop' message found in logs"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Output all logs from the last start
|
||||
echo "$all_logs" | tail -n +"$start_line"
|
||||
}
|
||||
|
||||
show_sing_box_config() {
|
||||
@@ -1817,9 +1954,7 @@ show_sing_box_config() {
|
||||
)' "$SING_BOX_CONFIG"
|
||||
}
|
||||
|
||||
show_config() {
|
||||
nolog "Current podkop configuration:"
|
||||
|
||||
show_config() {
|
||||
if [ ! -f /etc/config/podkop ]; then
|
||||
nolog "Configuration file not found"
|
||||
return 1
|
||||
@@ -1836,6 +1971,8 @@ show_config() {
|
||||
-e 's/\(ss:\/\/[^@]*@\)/ss:\/\/MASKED@/g' \
|
||||
-e 's/\(pbk=[^&]*\)/pbk=MASKED/g' \
|
||||
-e 's/\(sid=[^&]*\)/sid=MASKED/g' \
|
||||
-e 's/\(option dns_server '\''[^'\'']*\.dns\.nextdns\.io'\''\)/option dns_server '\''MASKED.dns.nextdns.io'\''/g' \
|
||||
-e "s|\(option dns_server 'dns\.nextdns\.io\)/[^']*|\1/MASKED|"
|
||||
> "$tmp_config"
|
||||
|
||||
cat "$tmp_config"
|
||||
@@ -1843,17 +1980,17 @@ show_config() {
|
||||
}
|
||||
|
||||
show_version() {
|
||||
local version=$(opkg info podkop | grep -m 1 "Version:" | cut -d' ' -f2)
|
||||
local version=$(opkg list-installed podkop | awk '{print $3}')
|
||||
echo "$version"
|
||||
}
|
||||
|
||||
show_luci_version() {
|
||||
local version=$(opkg info luci-app-podkop | grep -m 1 "Version:" | cut -d' ' -f2)
|
||||
local version=$(opkg list-installed luci-app-podkop | awk '{print $3}')
|
||||
echo "$version"
|
||||
}
|
||||
|
||||
show_sing_box_version() {
|
||||
local version=$(opkg info sing-box | grep -m 1 "Version:" | cut -d' ' -f2)
|
||||
local version=$(sing-box version | head -n 1 | awk '{print $3}')
|
||||
echo "$version"
|
||||
}
|
||||
|
||||
@@ -1908,40 +2045,86 @@ get_sing_box_status() {
|
||||
}
|
||||
|
||||
get_status() {
|
||||
local running=0
|
||||
local enabled=0
|
||||
local status=""
|
||||
|
||||
# Check if service is enabled
|
||||
if [ -x /etc/rc.d/S99podkop ]; then
|
||||
enabled=1
|
||||
fi
|
||||
|
||||
# Check if service is running
|
||||
if pgrep -f "sing-box" >/dev/null; then
|
||||
running=1
|
||||
fi
|
||||
|
||||
# Format status message
|
||||
if [ $running -eq 1 ]; then
|
||||
if [ $enabled -eq 1 ]; then
|
||||
status="running & enabled"
|
||||
else
|
||||
status="running but disabled"
|
||||
fi
|
||||
status="enabled"
|
||||
else
|
||||
if [ $enabled -eq 1 ]; then
|
||||
status="stopped but enabled"
|
||||
else
|
||||
status="stopped & disabled"
|
||||
fi
|
||||
status="disabled"
|
||||
fi
|
||||
|
||||
echo "{\"running\":$running,\"enabled\":$enabled,\"status\":\"$status\"}"
|
||||
echo "{\"enabled\":$enabled,\"status\":\"$status\"}"
|
||||
}
|
||||
|
||||
check_dns_available() {
|
||||
local dns_type=$(uci get podkop.main.dns_type 2>/dev/null)
|
||||
local dns_server=$(uci get podkop.main.dns_server 2>/dev/null)
|
||||
local is_available=0
|
||||
local status="unavailable"
|
||||
local local_dns_working=0
|
||||
local local_dns_status="unavailable"
|
||||
|
||||
# Mask NextDNS ID if present
|
||||
local display_dns_server="$dns_server"
|
||||
if echo "$dns_server" | grep -q "\.dns\.nextdns\.io$"; then
|
||||
local nextdns_id=$(echo "$dns_server" | cut -d'.' -f1)
|
||||
display_dns_server="$(echo "$nextdns_id" | sed 's/./*/g').dns.nextdns.io"
|
||||
elif echo "$dns_server" | grep -q "^dns\.nextdns\.io/"; then
|
||||
local masked_path=$(echo "$dns_server" | cut -d'/' -f2- | sed 's/./*/g')
|
||||
display_dns_server="dns.nextdns.io/$masked_path"
|
||||
fi
|
||||
|
||||
if [ "$dns_type" = "doh" ]; then
|
||||
local result=""
|
||||
|
||||
if echo "$dns_server" | grep -q "quad9.net" || \
|
||||
echo "$dns_server" | grep -qE "^9\.9\.9\.(9|10|11)$|^149\.112\.112\.(112|10|11)$|^2620:fe::(fe|9|10|11)$|^2620:fe::fe:(10|11)$"; then
|
||||
result=$(curl --connect-timeout 5 -s -H "accept: application/dns-json" "https://$dns_server:5053/dns-query?name=itdog.info&type=A")
|
||||
else
|
||||
result=$(curl --connect-timeout 5 -s -H "accept: application/dns-json" "https://$dns_server/dns-query?name=itdog.info&type=A")
|
||||
if [ $? -eq 0 ] && echo "$result" | grep -q "data"; then
|
||||
is_available=1
|
||||
status="available"
|
||||
else
|
||||
result=$(curl --connect-timeout 5 -s -H "accept: application/dns-json" "https://$dns_server/resolve?name=itdog.info&type=A")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $? -eq 0 ] && echo "$result" | grep -q "data"; then
|
||||
is_available=1
|
||||
status="available"
|
||||
fi
|
||||
elif [ "$dns_type" = "dot" ]; then
|
||||
(nc "$dns_server" 853 </dev/null >/dev/null 2>&1) & pid=$!
|
||||
sleep 2
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
kill $pid 2>/dev/null
|
||||
wait $pid 2>/dev/null
|
||||
else
|
||||
is_available=1
|
||||
status="available"
|
||||
fi
|
||||
elif [ "$dns_type" = "udp" ]; then
|
||||
if nslookup -timeout=2 itdog.info $dns_server >/dev/null 2>&1; then
|
||||
is_available=1
|
||||
status="available"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if local DNS resolver is working
|
||||
if nslookup -timeout=2 $TEST_DOMAIN 127.0.0.1 >/dev/null 2>&1; then
|
||||
local_dns_working=1
|
||||
local_dns_status="available"
|
||||
fi
|
||||
|
||||
echo "{\"dns_type\":\"$dns_type\",\"dns_server\":\"$display_dns_server\",\"is_available\":$is_available,\"status\":\"$status\",\"local_dns_working\":$local_dns_working,\"local_dns_status\":\"$local_dns_status\"}"
|
||||
}
|
||||
|
||||
sing_box_add_secure_dns_probe_domain() {
|
||||
local domain="fakeip.tech-domain.club"
|
||||
local domain="$TEST_DOMAIN"
|
||||
local override_port=8443
|
||||
|
||||
log "Adding DNS probe domain ${domain} to fakeip-server configuration"
|
||||
@@ -1969,6 +2152,154 @@ sing_box_add_secure_dns_probe_domain() {
|
||||
log "DNS probe domain ${domain} configured with override to port ${override_port}"
|
||||
}
|
||||
|
||||
print_global() {
|
||||
local message="$1"
|
||||
echo "$message"
|
||||
}
|
||||
|
||||
global_check() {
|
||||
print_global "📡 Global check run!"
|
||||
print_global "━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
print_global "🛠️ System info"
|
||||
print_global "🕳️ Podkop: $(opkg list-installed podkop | awk '{print $3}')"
|
||||
print_global "🕳️ LuCI App: $(opkg list-installed luci-app-podkop | awk '{print $3}')"
|
||||
print_global "📦 Sing-box: $(sing-box version | head -n 1 | awk '{print $3}')"
|
||||
print_global "🛜 OpenWrt: $(grep OPENWRT_RELEASE /etc/os-release | cut -d'"' -f2)"
|
||||
print_global "🛜 Device: $(cat /tmp/sysinfo/model)"
|
||||
|
||||
print_global "━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
print_global "📄 Podkop config"
|
||||
show_config
|
||||
|
||||
print_global "━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
print_global "🔧 System check"
|
||||
|
||||
if grep -E "^nameserver\s+([0-9]{1,3}\.){3}[0-9]{1,3}" "$RESOLV_CONF" | grep -vqE "127\.0\.0\.1|0\.0\.0\.0"; then
|
||||
print_global "❌ /etc/resolv.conf contains external nameserver:"
|
||||
cat /etc/resolv.conf
|
||||
echo ""
|
||||
else
|
||||
print_global "✅ /etc/resolv.conf"
|
||||
fi
|
||||
|
||||
cachesize="$(uci get dhcp.@dnsmasq[0].cachesize 2>/dev/null)"
|
||||
noresolv="$(uci get dhcp.@dnsmasq[0].noresolv 2>/dev/null)"
|
||||
server="$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)"
|
||||
|
||||
if [ "$cachesize" != "0" ] || [ "$noresolv" != "1" ] || [ "$server" != "127.0.0.42" ]; then
|
||||
print_global "❌ DHCP configuration differs from template. 📄 DHCP config:"
|
||||
awk '/^config /{p=($2=="dnsmasq")} p' /etc/config/dhcp
|
||||
elif [ "$(uci get podkop.main.dont_touch_dhcp 2>/dev/null)" = "1" ]; then
|
||||
print_global "⚠️ dont_touch_dhcp is enabled. 📄 DHCP config:"
|
||||
awk '/^config /{p=($2=="dnsmasq")} p' /etc/config/dhcp
|
||||
else
|
||||
print_global "✅ /etc/config/dhcp"
|
||||
fi
|
||||
|
||||
if ! pgrep -f "sing-box" >/dev/null; then
|
||||
print_global "❌ sing-box is not running"
|
||||
else
|
||||
print_global "✅ sing-box is running"
|
||||
fi
|
||||
|
||||
print_global "━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
print_global "🧱 NFT table"
|
||||
if ! nft list table inet PodkopTable >/dev/null 2>&1; then
|
||||
print_global "❌ PodkopTable not found"
|
||||
else
|
||||
nft list table inet PodkopTable
|
||||
fi
|
||||
|
||||
print_global "━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
print_global "📄 WAN config"
|
||||
if uci show network.wan >/dev/null 2>&1; then
|
||||
awk '
|
||||
/^config / {
|
||||
p = ($2 == "interface" && $3 == "'\''wan'\''")
|
||||
proto = ""
|
||||
}
|
||||
p {
|
||||
if ($1 == "option" && $2 == "proto") {
|
||||
proto = $3
|
||||
print
|
||||
} else if (proto == "'\''static'\''" && $1 == "option" && ($2 == "ipaddr" || $2 == "netmask" || $2 == "gateway")) {
|
||||
print " option", $2, "'\''******'\''"
|
||||
} else if (proto == "'\''pppoe'\''" && $1 == "option" && ($2 == "username" || $2 == "password")) {
|
||||
print " option", $2, "'\''******'\''"
|
||||
} else {
|
||||
print
|
||||
}
|
||||
}
|
||||
' /etc/config/network
|
||||
else
|
||||
print_global "❌ WAN configuration not found"
|
||||
fi
|
||||
|
||||
if uci show network | grep -q endpoint_host; then
|
||||
uci show network | grep endpoint_host | cut -d'=' -f2 | tr -d "'\" " | while read -r host; do
|
||||
if [ "$host" = "engage.cloudflareclient.com" ]; then
|
||||
print_global "⚠️ WARP detected: $host"
|
||||
continue
|
||||
fi
|
||||
|
||||
ip_prefix=$(echo "$host" | cut -d'.' -f1,2)
|
||||
if echo "$CLOUDFLARE_OCTETS" | grep -wq "$ip_prefix"; then
|
||||
print_global "━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
print_global "⚠️ WARP detected: $host"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
print_global "━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
print_global "➡️ DNS status"
|
||||
dns_info=$(check_dns_available)
|
||||
dns_type=$(echo "$dns_info" | jq -r '.dns_type')
|
||||
dns_server=$(echo "$dns_info" | jq -r '.dns_server')
|
||||
status=$(echo "$dns_info" | jq -r '.status')
|
||||
print_global "$dns_type ($dns_server) is $status"
|
||||
|
||||
print_global "━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
print_global "🔁 FakeIP"
|
||||
|
||||
print_global "➡️ DNS resolution: system DNS server"
|
||||
nslookup -timeout=2 $TEST_DOMAIN
|
||||
|
||||
local working_resolver=$(find_working_resolver)
|
||||
if [ -z "$working_resolver" ]; then
|
||||
print_global "❌ No working external resolver found"
|
||||
else
|
||||
print_global "➡️ DNS resolution: external resolver ($working_resolver)"
|
||||
nslookup -timeout=2 $TEST_DOMAIN $working_resolver
|
||||
fi
|
||||
|
||||
print_global "➡️ DNS resolution: sing-box DNS server (127.0.0.42)"
|
||||
local result=$(nslookup -timeout=2 $TEST_DOMAIN 127.0.0.42 2>&1)
|
||||
echo "$result"
|
||||
|
||||
if echo "$result" | grep -q "198.18"; then
|
||||
print_global "✅ FakeIP is working correctly on router (198.18.x.x)"
|
||||
else
|
||||
print_global "❌ FakeIP test failed: Domain did not resolve to FakeIP range"
|
||||
if ! pgrep -f "sing-box" >/dev/null; then
|
||||
print_global " ❌ sing-box is not running"
|
||||
else
|
||||
print_global " 🤔 sing-box is running, checking configuration"
|
||||
|
||||
if [ -f "$SING_BOX_CONFIG" ]; then
|
||||
local fakeip_enabled=$(jq -r '.dns.fakeip.enabled' "$SING_BOX_CONFIG")
|
||||
local fakeip_range=$(jq -r '.dns.fakeip.inet4_range' "$SING_BOX_CONFIG")
|
||||
local dns_rules=$(jq -r '.dns.rules[] | select(.server == "fakeip-server") | .domain' "$SING_BOX_CONFIG")
|
||||
|
||||
print_global " 📦 FakeIP enabled: $fakeip_enabled"
|
||||
print_global " 📦 FakeIP range: $fakeip_range"
|
||||
print_global " 📦 FakeIP domain: $dns_rules"
|
||||
else
|
||||
print_global " ⛔ sing-box config file not found"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
@@ -1976,9 +2307,8 @@ case "$1" in
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
reload)
|
||||
reload
|
||||
;;
|
||||
main)
|
||||
main
|
||||
@@ -2034,8 +2364,14 @@ case "$1" in
|
||||
get_sing_box_status)
|
||||
get_sing_box_status
|
||||
;;
|
||||
check_dns_available)
|
||||
check_dns_available
|
||||
;;
|
||||
global_check)
|
||||
global_check
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload|enable|disable|main|list_update|check_proxy|check_nft|check_github|check_logs|check_sing_box_connections|check_sing_box_logs|check_fakeip|check_dnsmasq|show_config|show_version|show_sing_box_config|show_luci_version|show_sing_box_version|show_system_info|get_status|get_sing_box_status}"
|
||||
echo "Usage: $0 {start|stop|reload|enable|disable|main|list_update|check_proxy|check_nft|check_github|check_logs|check_sing_box_connections|check_sing_box_logs|check_fakeip|check_dnsmasq|show_config|show_version|show_sing_box_config|show_luci_version|show_sing_box_version|show_system_info|get_status|get_sing_box_status|check_dns_available|global_check}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user