mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-06 11:36:50 +03:00
Compare commits
78 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c96de62d96 | ||
|
|
14b7fbe4f7 | ||
|
|
3d05fe8be4 | ||
|
|
6ddf9d3b24 | ||
|
|
b401243f74 | ||
|
|
407ef404ac | ||
|
|
f2e45bbbb9 | ||
|
|
c2b37a14f4 | ||
|
|
3d029edaea | ||
|
|
b86d6d6294 | ||
|
|
5c48ead9e4 | ||
|
|
53475b5e8a | ||
|
|
59e1d75870 | ||
|
|
3ec6cc4d84 | ||
|
|
3413af9f94 | ||
|
|
76b5ceae5c | ||
|
|
99ccd9fbb3 | ||
|
|
b82c6eb718 | ||
|
|
ccc87d9aa0 | ||
|
|
8bcdee87f5 | ||
|
|
f77ef5626b | ||
|
|
b50a21ded7 | ||
|
|
a831054e5e | ||
|
|
a8dbff816c | ||
|
|
171381fa18 | ||
|
|
b806586a5a | ||
|
|
9e2b192181 | ||
|
|
c5be041664 | ||
|
|
445ad6d3d2 | ||
|
|
9203315107 | ||
|
|
d8d8d79d68 | ||
|
|
615928db4e | ||
|
|
7697754a73 | ||
|
|
25107a0481 | ||
|
|
5f5b1cbe1f | ||
|
|
a278918e77 | ||
|
|
2074ccecce | ||
|
|
06f9bee038 | ||
|
|
febb69d0be | ||
|
|
1a6ee45612 | ||
|
|
891b8f713d | ||
|
|
b96552fb49 | ||
|
|
ce9a7cdc45 | ||
|
|
6071a96e9c | ||
|
|
000d2f8e18 | ||
|
|
e17422a0cf | ||
|
|
2e78b2b4b8 | ||
|
|
b84f3b6782 | ||
|
|
0f66305e50 | ||
|
|
a32a5c600b | ||
|
|
89737efcbc | ||
|
|
4608bc31cd | ||
|
|
d9e9f2dfe4 | ||
|
|
bb9318e96f | ||
|
|
7ff49c3e4e | ||
|
|
134a79cb3b | ||
|
|
560dda8604 | ||
|
|
255c08a6de | ||
|
|
1f3a65347e | ||
|
|
ec936e2369 | ||
|
|
cee934d139 | ||
|
|
a25c6b8013 | ||
|
|
ec3a281cef | ||
|
|
86947e7dee | ||
|
|
ff5d017acc | ||
|
|
22d919657c | ||
|
|
3271f23ae0 | ||
|
|
35ea1a14cf | ||
|
|
51a9cc5934 | ||
|
|
e1df26e62b | ||
|
|
75b8bef0e0 | ||
|
|
1a6b0cac46 | ||
|
|
e49bd91109 | ||
|
|
85642a2585 | ||
|
|
c31785d20e | ||
|
|
a0af04037a | ||
|
|
51fb10e30e | ||
|
|
069ea41ef8 |
111
README.md
111
README.md
@@ -2,7 +2,7 @@
|
||||
|
||||
- Это альфа версия, которая находится в активной разработке. Из версии в версию что-то может меняться.
|
||||
- Основной функционал работает, но побочные штуки сейчас могут сбоить.
|
||||
- При обновлении **обязатально** сбрасывайте кэш LuCI.
|
||||
- При обновлении **обязательно** сбрасывайте кэш LuCI.
|
||||
- Также при обновлении всегда заходите в конфигурацию и проверяйте свои настройки. Конфигурация может измениться.
|
||||
- Необходимо минимум 15МБ свободного места на роутере. Роутерами с флешками на 16МБ сразу мимо.
|
||||
- При старте программы редактируется конфиг Dnsmasq.
|
||||
@@ -49,11 +49,6 @@ sh <(wget -O - https://raw.githubusercontent.com/itdoginfo/podkop/refs/heads/mai
|
||||
opkg remove luci-i18n-podkop-ru luci-app-podkop podkop
|
||||
```
|
||||
|
||||
Если был установлен русский язык
|
||||
```
|
||||
opkg remove luci-i18n-podkop-ru
|
||||
```
|
||||
|
||||
# Использование
|
||||
Конфиг: /etc/config/podkop
|
||||
|
||||
@@ -74,124 +69,32 @@ Luci: Services/podkop
|
||||
## Настройка доменов и подсетей
|
||||
**Community Lists** - Включить списки комьюнити
|
||||
|
||||
**Subnets list enable** - Включить подсети из общего списка, выбрать из предложенных.
|
||||
|
||||
**Custom domains enable** - Добавить свои домены
|
||||
|
||||
**Custom subnets enable** - Добавить подсети или IP-адреса. Для подсетей задать маску.
|
||||
|
||||
# Известные баги
|
||||
- [x] Не работает proxy при режимах main vpn, second proxy
|
||||
- [x] Не всегда отрабатывает ucitrack (применение настроек из luci). Не удаётся повторить
|
||||
- [x] All traffic for IP ломает инет на клиенте. Proxy mode
|
||||
- [x] Не отрабатывает рестарт, при awg и не применяются изменения при awg
|
||||
- [x] awg работает не стабильно
|
||||
- [x] Сеть рестартится при любом раскладе
|
||||
- [x] Выкл-вкл wg через luci не отрабатывает поднятие маршрута
|
||||
- [ ] Если eof после последней строки в rt_tables, то скрипт не добавляет перенос строки
|
||||
- [ ] Парсинг VLESS не отрабатывает, если в SNI два домена. Пример `sni=telegram.org%3Bwww.telegram.org`
|
||||
- [ ] `service network restart` ломает маршруты при sing-box
|
||||
- [ ] Совпадение секции с ruleset ломает конфиг sing-box
|
||||
- [ ] В каких-то случаях плохо отрабатывает localfile
|
||||
- [ ] exit 1 если в конфиге присуствует
|
||||
```
|
||||
option doh_backup_noresolv '0'
|
||||
list doh_backup_server ''
|
||||
list doh_backup_server ''
|
||||
list doh_server '127.0.0.1#5053'
|
||||
list doh_server '127.0.0.1#5054'
|
||||
```
|
||||
- [x] Только кастомный remote list не создаёт секцию в route-rules-rule-set и dns-rules-ruleset
|
||||
- [ ] Не отрабатывает service podkop stop, если podkop запущен и не может, к пример, зарезолвить домен с сломанным DNS
|
||||
- [ ] Всплывает в логах при старте. Не каждый раз. На работу не влияет. Wed Feb 19 17:12:28 2025 daemon.err sh[17665]: Command failed: ubus call service delete { "name": "sing-box" } (Not found)
|
||||
- [ ] Update list из remote url domain не удаляет старые домены. А добавляет новые. Для подсетей тоже самое скорее всего. Пересоздавать ruleset?
|
||||
|
||||
# ToDo
|
||||
Этот раздел не означает задачи, которые нужно брать и делать. Это общий список хотелок. Если вы хотите помочь, пожалуйста, спросите сначала в телеграмме.
|
||||
|
||||
Сделано
|
||||
- [x] Скрипт для автоматической установки.
|
||||
- [x] Подсети дискорда.
|
||||
- [x] Удаление getdomains через скрипт. Кроме туннеля и sing-box.
|
||||
- [x] Дополнительная вкладка для ещё одного туннеля. Домены, подсети.
|
||||
- [x] Улучшение скрипта автоматической установки. Спрашивать про туннели.
|
||||
- [x] Зависимость от dnsmasq-full
|
||||
- [x] Весь трафик для устойства пускать в туннель\прокси
|
||||
- [x] Исключение для IP, не ходить в туннель\прокси совсем 0x0
|
||||
- [x] Врубать галочкой yacd в sing-box
|
||||
- [x] Свои списки. Просто список доменов с переносом строки
|
||||
- [x] Свои списки ipv4
|
||||
- [x] В nft разделить правило tproxy на маркировку и tproxy
|
||||
- [x] Вернуть две цепочки nft
|
||||
- [x] Ntp (порт 123) делать маркировку 0x0. По галке
|
||||
- [x] Открытый прокси порт на роутере для браузеров
|
||||
- [x] Автонастройка wireguard по примеру getdomains
|
||||
- [x] Автонастройка awg по примеру getdomains
|
||||
- [x] RU перевод
|
||||
- [x] Переделать на PROCD и выкинуть ucitrack.
|
||||
- [x] Нужен дебаг. Restart ucitrack в отдельный скрипт postinst, не отрабатывает.
|
||||
- [x] Закомментировать дефолтные значения у list. interface поставить в пустое.
|
||||
- [x] Скрипт установки: проверка установлен ли уже podkop. Если да, то просто предлагать обновится без установки тунелей и прокси.
|
||||
|
||||
Приоритет 1
|
||||
- [x] Изменить название "Alternative Config"
|
||||
- [x] "domain_service_enabled" Добавить _second
|
||||
- [x] Установка Ru пакета в install.sh
|
||||
- [x] Правка nft mark, tproxy
|
||||
- [x] Правка перевода минимальная
|
||||
- [x] Вставлять готовый outdbound вместо строки. Отдельная галка, которая в идеале должны скрывать поле для строки
|
||||
- [ ] udp over tcp для ss сделать с выбором:
|
||||
1) отключен (ПО на сервере -Shadowsocks)
|
||||
2) включен, версия 2 (новые релизы xray-core, sing-box на сервере)
|
||||
3) включен, версия 1 (старые релизы xray, sing-box на сервере)
|
||||
Проблема в том, что это нужно только если SS. Выставлять выбор при парсинг из конфига вопрос можно ли. Если совсем тупо - сделать костыль в допонительные настройки
|
||||
- [x] Проверка места в скрипте install. Если доступно меньше 20MB - exit 1 c выводом колько надо и сколько доступно. + показ модели роутера
|
||||
- [ ] Правило запрещающее QUIC
|
||||
- [ ] Проверить обновление списков, отрабатывает ли
|
||||
- [ ] Проверка на ванильную openwrt
|
||||
- [ ] Проверка откуда установлен sing-box. Например, проверять установлен ли он из официального репозитория
|
||||
- [x] TG в сервисы
|
||||
- [ ] Выбор ткуда направлять трафик в туннель. В том числе чтоб откуда угодно, а не только br-lan
|
||||
- [ ] Диагностика: Proxy check completed successfully предположительно не показывает IP, если вернулся это IPv6.
|
||||
- [ ] Диагностика: podkop_domains: 0 elements как проверять что доходят запросы при fakeip? Мб врубать логи dnsmasq и их чекать.
|
||||
- [ ] Сделать галку запрещающую подкопу редачить dhcp. Допилить в исключение вместе с пустыми полями proxy и vpn
|
||||
- [ ] Валидации предустановленных значений. Если прописаны другие, то вывод в лог о неизвестной переменной и продолжение работы
|
||||
- [ ] Добавление в список доменов домены первого уровня (LuCI)
|
||||
- [ ] Проверка, что версия в makefile совпадает с тегом
|
||||
- [ ] Don't touch my DHCP!
|
||||
|
||||
Приоритет 2
|
||||
- [x] Списки доменов и подсетей с роутера
|
||||
- [ ] Кнопка обновления списка доменов и подсетей. Запихнуть в главное меню
|
||||
- [ ] IPv6
|
||||
|
||||
Wiki
|
||||
- [x] Тема
|
||||
- [x] Изначальное наполнение
|
||||
- [ ] Диагностика: Proxy check completed successfully предположительно не показывает IP, если вернулся это IPv6.
|
||||
- [ ] Сделать галку запрещающую подкопу редачить dhcp. Допилить в исключение вместе с пустыми полями proxy и vpn
|
||||
- [ ] Обработка ошибки `sing-box[9345]: FATAL[0000] start service: initialize DNS rule[2]: rule-set not found: main`. Когда не задана строка\интерфейс
|
||||
|
||||
Низкий приоритет
|
||||
- [x] Переменная, раз во сколько часов обновлять списки
|
||||
- [ ] Галочка, которая режет доступ к doh серверам
|
||||
- [ ] Свой конфиг sing-box
|
||||
- [x] Поменять curl на wget, убрать зависимость. Проверять доступность списков лучше всего curl`ом
|
||||
- [ ] IPv6. Только после наполнения Wiki
|
||||
|
||||
Рефактор
|
||||
- [ ] Handle для sing-box
|
||||
- [ ] Handle для dnsmasq
|
||||
- [ ] Формирование json для sing-box на уровне jq, а не шаблонов
|
||||
- [ ] Unit тесты (BATS)
|
||||
- [ ] Интеграционые тесты бекенда (OpenWrt rootfs + BATS)
|
||||
|
||||
Хз как сделать
|
||||
- [ ] Добавить label от конфига vless\ss\etc в luci.
|
||||
|
||||
# Установка версии v0.2.5
|
||||
Удаляет полностью все пакеты podkop. Удаляет текущую конфигурацию podkop.
|
||||
После установки **обязательно** сбросьте кэш в LuCI.
|
||||
|
||||
```
|
||||
sh <(wget -O - https://raw.githubusercontent.com/itdoginfo/podkop/refs/heads/main/install-v0.2.5.sh)
|
||||
```
|
||||
|
||||
# Разработка
|
||||
Есть два варианта:
|
||||
- Просто поставить пакет на роутер или виртуалку и прям редактировать через SFTP (opkg install openssh-sftp-server)
|
||||
@@ -240,7 +143,7 @@ make package/luci-app-podkop/{clean,compile} V=s
|
||||
|
||||
.ipk лежат в `bin/packages/x86_64/base/`
|
||||
|
||||
## Примеры строкs
|
||||
## Примеры строк
|
||||
https://github.com/itdoginfo/podkop/blob/main/String-example.md
|
||||
|
||||
## Ошибки
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
REPO="https://api.github.com/repos/itdoginfo/podkop/releases/tags/v0.2.5"
|
||||
|
||||
DOWNLOAD_DIR="/tmp/podkop"
|
||||
COUNT=3
|
||||
|
||||
rm -rf "$DOWNLOAD_DIR"
|
||||
mkdir -p "$DOWNLOAD_DIR"
|
||||
|
||||
main() {
|
||||
check_system
|
||||
|
||||
opkg update
|
||||
|
||||
if [ -f "/etc/init.d/podkop" ]; then
|
||||
echo "Remove current vesrion podkop"
|
||||
opkg remove luci-i18n-podkop-ru luci-app-podkop podkop
|
||||
rm /etc/config/podkop
|
||||
else
|
||||
echo "Installed podkop..."
|
||||
fi
|
||||
|
||||
wget -qO- "$REPO" | grep -o 'https://[^"[:space:]]*\.ipk' | while read -r url; do
|
||||
filename=$(basename "$url")
|
||||
filepath="$DOWNLOAD_DIR/$filename"
|
||||
|
||||
attempt=0
|
||||
while [ $attempt -lt $COUNT ]; do
|
||||
if [ -f "$filepath" ] && [ -s "$filepath" ]; then
|
||||
echo "$filename has already been uploaded"
|
||||
break
|
||||
fi
|
||||
|
||||
echo "Download $filename (count $((attempt+1)))..."
|
||||
wget -q -O "$filepath" "$url"
|
||||
|
||||
if [ -s "$filepath" ]; then
|
||||
echo "$filename successfully downloaded"
|
||||
else
|
||||
echo "Download error $filename. Retry..."
|
||||
rm -f "$filepath"
|
||||
fi
|
||||
attempt=$((attempt+1))
|
||||
done
|
||||
done
|
||||
|
||||
for pkg in podkop luci-app-podkop; do
|
||||
file=$(ls "$DOWNLOAD_DIR" | grep "^$pkg" | head -n 1)
|
||||
if [ -n "$file" ]; then
|
||||
echo "Installing $file"
|
||||
opkg install "$DOWNLOAD_DIR/$file"
|
||||
fi
|
||||
done
|
||||
|
||||
ru=$(ls "$DOWNLOAD_DIR" | grep "luci-i18n-podkop-ru" | head -n 1)
|
||||
if [ -n "$ru" ]; then
|
||||
printf "\033[32;1mРусский язык интерфейса ставим? y/n (Need a Russian translation?)\033[0m "
|
||||
while true; do
|
||||
read -r -p '' RUS
|
||||
case $RUS in
|
||||
y)
|
||||
opkg install "$DOWNLOAD_DIR/$ru"
|
||||
break
|
||||
;;
|
||||
n)
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Введите y или n"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
rm -f $DOWNLOAD_DIR/podkop*.ipk $DOWNLOAD_DIR/luci-app-podkop*.ipk $DOWNLOAD_DIR/luci-i18n-podkop-ru*.ipk
|
||||
|
||||
}
|
||||
|
||||
|
||||
check_system() {
|
||||
# Get router model
|
||||
MODEL=$(cat /tmp/sysinfo/model)
|
||||
echo "Router model: $MODEL"
|
||||
|
||||
if ! nslookup google.com >/dev/null 2>&1; then
|
||||
log "DNS not working"
|
||||
exit 1
|
||||
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
|
||||
}
|
||||
|
||||
main
|
||||
@@ -111,7 +111,7 @@ main() {
|
||||
}
|
||||
|
||||
add_tunnel() {
|
||||
printf "\033[32;1mWill you be using Wireguard, AmneziaWG, OpenVPN, OpenConnect? If yes, select a number and they will be automatically installed\033[0m "
|
||||
printf "\033[32;1mWill you be using Wireguard, AmneziaWG, OpenVPN, OpenConnect? If yes, select a number and they will be automatically installed\033[0m\n"
|
||||
echo "1) Wireguard"
|
||||
echo "2) AmneziaWG"
|
||||
echo "3) OpenVPN"
|
||||
@@ -412,7 +412,7 @@ check_system() {
|
||||
fi
|
||||
|
||||
if ! nslookup google.com >/dev/null 2>&1; then
|
||||
log "DNS not working"
|
||||
printf "\033[31;1mDNS not working\033[0m\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-podkop
|
||||
PKG_VERSION:=0.3.11
|
||||
PKG_VERSION:=0.3.22
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LUCI_TITLE:=LuCI podkop app
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -494,4 +494,232 @@ msgid "Update Lists"
|
||||
msgstr "Обновить списки"
|
||||
|
||||
msgid "Lists Update Results"
|
||||
msgstr "Результаты обновления списков"
|
||||
msgstr "Результаты обновления списков"
|
||||
|
||||
msgid "DNS Protocol Type"
|
||||
msgstr "Тип DNS протокола"
|
||||
|
||||
msgid "Select DNS protocol to use"
|
||||
msgstr "Выберите протокол DNS"
|
||||
|
||||
msgid "DNS over HTTPS (DoH)"
|
||||
msgstr "DNS через HTTPS (DoH)"
|
||||
|
||||
msgid "DNS over TLS (DoT)"
|
||||
msgstr "DNS через TLS (DoT)"
|
||||
|
||||
msgid "UDP (Unprotected DNS)"
|
||||
msgstr "UDP (Незащищённый DNS)"
|
||||
|
||||
msgid "DNS Server"
|
||||
msgstr "DNS сервер"
|
||||
|
||||
msgid "Select or enter DNS server address"
|
||||
msgstr "Выберите или введите адрес DNS сервера"
|
||||
|
||||
msgid "DNS server address cannot be empty"
|
||||
msgstr "Адрес DNS сервера не может быть пустым"
|
||||
|
||||
msgid "Invalid DNS server format. Examples: 8.8.8.8 or dns.example.com"
|
||||
msgstr "Неверный формат DNS сервера. Примеры: 8.8.8.8 или dns.example.com"
|
||||
|
||||
msgid "DNS Rewrite TTL"
|
||||
msgstr "Перезапись TTL для DNS"
|
||||
|
||||
msgid "Time in seconds for DNS record caching (default: 600)"
|
||||
msgstr "Время в секундах для кэширования DNS записей (по умолчанию: 600)"
|
||||
|
||||
msgid "TTL value cannot be empty"
|
||||
msgstr "Значение TTL не может быть пустым"
|
||||
|
||||
msgid "TTL must be a positive number"
|
||||
msgstr "TTL должно быть положительным числом"
|
||||
|
||||
msgid "Cache File Path"
|
||||
msgstr "Путь к файлу кэша"
|
||||
|
||||
msgid "Select or enter path for sing-box cache file. Change this ONLY if you know what you are doing"
|
||||
msgstr "Выберите или введите путь к файлу кэша sing-box. Меняйте ТОЛЬКО если знаете, что делаете"
|
||||
|
||||
msgid "Cache file path cannot be empty"
|
||||
msgstr "Путь к файлу кэша не может быть пустым"
|
||||
|
||||
msgid "Path must be absolute (start with /)"
|
||||
msgstr "Путь должен быть абсолютным (начинаться с /)"
|
||||
|
||||
msgid "Path must end with cache.db"
|
||||
msgstr "Путь должен заканчиваться на cache.db"
|
||||
|
||||
msgid "Path must contain at least one directory (like /tmp/cache.db)"
|
||||
msgstr "Путь должен содержать хотя бы одну директорию (например /tmp/cache.db)"
|
||||
|
||||
msgid "Invalid path format. Must be like /tmp/cache.db"
|
||||
msgstr "Неверный формат пути. Пример: /tmp/cache.db"
|
||||
|
||||
msgid "Copy to Clipboard"
|
||||
msgstr "Копировать в буфер обмена"
|
||||
|
||||
msgid "Close"
|
||||
msgstr "Закрыть"
|
||||
|
||||
msgid "Loading..."
|
||||
msgstr "Загрузка..."
|
||||
|
||||
msgid "Loading version information..."
|
||||
msgstr "Загрузка информации о версии..."
|
||||
|
||||
msgid "Checking FakeIP..."
|
||||
msgstr "Проверка FakeIP..."
|
||||
|
||||
msgid "timeout"
|
||||
msgstr "таймаут"
|
||||
|
||||
msgid "Current config: "
|
||||
msgstr "Текущая конфигурация: "
|
||||
|
||||
msgid "Invalid VLESS URL: type must be one of tcp, udp, grpc, http"
|
||||
msgstr "Неверный URL VLESS: тип должен быть одним из tcp, udp, grpc, http"
|
||||
|
||||
msgid "Invalid VLESS URL: security must be one of tls, reality, none"
|
||||
msgstr "Неверный URL VLESS: security должен быть одним из tls, reality, none"
|
||||
|
||||
msgid "Podkop"
|
||||
msgstr "Podkop"
|
||||
|
||||
msgid "Proxy"
|
||||
msgstr "Прокси"
|
||||
|
||||
msgid "VPN"
|
||||
msgstr "VPN"
|
||||
|
||||
msgid "http://openwrt.lan:9090/ui"
|
||||
msgstr "http://openwrt.lan:9090/ui"
|
||||
|
||||
msgid "Podkop Configuration"
|
||||
msgstr "Конфигурация Podkop"
|
||||
|
||||
msgid "Active Connections"
|
||||
msgstr "Активные соединения"
|
||||
|
||||
msgid "DNSMasq Configuration"
|
||||
msgstr "Конфигурация DNSMasq"
|
||||
|
||||
msgid "Sing-box Configuration"
|
||||
msgstr "Конфигурация Sing-box"
|
||||
|
||||
msgid "Extra configurations"
|
||||
msgstr "Дополнительные конфигурации"
|
||||
|
||||
msgid "Add Section"
|
||||
msgstr "Добавить раздел"
|
||||
|
||||
msgid "No output"
|
||||
msgstr "Нет вывода"
|
||||
|
||||
msgid "Failed to copy: "
|
||||
msgstr "Не удалось скопировать: "
|
||||
|
||||
msgid "Show Config"
|
||||
msgstr "Показать конфигурацию"
|
||||
|
||||
msgid "View Logs"
|
||||
msgstr "Просмотр логов"
|
||||
|
||||
msgid "Check Connections"
|
||||
msgstr "Проверить соединения"
|
||||
|
||||
msgid "FakeIP Status"
|
||||
msgstr "Статус FakeIP"
|
||||
|
||||
msgid "Device Model: "
|
||||
msgstr "Модель устройства: "
|
||||
|
||||
msgid "OpenWrt Version: "
|
||||
msgstr "Версия OpenWrt: "
|
||||
|
||||
msgid "Check DNSMasq"
|
||||
msgstr "Проверить DNSMasq"
|
||||
|
||||
msgid "Check NFT Rules"
|
||||
msgstr "Проверить правила NFT"
|
||||
|
||||
msgid "Update Lists"
|
||||
msgstr "Обновить списки"
|
||||
|
||||
msgid "Lists Update Results"
|
||||
msgstr "Результаты обновления списков"
|
||||
|
||||
msgid "NFT Rules"
|
||||
msgstr "Правила NFT"
|
||||
|
||||
msgid "GitHub Connectivity"
|
||||
msgstr "Подключение к GitHub"
|
||||
|
||||
msgid "Check GitHub"
|
||||
msgstr "Проверить GitHub"
|
||||
|
||||
msgid "GitHub Connectivity Results"
|
||||
msgstr "Результаты проверки подключения к GitHub"
|
||||
|
||||
msgid "Sing-Box Logs"
|
||||
msgstr "Логи Sing-Box"
|
||||
|
||||
msgid "View recent sing-box logs from system journal"
|
||||
msgstr "Просмотр последних логов sing-box из системного журнала"
|
||||
|
||||
msgid "View Sing-Box Logs"
|
||||
msgstr "Просмотр логов Sing-Box"
|
||||
|
||||
msgid "Podkop Logs"
|
||||
msgstr "Логи Podkop"
|
||||
|
||||
msgid "View recent podkop logs from system journal"
|
||||
msgstr "Просмотр последних логов podkop из системного журнала"
|
||||
|
||||
msgid "View Podkop Logs"
|
||||
msgstr "Просмотр логов Podkop"
|
||||
|
||||
msgid "Active Connections"
|
||||
msgstr "Активные соединения"
|
||||
|
||||
msgid "View active sing-box network connections"
|
||||
msgstr "Просмотр активных сетевых подключений sing-box"
|
||||
|
||||
msgid "DNSMasq Configuration"
|
||||
msgstr "Конфигурация DNSMasq"
|
||||
|
||||
msgid "View current DNSMasq configuration settings"
|
||||
msgstr "Просмотр текущих настроек конфигурации DNSMasq"
|
||||
|
||||
msgid "Sing-Box Configuration"
|
||||
msgstr "Конфигурация Sing-Box"
|
||||
|
||||
msgid "Show current sing-box configuration"
|
||||
msgstr "Показать текущую конфигурацию sing-box"
|
||||
|
||||
msgid "Show Sing-Box Config"
|
||||
msgstr "Показать конфигурацию Sing-Box"
|
||||
|
||||
msgid "Diagnostic Tools"
|
||||
msgstr "Инструменты диагностики"
|
||||
|
||||
msgid "Unknown"
|
||||
msgstr "Неизвестно"
|
||||
|
||||
msgid "sing-box not running"
|
||||
msgstr "sing-box не запущен"
|
||||
|
||||
msgid "DNS not configured"
|
||||
msgstr "DNS не настроен"
|
||||
|
||||
msgid "running & enabled"
|
||||
msgstr "запущен и активирован"
|
||||
|
||||
msgid "running but disabled"
|
||||
msgstr "запущен, но деактивирован"
|
||||
|
||||
msgid "stopped but enabled"
|
||||
msgstr "остановлен, но активирован"
|
||||
|
||||
msgid "stopped & disabled"
|
||||
msgstr "остановлен и деактивирован"
|
||||
@@ -854,4 +854,226 @@ msgid "Check completed"
|
||||
msgstr ""
|
||||
|
||||
msgid "Check failed"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNS Protocol Type"
|
||||
msgstr ""
|
||||
|
||||
msgid "Select DNS protocol to use"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNS over HTTPS (DoH)"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNS over TLS (DoT)"
|
||||
msgstr ""
|
||||
|
||||
msgid "UDP (Unprotected DNS)"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNS Server"
|
||||
msgstr ""
|
||||
|
||||
msgid "Select or enter DNS server address"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNS Rewrite TTL"
|
||||
msgstr ""
|
||||
|
||||
msgid "Time in seconds for DNS record caching (default: 600)"
|
||||
msgstr ""
|
||||
|
||||
msgid "TTL value cannot be empty"
|
||||
msgstr ""
|
||||
|
||||
msgid "TTL must be a positive number"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cache File Path"
|
||||
msgstr ""
|
||||
|
||||
msgid "Select or enter path for sing-box cache file. Change this ONLY if you know what you are doing"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cache file path cannot be empty"
|
||||
msgstr ""
|
||||
|
||||
msgid "Path must be absolute (start with /)"
|
||||
msgstr ""
|
||||
|
||||
msgid "Path must end with cache.db"
|
||||
msgstr ""
|
||||
|
||||
msgid "Path must contain at least one directory (like /tmp/cache.db)"
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid path format. Must be like /tmp/cache.db"
|
||||
msgstr ""
|
||||
|
||||
msgid "Copy to Clipboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Close"
|
||||
msgstr ""
|
||||
|
||||
msgid "Loading..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Loading version information..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Checking FakeIP..."
|
||||
msgstr ""
|
||||
|
||||
msgid "timeout"
|
||||
msgstr ""
|
||||
|
||||
msgid "Current config: "
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid VLESS URL: type must be one of tcp, udp, grpc, http"
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid VLESS URL: security must be one of tls, reality, none"
|
||||
msgstr ""
|
||||
|
||||
msgid "Podkop"
|
||||
msgstr ""
|
||||
|
||||
msgid "Proxy"
|
||||
msgstr ""
|
||||
|
||||
msgid "VPN"
|
||||
msgstr ""
|
||||
|
||||
msgid "http://openwrt.lan:9090/ui"
|
||||
msgstr ""
|
||||
|
||||
msgid "Podkop Configuration"
|
||||
msgstr ""
|
||||
|
||||
msgid "Active Connections"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNSMasq Configuration"
|
||||
msgstr ""
|
||||
|
||||
msgid "Sing-box Configuration"
|
||||
msgstr ""
|
||||
|
||||
msgid "Extra configurations"
|
||||
msgstr ""
|
||||
|
||||
msgid "Add Section"
|
||||
msgstr ""
|
||||
|
||||
msgid "No output"
|
||||
msgstr ""
|
||||
|
||||
msgid "Failed to copy: "
|
||||
msgstr ""
|
||||
|
||||
msgid "Show Config"
|
||||
msgstr ""
|
||||
|
||||
msgid "View Logs"
|
||||
msgstr ""
|
||||
|
||||
msgid "Check Connections"
|
||||
msgstr ""
|
||||
|
||||
msgid "FakeIP Status"
|
||||
msgstr ""
|
||||
|
||||
msgid "Device Model: "
|
||||
msgstr ""
|
||||
|
||||
msgid "OpenWrt Version: "
|
||||
msgstr ""
|
||||
|
||||
msgid "Check DNSMasq"
|
||||
msgstr ""
|
||||
|
||||
msgid "Check NFT Rules"
|
||||
msgstr ""
|
||||
|
||||
msgid "Update Lists"
|
||||
msgstr ""
|
||||
|
||||
msgid "Lists Update Results"
|
||||
msgstr ""
|
||||
|
||||
msgid "NFT Rules"
|
||||
msgstr ""
|
||||
|
||||
msgid "GitHub Connectivity"
|
||||
msgstr ""
|
||||
|
||||
msgid "Check GitHub"
|
||||
msgstr ""
|
||||
|
||||
msgid "GitHub Connectivity Results"
|
||||
msgstr ""
|
||||
|
||||
msgid "Sing-Box Logs"
|
||||
msgstr ""
|
||||
|
||||
msgid "View recent sing-box logs from system journal"
|
||||
msgstr ""
|
||||
|
||||
msgid "View Sing-Box Logs"
|
||||
msgstr ""
|
||||
|
||||
msgid "Podkop Logs"
|
||||
msgstr ""
|
||||
|
||||
msgid "View recent podkop logs from system journal"
|
||||
msgstr ""
|
||||
|
||||
msgid "View Podkop Logs"
|
||||
msgstr ""
|
||||
|
||||
msgid "Active Connections"
|
||||
msgstr ""
|
||||
|
||||
msgid "View active sing-box network connections"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNSMasq Configuration"
|
||||
msgstr ""
|
||||
|
||||
msgid "View current DNSMasq configuration settings"
|
||||
msgstr ""
|
||||
|
||||
msgid "Sing-Box Configuration"
|
||||
msgstr ""
|
||||
|
||||
msgid "Show current sing-box configuration"
|
||||
msgstr ""
|
||||
|
||||
msgid "Show Sing-Box Config"
|
||||
msgstr ""
|
||||
|
||||
msgid "Diagnostic Tools"
|
||||
msgstr ""
|
||||
|
||||
msgid "Unknown"
|
||||
msgstr ""
|
||||
|
||||
msgid "sing-box not running"
|
||||
msgstr ""
|
||||
|
||||
msgid "DNS not configured"
|
||||
msgstr ""
|
||||
|
||||
msgid "running & enabled"
|
||||
msgstr ""
|
||||
|
||||
msgid "running but disabled"
|
||||
msgstr ""
|
||||
|
||||
msgid "stopped but enabled"
|
||||
msgstr ""
|
||||
|
||||
msgid "stopped & disabled"
|
||||
msgstr ""
|
||||
@@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=podkop
|
||||
PKG_VERSION:=0.3.11
|
||||
PKG_VERSION:=0.3.22
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=ITDog <podkop@itdog.info>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
config main 'main'
|
||||
option mode 'proxy'
|
||||
#option interface ''
|
||||
option proxy_config_type ''
|
||||
option proxy_config_type 'url'
|
||||
#option outbound_json ''
|
||||
option proxy_string ''
|
||||
option domain_list_enabled '1'
|
||||
option domain_list 'russia_inside'
|
||||
list domain_list 'russia_inside'
|
||||
option subnets_list_enabled '0'
|
||||
option custom_domains_list_type 'disable'
|
||||
option custom_domains_list_type 'disabled'
|
||||
#list custom_domains ''
|
||||
#option custom_domains_text ''
|
||||
option custom_local_domains_list_enabled '0'
|
||||
@@ -31,4 +31,7 @@ config main 'main'
|
||||
option quic_disable '0'
|
||||
option dont_touch_dhcp '0'
|
||||
option update_interval '1d'
|
||||
option custom_domains_text
|
||||
option dns_type 'doh'
|
||||
option dns_server '1.1.1.1'
|
||||
option dns_rewrite_ttl '600'
|
||||
option cache_file '/tmp/cache.db'
|
||||
@@ -24,8 +24,6 @@ EXTRA_HELP=" list_update Updating domain and subnet lists
|
||||
show_system_info Show OpenWrt version and device model
|
||||
get_sing_box_status Get sing-box status"
|
||||
|
||||
[ ! -L /usr/sbin/podkop ] && ln -s /etc/init.d/podkop /usr/sbin/podkop
|
||||
|
||||
GITHUB_RAW_URL="https://raw.githubusercontent.com/itdoginfo/allow-domains/main"
|
||||
SRS_MAIN_URL="https://github.com/itdoginfo/allow-domains/releases/latest/download"
|
||||
DOMAINS_RU_INSIDE="${GITHUB_RAW_URL}/Russia/inside-dnsmasq-nfset.lst"
|
||||
@@ -37,9 +35,10 @@ 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"
|
||||
SING_BOX_CONFIG="/etc/sing-box/config.json"
|
||||
CACHE_FILE_PATH="/tmp/cache.db"
|
||||
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"
|
||||
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"
|
||||
|
||||
start_service() {
|
||||
log "Start podkop"
|
||||
@@ -52,8 +51,12 @@ start_service() {
|
||||
exit 1
|
||||
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"
|
||||
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
|
||||
@@ -141,9 +144,7 @@ nolog() {
|
||||
}
|
||||
|
||||
main() {
|
||||
sleep 5
|
||||
|
||||
config_foreach wget_github
|
||||
sleep 3
|
||||
|
||||
mkdir -p /tmp/podkop
|
||||
|
||||
@@ -207,8 +208,9 @@ main() {
|
||||
|
||||
config_get proxy_string "main" "proxy_string"
|
||||
config_get interface "main" "interface"
|
||||
config_get outbound_json "main" "outbound_json"
|
||||
|
||||
if [ -n "$proxy_string" ] || [ -n "$interface" ]; then
|
||||
if [ -n "$proxy_string" ] || [ -n "$interface" ] || [ -n "$outbound_json" ]; then
|
||||
config_get_bool dont_touch_dhcp "main" "dont_touch_dhcp" "0"
|
||||
if [ "$dont_touch_dhcp" -eq 0 ]; then
|
||||
dnsmasq_add_resolver
|
||||
@@ -334,7 +336,7 @@ save_dnsmasq_config() {
|
||||
value=$(uci get "$key" 2>/dev/null)
|
||||
|
||||
if [ -z "$value" ]; then
|
||||
uci -q delete "$backup_key"
|
||||
uci set "$backup_key"="unset"
|
||||
else
|
||||
uci set "$backup_key"="$value"
|
||||
fi
|
||||
@@ -375,8 +377,9 @@ dnsmasq_restore() {
|
||||
fi
|
||||
|
||||
local noresolv=$(uci get dhcp.@dnsmasq[0].podkop_noresolv 2>/dev/null)
|
||||
if [ -z "$noresolv" ]; then
|
||||
if [[ "$noresolv" == "unset" ]]; then
|
||||
log "dnsmasq revert: noresolv is unset"
|
||||
uci -q delete dhcp.@dnsmasq[0].noresolv
|
||||
else
|
||||
uci set dhcp.@dnsmasq[0].noresolv="$noresolv"
|
||||
fi
|
||||
@@ -405,14 +408,17 @@ process_domains_text() {
|
||||
local tmp_file=$(mktemp)
|
||||
echo "$text" > "$tmp_file"
|
||||
|
||||
sed 's/[, ]\+/\n/g' "$tmp_file" | while IFS= read -r domain; do
|
||||
# First filter out full comment lines and remove comments after domains
|
||||
grep -v "^[[:space:]]*\/\/" "$tmp_file" | sed 's/\/\/.*$//' > "${tmp_file}.filtered"
|
||||
|
||||
sed 's/[, ]\+/\n/g' "${tmp_file}.filtered" | while IFS= read -r domain; do
|
||||
domain=$(echo "$domain" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||
if [ -n "$domain" ]; then
|
||||
sing_box_ruleset_domains "$domain" "$name"
|
||||
fi
|
||||
done
|
||||
|
||||
rm -f "$tmp_file"
|
||||
rm -f "$tmp_file" "${tmp_file}.filtered"
|
||||
}
|
||||
|
||||
process_subnets_text() {
|
||||
@@ -422,7 +428,10 @@ process_subnets_text() {
|
||||
local tmp_file=$(mktemp)
|
||||
echo "$text" > "$tmp_file"
|
||||
|
||||
sed 's/[, ]\+/\n/g' "$tmp_file" | while IFS= read -r subnet; do
|
||||
# First filter out full comment lines and remove comments after subnets
|
||||
grep -v "^[[:space:]]*\/\/" "$tmp_file" | sed 's/\/\/.*$//' > "${tmp_file}.filtered"
|
||||
|
||||
sed 's/[, ]\+/\n/g' "${tmp_file}.filtered" | while IFS= read -r subnet; do
|
||||
subnet=$(echo "$subnet" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||
if [ -n "$subnet" ]; then
|
||||
if ! echo "$subnet" | grep -q "/"; then
|
||||
@@ -432,66 +441,9 @@ process_subnets_text() {
|
||||
fi
|
||||
done
|
||||
|
||||
rm -f "$tmp_file"
|
||||
rm -f "$tmp_file" "${tmp_file}.filtered"
|
||||
}
|
||||
|
||||
wget_github() {
|
||||
local count_nslookup=0
|
||||
local count_curl=0
|
||||
|
||||
config_get domain_list_enabled "$section" "domain_list_enabled"
|
||||
config_get subnets_list_enabled "$section" "subnets_list_enabled"
|
||||
config_get custom_download_domains_list_enabled "$section" "custom_download_domains_list_enabled"
|
||||
config_get custom_download_subnets_list_enabled "$section" "custom_download_subnets_list_enabled"
|
||||
|
||||
if [ "$domain_list_enabled" -eq 1 ] || [ "$subnets_list_enabled" -eq 1 ] ||
|
||||
[ "$custom_download_domains_list_enabled" -eq 1 ] || [ "$custom_download_subnets_list_enabled" -eq 1 ] ; then
|
||||
|
||||
while true; do
|
||||
if ! nslookup google.com >/dev/null 2>&1; then
|
||||
log "DNS not working. Retrying... [$count_nslookup sec]"
|
||||
count_nslookup=$((count_nslookup + 1))
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
||||
if [ $count_nslookup -lt 30 ]; then
|
||||
sleep_interval=1
|
||||
elif [ $count_nslookup -ge 30 ] && [ $count_nslookup -lt 60 ]; then
|
||||
sleep_interval=5
|
||||
elif [ $count_nslookup -ge 60 ] && [ $count_nslookup -lt 90 ]; then
|
||||
sleep_interval=10
|
||||
else
|
||||
sleep_interval=30
|
||||
fi
|
||||
|
||||
sleep $sleep_interval
|
||||
done
|
||||
|
||||
while true; do
|
||||
if ! curl -m 3 github.com; then
|
||||
log "GitHub is not available. Check the internet availability [$count_curl sec]"
|
||||
count_curl=$((count_curl + 1))
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
||||
if [ $count_curl -lt 30 ]; then
|
||||
sleep_interval=1
|
||||
elif [ $count_curl -ge 30 ] && [ $count_curl -lt 60 ]; then
|
||||
sleep_interval=5
|
||||
elif [ $count_curl -ge 60 ] && [ $count_curl -lt 90 ]; then
|
||||
sleep_interval=10
|
||||
else
|
||||
sleep_interval=30
|
||||
fi
|
||||
|
||||
sleep $sleep_interval
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
add_cron_job() {
|
||||
## Future: make a check so that it doesn't recreate many times
|
||||
config_get domain_list_enabled "$section" "domain_list_enabled"
|
||||
@@ -545,6 +497,17 @@ list_update() {
|
||||
config_foreach process_subnet_for_section_remote
|
||||
}
|
||||
|
||||
find_working_resolver() {
|
||||
local resolver_found=""
|
||||
for resolver in $DNS_RESOLVERS; do
|
||||
if nslookup $TEST_DOMAIN $resolver >/dev/null 2>&1; then
|
||||
echo "$resolver"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
echo "8.8.8.8"
|
||||
return 1
|
||||
}
|
||||
|
||||
# sing-box funcs
|
||||
|
||||
@@ -622,32 +585,86 @@ sing_box_inbound_proxy() {
|
||||
}
|
||||
|
||||
sing_box_dns() {
|
||||
local dns_type
|
||||
local dns_server
|
||||
local resolver_tag="resolver"
|
||||
|
||||
config_get dns_type "main" "dns_type" "doh"
|
||||
config_get dns_server "main" "dns_server" "1.1.1.1"
|
||||
|
||||
local server_json
|
||||
local is_ip=$(echo "$dns_server" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' && echo "1" || echo "0")
|
||||
|
||||
if [ "$is_ip" = "0" ]; then
|
||||
log "Finding working DNS resolver"
|
||||
local dns_resolver=$(find_working_resolver)
|
||||
log "Found working resolver: $dns_resolver"
|
||||
fi
|
||||
|
||||
log "Configure DNS in sing-box"
|
||||
|
||||
server_json=$(jq -n \
|
||||
--arg type "$dns_type" \
|
||||
--arg server "$dns_server" \
|
||||
--arg resolver "$resolver_tag" \
|
||||
--arg is_ip "$is_ip" \
|
||||
'{
|
||||
"servers": [
|
||||
{
|
||||
"tag": "dns-server",
|
||||
"address": (
|
||||
if $type == "doh" then
|
||||
"https://" + $server + "/dns-query"
|
||||
elif $type == "dot" then
|
||||
"tls://" + $server
|
||||
else
|
||||
$server
|
||||
end
|
||||
),
|
||||
"detour": "direct-out"
|
||||
} + (
|
||||
if $is_ip == "0" then
|
||||
{"address_resolver": $resolver}
|
||||
else
|
||||
{}
|
||||
end
|
||||
)
|
||||
]
|
||||
}')
|
||||
|
||||
if [ "$is_ip" = "0" ]; then
|
||||
server_json=$(echo "$server_json" | jq \
|
||||
--arg resolver "$resolver_tag" \
|
||||
--arg address "$dns_resolver" \
|
||||
'.servers += [{
|
||||
"tag": $resolver,
|
||||
"address": $address
|
||||
}]')
|
||||
fi
|
||||
|
||||
server_json=$(echo "$server_json" | jq '.servers += [{"tag": "fakeip-server", "address": "fakeip"}]')
|
||||
|
||||
jq \
|
||||
--arg FAKEIP "$FAKEIP" \
|
||||
'.dns = {
|
||||
"strategy": "ipv4_only",
|
||||
"fakeip": {
|
||||
"enabled": true,
|
||||
"inet4_range": $FAKEIP
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"tag": "cloudflare-doh-server",
|
||||
"address": "https://1.1.1.1/dns-query",
|
||||
"detour": "direct-out"
|
||||
--argjson dns_config "$server_json" \
|
||||
--arg fakeip "$FAKEIP" \
|
||||
'.dns = {
|
||||
"strategy": "ipv4_only",
|
||||
"fakeip": {
|
||||
"enabled": true,
|
||||
"inet4_range": $fakeip
|
||||
},
|
||||
{
|
||||
"tag": "fakeip-server",
|
||||
"address": "fakeip"
|
||||
}
|
||||
]
|
||||
}' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
"servers": $dns_config.servers
|
||||
}' $SING_BOX_CONFIG > /tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
}
|
||||
|
||||
sing_box_dns_rule_fakeip() {
|
||||
log "Configure fakeip route in sing-box"
|
||||
local rewrite_ttl
|
||||
config_get rewrite_ttl "main" "dns_rewrite_ttl" "600"
|
||||
|
||||
log "Configure fakeip route in sing-box and set TTL to $rewrite_ttl seconds"
|
||||
|
||||
jq \
|
||||
--arg ttl "$rewrite_ttl" \
|
||||
'.dns += {
|
||||
"rules": [
|
||||
{
|
||||
@@ -664,6 +681,8 @@ sing_box_dns_rule_fakeip() {
|
||||
},
|
||||
{
|
||||
"server": "fakeip-server",
|
||||
"domain": "",
|
||||
"rewrite_ttl": ($ttl | tonumber),
|
||||
"rule_set": []
|
||||
}
|
||||
]
|
||||
@@ -691,14 +710,17 @@ sing_box_dns_rule_fakeip_section() {
|
||||
}
|
||||
|
||||
sing_box_cache_file() {
|
||||
log "Configure cache.db in sing-box"
|
||||
config_get cache_file "main" "cache_file" "/tmp/cache.db"
|
||||
|
||||
log "Configure sing-box cache.db path"
|
||||
|
||||
jq \
|
||||
--arg CACHE_FILE_PATH "$CACHE_FILE_PATH" \
|
||||
--arg cache_file "$cache_file" \
|
||||
'.experimental = {
|
||||
"cache_file": {
|
||||
"enabled": true,
|
||||
"store_fakeip": true,
|
||||
"path": $CACHE_FILE_PATH
|
||||
"path": $cache_file
|
||||
}
|
||||
}' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
}
|
||||
@@ -722,17 +744,26 @@ sing_box_outdound() {
|
||||
config_get outbound_json $section "outbound_json"
|
||||
if [ -n "$outbound_json" ]; then
|
||||
log "Using JSON outbound configuration"
|
||||
sing_box_config_outbound_json "$outbound_json"
|
||||
sing_box_config_outbound_json "$outbound_json" "$section"
|
||||
else
|
||||
log "Missing outbound JSON configuration"
|
||||
return
|
||||
fi
|
||||
else
|
||||
config_get proxy_string $section "proxy_string"
|
||||
if [[ "$proxy_string" =~ ^ss:// ]]; then
|
||||
sing_box_config_shadowsocks "$section" "$proxy_string"
|
||||
elif [[ "$proxy_string" =~ ^vless:// ]]; then
|
||||
sing_box_config_vless "$section" "$proxy_string"
|
||||
|
||||
# Extract the first non-comment line as the active configuration
|
||||
active_proxy_string=$(echo "$proxy_string" | grep -v "^[[:space:]]*\/\/" | head -n 1)
|
||||
|
||||
if [ -z "$active_proxy_string" ]; then
|
||||
log "No active proxy configuration found"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$active_proxy_string" =~ ^ss:// ]]; then
|
||||
sing_box_config_shadowsocks "$section" "$active_proxy_string"
|
||||
elif [[ "$active_proxy_string" =~ ^vless:// ]]; then
|
||||
sing_box_config_vless "$section" "$active_proxy_string"
|
||||
else
|
||||
log "Unsupported proxy type or missing configuration"
|
||||
return
|
||||
@@ -804,40 +835,35 @@ sing_box_config_check() {
|
||||
|
||||
sing_box_config_outbound_json() {
|
||||
local json_config="$1"
|
||||
local listen_port="$2"
|
||||
local section="$2"
|
||||
|
||||
cat > /tmp/base_config.json << EOF
|
||||
{
|
||||
"log": {
|
||||
"level": "warn"
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"type": "tproxy",
|
||||
"listen": "::",
|
||||
"listen_port": $listen_port,
|
||||
"tcp_fast_open": true,
|
||||
"udp_fragment": true
|
||||
},
|
||||
{
|
||||
"tag": "dns-in",
|
||||
"type": "direct",
|
||||
"listen": "127.0.0.42",
|
||||
"listen_port": 53
|
||||
}
|
||||
],
|
||||
"outbounds": [],
|
||||
"route": {
|
||||
"auto_detect_interface": true
|
||||
}
|
||||
# Create new object with tag first, then merge with the rest of the config
|
||||
local modified_config=$(echo "$json_config" | jq --arg section "$section" \
|
||||
'del(.tag) | {"tag": $section} + .')
|
||||
|
||||
jq --argjson outbound "$modified_config" \
|
||||
--arg section "$section" \
|
||||
'. |
|
||||
.outbounds |= (
|
||||
map(
|
||||
if .tag == $section then
|
||||
$outbound
|
||||
else . end
|
||||
) +
|
||||
(
|
||||
if (map(select(.tag == $section)) | length) == 0 then
|
||||
[$outbound]
|
||||
else [] end
|
||||
)
|
||||
)' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log "Outbound config updated successfully"
|
||||
else
|
||||
log "Error: Invalid JSON config generated"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
EOF
|
||||
|
||||
jq --argjson outbound "$json_config" '.outbounds += [$outbound]' /tmp/base_config.json > $SING_BOX_CONFIG
|
||||
rm -f /tmp/base_config.json
|
||||
}
|
||||
|
||||
|
||||
|
||||
sing_box_config_shadowsocks() {
|
||||
local section="$1"
|
||||
@@ -909,7 +935,7 @@ sing_box_config_vless() {
|
||||
get_param() {
|
||||
local param="$1"
|
||||
local value=$(echo "$STRING" | sed -n "s/.*[?&]$param=\([^&?#]*\).*/\1/p")
|
||||
value=$(echo "$value" | sed 's/%2F/\//g; s/%2C/,/g; s/%3D/=/g; s/%2B/+/g; s/%20/ /g' | tr -d '\n' | tr -d '\r')
|
||||
value=$(echo "$value" | sed 's/%2F/\//g; s/%2C/,/g; s/%3D/=/g; s/%2B/+/g; s/%20/ /g; s/%3B/;/g' | tr -d '\n' | tr -d '\r')
|
||||
echo "$value"
|
||||
}
|
||||
|
||||
@@ -1207,7 +1233,7 @@ list_subnets_download() {
|
||||
esac
|
||||
|
||||
local filename=$(basename "$URL")
|
||||
wget -q -O "/tmp/podkop/$filename" "$URL"
|
||||
wget -O "/tmp/podkop/$filename" "$URL"
|
||||
|
||||
while IFS= read -r subnet; do
|
||||
if [ "$service" = "discord" ]; then
|
||||
@@ -1280,10 +1306,16 @@ sing_box_rule_preset() {
|
||||
config_get custom_subnets_list_enabled "$section" "custom_subnets_list_enabled"
|
||||
config_get custom_local_domains_list_enabled "$section" "custom_local_domains_list_enabled"
|
||||
config_get custom_download_domains_list_enabled "$section" "custom_download_domains_list_enabled"
|
||||
config_get custom_download_subnets_list_enabled "$section" "custom_download_subnets_list_enabled"
|
||||
|
||||
if [ "$custom_domains_list_type" != "disabled" ] || [ "$custom_subnets_list_enabled" != "disabled" ] ||
|
||||
[ "$custom_local_domains_list_enabled" = "1" ] || [ "$custom_download_domains_list_enabled" = "1" ]; then
|
||||
[ "$custom_local_domains_list_enabled" = "1" ] || [ "$custom_download_domains_list_enabled" = "1" ] ||
|
||||
[ "$custom_download_subnets_list_enabled" = "1" ]; then
|
||||
sing_box_rules "$section" "$section"
|
||||
fi
|
||||
|
||||
if [ "$custom_domains_list_type" != "disabled" ] || [ "$custom_local_domains_list_enabled" = "1" ] ||
|
||||
[ "$custom_download_domains_list_enabled" = "1" ]; then
|
||||
sing_box_dns_rule_fakeip_section "$section" "$section"
|
||||
fi
|
||||
|
||||
@@ -1301,8 +1333,13 @@ list_custom_local_domains_create() {
|
||||
local filename=$(basename "$local_file" | cut -d. -f1)
|
||||
|
||||
while IFS= read -r domain; do
|
||||
log "From local file: $domain"
|
||||
sing_box_ruleset_domains $domain $section
|
||||
domain=$(echo "$domain" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||
if [ -n "$domain" ] && echo "$domain" | grep -E -q '^([a-zA-Z0-9][-a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$'; then
|
||||
log "Added $domain from local file"
|
||||
sing_box_ruleset_domains "$domain" "$section"
|
||||
else
|
||||
log "Invalid domain skipped: $domain"
|
||||
fi
|
||||
done <"$local_file"
|
||||
}
|
||||
|
||||
@@ -1386,22 +1423,23 @@ process_all_traffic_for_section() {
|
||||
if [ "$all_traffic_from_ip_enabled" -eq "1" ]; then
|
||||
log "Adding an IP to redirect all traffic"
|
||||
config_list_foreach $section all_traffic_ip list_all_traffic_from_ip
|
||||
config_list_foreach $section all_traffic_ip sing_box_rules_source_ip_cidr "$section" "$all_traffic_ip"
|
||||
config_list_foreach $section all_traffic_ip sing_box_rules_source_ip_cidr $all_traffic_ip $section
|
||||
fi
|
||||
}
|
||||
|
||||
sing_box_rules_source_ip_cidr() {
|
||||
log "Configure source_ip_cidr rule in sing-box"
|
||||
local outbound="$2"
|
||||
local source_ip_cidr="$1"
|
||||
local outbound="$2"
|
||||
|
||||
local current_source_ip_cidr=$(jq -r '.route.rules[] | select(.outbound == "'"$outbound"'" and .action == "route" and (.rule_set | not))' $SING_BOX_CONFIG)
|
||||
|
||||
local current_source_ip_cidr=$(jq -r ".route.rules[] | select(.outbound == \"$outbound\" and .source_ip_cidr) | .rule_set" $SING_BOX_CONFIG)
|
||||
|
||||
if [[ -n "$current_source_ip_cidr" ]]; then
|
||||
jq \
|
||||
--arg source_ip_cidr "$source_ip_cidr" \
|
||||
--arg outbound "$outbound" \
|
||||
'(.route.rules[] | select(.outbound == $outbound) | .source_ip_cidr) += [$source_ip_cidr]' \
|
||||
'(.route.rules[] | select(.outbound == $outbound and .action == "route" and (.rule_set | not)) | .source_ip_cidr) += [$source_ip_cidr]' \
|
||||
$SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
else
|
||||
jq \
|
||||
@@ -1411,7 +1449,8 @@ sing_box_rules_source_ip_cidr() {
|
||||
{
|
||||
"inbound": ["tproxy-in"],
|
||||
"source_ip_cidr": [$source_ip_cidr],
|
||||
"outbound": $outbound
|
||||
"outbound": $outbound,
|
||||
"action": "route"
|
||||
}
|
||||
] + .route.rules' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
fi
|
||||
@@ -1701,6 +1740,7 @@ get_sing_box_status() {
|
||||
local enabled=0
|
||||
local status=""
|
||||
local version=""
|
||||
local dns_configured=0
|
||||
|
||||
# Check if service is enabled
|
||||
if [ -x /etc/rc.d/S99sing-box ]; then
|
||||
@@ -1713,6 +1753,12 @@ get_sing_box_status() {
|
||||
version=$(sing-box version | head -n 1 | awk '{print $3}')
|
||||
fi
|
||||
|
||||
# Check DNS configuration
|
||||
local dns_server=$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)
|
||||
if [ "$dns_server" = "127.0.0.42" ]; then
|
||||
dns_configured=1
|
||||
fi
|
||||
|
||||
# Format status message
|
||||
if [ $running -eq 1 ]; then
|
||||
if [ $enabled -eq 1 ]; then
|
||||
@@ -1728,7 +1774,7 @@ get_sing_box_status() {
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "{\"running\":$running,\"enabled\":$enabled,\"status\":\"$status\"}"
|
||||
echo "{\"running\":$running,\"enabled\":$enabled,\"status\":\"$status\",\"dns_configured\":$dns_configured}"
|
||||
}
|
||||
|
||||
get_status() {
|
||||
@@ -1780,10 +1826,8 @@ sing_box_add_secure_dns_probe_domain() {
|
||||
--arg override "$override_address" \
|
||||
'.dns.rules |= map(
|
||||
if .server == "fakeip-server" then
|
||||
{
|
||||
"server": .server,
|
||||
"domain": $domain,
|
||||
"rule_set": .rule_set
|
||||
. + {
|
||||
"domain": $domain
|
||||
}
|
||||
else
|
||||
.
|
||||
|
||||
Reference in New Issue
Block a user