Compare commits

..

16 Commits

Author SHA1 Message Date
itdoginfo
e86bffb720 v0.3.8 2025-02-17 16:04:34 +03:00
itdoginfo
fb65b63639 Merge pull request #25 from VizzleTF/main
docs(ru): add new translations for podkop configuration
2025-02-17 15:51:19 +03:00
itdoginfo
daf7e30ed1 dnsmasq add 8.8.8.8. Validate domain_list 2025-02-17 15:22:55 +03:00
itdoginfo
dd62ecfbeb Check sing-box 2025-02-17 13:20:28 +03:00
Ivan K
41cb8cd650 Merge branch 'itdoginfo:main' into main 2025-02-17 13:08:35 +03:00
Ivan K
b7ad256986 docs(ru): add new translations for podkop configuration 2025-02-17 13:07:11 +03:00
itdoginfo
f88ffa1893 Fix install logic 2025-02-17 12:44:48 +03:00
itdoginfo
6f604ca765 Update 2025-02-16 17:53:14 +03:00
itdoginfo
52c6eeae12 Fix version 2025-02-16 17:52:57 +03:00
itdoginfo
778f2897bc Fix check iptables 2025-02-16 17:41:58 +03:00
itdoginfo
ca7bb77356 Fix 2025-02-16 16:57:16 +03:00
itdoginfo
da8195b795 Fix migrate 2025-02-16 15:59:07 +03:00
itdoginfo
98129720bb rm until 2025-02-16 14:29:50 +03:00
itdoginfo
3c1865c8a3 Expanding checkes. DNS 127.0.0.42. QUIC disable. Some fixes 2025-02-16 14:18:19 +03:00
itdoginfo
77ac728d47 Check sing-box 2025-02-16 12:16:43 +03:00
itdoginfo
1b5cfa3371 Move check sing-box to start 2025-02-15 23:32:18 +03:00
9 changed files with 312 additions and 90 deletions

View File

@@ -2,11 +2,13 @@
- Это альфа версия, которая находится в активной разработке. Из версии в версию что-то может меняться.
- Основной функционал работает, но побочные штуки сейчас могут сбоить.
- При обновлении всегда заходите в конфигурацию и проверяйте свои настройки. Конфигурация может измениться.
- При обновлении **обязатально** сбрасывайте кэш LuCI.
- Также при обновлении всегда заходите в конфигурацию и проверяйте свои настройки. Конфигурация может измениться.
- Необходимо минимум 15МБ свободного места на роутере. Роутерами с флешками на 16МБ сразу мимо.
- При старте программы редактируется конфиг Dnsmasq.
- Podkop редактирует конфиг sing-box. Обязательно сохраните ваш конфиг sing-box перед установкой, если он вам нужен.
- Информация здесь может быть устаревшей. Все изменения фиксируются в телеграм-чате https://t.me/itdogchat - топик **Podkop**.
- Если у вас не что-то не работает, то следуюет сходить в телеграм чат, прочитать закрепы и выполнить что там написано..
- Если у вас установлен Getdomains, его следует удалить.
# Удаление GetDomains скриптом
@@ -18,7 +20,8 @@ sh <(wget -O - https://raw.githubusercontent.com/itdoginfo/domain-routing-openwr
# Установка Podkop
Пакет работает на всех архитектурах.
Тестировался на OpenWrt 23.05 и OpenWrt 24.10.
Тестировался на **ванильной** OpenWrt 23.05 и OpenWrt 24.10.
На FriendlyWrt 23.05 присуствуют зависимости от iptables, которые ломают tproxy. Если у вас появляется warning про это в логах, следуйте инструкции по приведённой там ссылке.
Поддержки APK на данный момент нет. APK будет сделан после того как разгребу основное.
@@ -149,6 +152,7 @@ Luci: Services/podkop
- [ ] Сделать галку запрещающую подкопу редачить dhcp. Допилить в исключение вместе с пустыми полями proxy и vpn
- [ ] Валидации предустановленных значений. Если прописаны другие, то вывод в лог о неизвестной переменной и продолжение работы
- [ ] Добавление в список доменов домены первого уровня (LuCI)
- [ ] Проверка, что версия в makefile совпадает с тегом
Приоритет 2
- [x] Списки доменов и подсетей с роутера

View File

@@ -11,39 +11,14 @@ mkdir -p "$DOWNLOAD_DIR"
main() {
check_system
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"
break
else
echo "Download error $filename. Retry..."
rm -f "$filepath"
fi
attempt=$((attempt+1))
done
done
echo "opkg update"
sing_box
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 proxy or tunnels\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
@@ -68,28 +43,59 @@ main() {
add_tunnel
fi
opkg install $DOWNLOAD_DIR/podkop*.ipk
opkg install $DOWNLOAD_DIR/luci-app-podkop*.ipk
wget -qO- "$REPO" | grep -o 'https://[^"[:space:]]*\.ipk' | while read -r url; do
filename=$(basename "$url")
filepath="$DOWNLOAD_DIR/$filename"
echo "Русский язык интерфейса ставим? y/n (Need a Russian translation?)"
while true; do
read -r -p '' RUS
case $RUS in
y)
opkg install $DOWNLOAD_DIR/luci-i18n-podkop-ru*.ipk
break
;;
attempt=0
while [ $attempt -lt $COUNT ]; do
if [ -f "$filepath" ] && [ -s "$filepath" ]; then
echo "$filename has already been uploaded"
break
fi
n)
break
;;
*)
echo "Please enter y or n"
;;
esac
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
if [ "$IS_SHOULD_RESTART_NETWORK" ]; then
@@ -99,7 +105,7 @@ main() {
}
add_tunnel() {
echo "Will you be using Wireguard, AmneziaWG, OpenVPN, OpenConnect? If yes, select a number and they will be automatically installed"
printf "\033[32;1mWill you be using Wireguard, AmneziaWG, OpenVPN, OpenConnect? If yes, select a number and they will be automatically installed\033[0m "
echo "1) Wireguard"
echo "2) AmneziaWG"
echo "3) OpenVPN"
@@ -151,7 +157,7 @@ add_tunnel() {
;;
5)
echo "Skip. Use this if you're installing an upgrade."
echo "Installation without additional dependencies."
break
;;
@@ -389,18 +395,37 @@ check_system() {
echo "Router model: $MODEL"
# Check available space
AVAILABLE_SPACE=$(df /tmp | awk 'NR==2 {print $4}')
AVAILABLE_SPACE=$(df /overlay | awk 'NR==2 {print $4}')
REQUIRED_SPACE=15360 # 15MB in KB
echo "Available space: $((AVAILABLE_SPACE/1024))MB"
echo "Required space: $((REQUIRED_SPACE/1024))MB"
if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]; then
echo "Error: Insufficient space in /tmp"
printf "\033[31;1mError: Insufficient space in flash\033[0m\n"
echo "Available: $((AVAILABLE_SPACE/1024))MB"
echo "Required: $((REQUIRED_SPACE/1024))MB"
exit 1
fi
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
}
sing_box() {
if ! opkg list-installed | grep -q "^sing-box"; then
return
fi
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
opkg remove sing-box
fi
}
main

View File

@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-podkop
PKG_VERSION:=0.3.4
PKG_VERSION:=0.3.8
PKG_RELEASE:=1
LUCI_TITLE:=LuCI podkop app

View File

@@ -404,13 +404,16 @@ return view.extend({
o = s.taboption('additional', form.Flag, 'yacd', _('Yacd enable'), _('http://openwrt.lan:9090/ui'));
o.default = '0';
o.depends('mode', 'proxy');
o.rmempty = false;
o.ucisection = 'main';
o = s.taboption('additional', form.Flag, 'exclude_ntp', _('Exclude NTP'), _('For issues with open connections sing-box'));
o.default = '0';
o.depends('mode', 'proxy');
o.rmempty = false;
o.ucisection = 'main';
o = s.taboption('additional', form.Flag, 'quic_disable', _('QUIC disable'), _('For issues with the video stream'));
o.default = '0';
o.rmempty = false;
o.ucisection = 'main';

View File

@@ -329,4 +329,55 @@ msgid "View Logs"
msgstr "Просмотр логов"
msgid "Failed to copy logs: "
msgstr "Ошибка копирования логов: "
msgstr "Ошибка копирования логов: "
msgid "Show Config"
msgstr "Показать конфигурацию"
msgid "Show current podkop configuration with masked sensitive data"
msgstr "Показать текущую конфигурацию podkop с маскированными конфиденциальными данными"
msgid "Podkop Configuration"
msgstr "Конфигурация Podkop"
msgid "Update lists"
msgstr "Обновить списки"
msgid "Update all lists in config"
msgstr "Обновить все списки в конфигурации"
msgid "List Update"
msgstr "Обновление списков"
msgid "Lists will be updated in background. You can check the progress in system logs."
msgstr "Списки будут обновлены в фоновом режиме. Вы можете проверить прогресс в системных логах."
msgid "Extra configurations"
msgstr "Дополнительные конфигурации"
msgid "Extra configuration"
msgstr "Дополнительная конфигурация"
msgid "Add Section"
msgstr "Добавить раздел"
msgid "QUIC disable"
msgstr "Отключить QUIC"
msgid "For issues with the video stream"
msgstr "Для проблем с видеопотоком"
msgid "Community Lists"
msgstr "Списки сообщества"
msgid "Local Domain Lists"
msgstr "Локальные списки доменов"
msgid "Use the list from the router filesystem"
msgstr "Использовать список из файловой системы роутера"
msgid "Local Domain Lists Path"
msgstr "Путь к локальным спискам доменов"
msgid "Enter to the list file path"
msgstr "Введите путь к файлу списка"

View File

@@ -329,4 +329,55 @@ msgid "View Logs"
msgstr ""
msgid "Failed to copy logs: "
msgstr ""
msgid "Show Config"
msgstr ""
msgid "Show current podkop configuration with masked sensitive data"
msgstr ""
msgid "Podkop Configuration"
msgstr ""
msgid "Update lists"
msgstr ""
msgid "Update all lists in config"
msgstr ""
msgid "List Update"
msgstr ""
msgid "Lists will be updated in background. You can check the progress in system logs."
msgstr ""
msgid "Extra configurations"
msgstr ""
msgid "Extra configuration"
msgstr ""
msgid "Add Section"
msgstr ""
msgid "QUIC disable"
msgstr ""
msgid "For issues with the video stream"
msgstr ""
msgid "Community Lists"
msgstr ""
msgid "Local Domain Lists"
msgstr ""
msgid "Use the list from the router filesystem"
msgstr ""
msgid "Local Domain Lists Path"
msgstr ""
msgid "Enter to the list file path"
msgstr ""

View File

@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=podkop
PKG_VERSION:=0.3.4
PKG_VERSION:=0.3.8
PKG_RELEASE:=1
PKG_MAINTAINER:=ITDog <podkop@itdog.info>

View File

@@ -28,5 +28,6 @@ config main 'main'
option yacd '0'
option socks5 '0'
option exclude_ntp '0'
option quic_disable '0'
option update_interval '1d'
option custom_domains_text

View File

@@ -35,10 +35,32 @@ 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"
start_service() {
log "Start podkop"
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
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 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
if ! ip addr | grep -q "br-lan"; then
log "Interface br-lan not found"
exit 1
fi
migration
config_foreach process_validate_service
procd_open_instance
procd_set_param command /bin/sh -c "/etc/init.d/podkop main &"
procd_set_param stdout 1
@@ -111,26 +133,12 @@ nolog() {
}
main() {
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
echo "The version of sing-box ($sing_box_version) is lower than the minimum version. Update sing-box: opkg update && opkg install sing-box"
exit 1
fi
migration
sleep 5
config_foreach wget_github
mkdir -p /tmp/podkop
if ! ip addr | grep -q "br-lan"; then
log "Interface br-lan not found"
fi
# base
route_table_rule_mark
create_nft_table
@@ -178,6 +186,12 @@ main() {
nft insert rule inet PodkopTable mangle udp dport 123 return
fi
config_get_bool quic_disable "main" "quic_disable" "0"
if [ "$quic_disable" -eq 1 ]; then
log "Rule for disable QUIC"
sing_box_quic_reject
fi
sing_box_config_check
/etc/init.d/sing-box restart
/etc/init.d/sing-box enable
@@ -190,18 +204,69 @@ main() {
fi
}
# Migrations funcs
# Migrations and validation funcs
migration() {
# list migrate
grep -q "list domain_list 'ru_inside'" /etc/config/podkop && sed -i "s/list domain_list 'ru_inside'/list domain_list 'russia_inside'/" /etc/config/podkop
grep -q "list domain_list 'ru_outside'" /etc/config/podkop && sed -i "s/list domain_list 'ru_outside'/list domain_list 'russia_outside'/" /etc/config/podkop
grep -q "list domain_list 'ua'" /etc/config/podkop && sed -i "s/list domain_list 'ua'/list domain_list 'ukraine_inside'/" /etc/config/podkop
local CONFIG="/etc/config/podkop"
if grep -q "ru_inside" $CONFIG; then
log "Depricated list found: ru_inside"
sed -i '/ru_inside/d' $CONFIG
fi
if grep -q "list domain_list 'ru_outside'" $CONFIG; then
log "Depricated list found: sru_outside"
sed -i '/ru_outside/d' $CONFIG
fi
if grep -q "list domain_list 'ua'" $CONFIG; then
log "Depricated list found: ua"
sed -i '/ua/d' $CONFIG
fi
# Subnet list
if grep -q "list subnets" $CONFIG; then
log "Depricated second section found"
sed -i '/list subnets/d' $CONFIG
fi
# second remove
grep -q "config second 'second'" /etc/config/podkop && sed -i '/second/d' /etc/config/podkop
if grep -q "config second 'second'" $CONFIG; then
log "Depricated second section found"
sed -i '/second/d' $CONFIG
fi
# cron update
grep -qE "^\s*option update_interval '[0-9*/,-]+( [0-9*/,-]+){4}'" /etc/config/podkop && sed -i "s|^\(\s*option update_interval\) '[0-9*/,-]\+\( [0-9*/,-]\+\)\{4\}'|\1 '1d'|" /etc/config/podkop
if grep -qE "^\s*option update_interval '[0-9*/,-]+( [0-9*/,-]+){4}'" $CONFIG; then
log "Depricated update_interval"
sed -i "s|^\(\s*option update_interval\) '[0-9*/,-]\+\( [0-9*/,-]\+\)\{4\}'|\1 '1d'|" $CONFIG
fi
# dnsmasq https
if grep -q "^filter-rr=HTTPS" "/etc/dnsmasq.conf"; then
log "Found and removed filter-rr=HTTPS in dnsmasq config"
sed -i '/^filter-rr=HTTPS/d' "/etc/dnsmasq.conf"
fi
}
validate_service() {
local domain="$1"
for valid_service in $VALID_SERVICES; do
if [ "$domain" = "$valid_service" ]; then
return 0
fi
done
log "Invalid service in domain_list: $domain. Exiting. Check config and LuCI cache"
exit 1
}
process_validate_service() {
config_get_bool domain_list_enabled "$section" "domain_list_enabled" "0"
if [ "$domain_list_enabled" -eq 1 ]; then
config_list_foreach "$section" domain_list validate_service
fi
}
# Main funcs
@@ -252,12 +317,10 @@ dnsmasq_add() {
uci set dhcp.@dnsmasq[0].filter_aaaa="1"
uci set dhcp.@dnsmasq[0].cachesize="0"
uci -q delete dhcp.@dnsmasq[0].server
uci add_list dhcp.@dnsmasq[0].server="127.0.0.1#5353"
uci add_list dhcp.@dnsmasq[0].server="127.0.0.42"
uci add_list dhcp.@dnsmasq[0].server='/use-application-dns.net/'
uci commit dhcp
grep -q "filter-rr=HTTPS" /etc/dnsmasq.conf || echo "filter-rr=HTTPS" >> /etc/dnsmasq.conf
/etc/init.d/dnsmasq restart
}
@@ -267,10 +330,9 @@ dnsmasq_rm() {
uci set dhcp.@dnsmasq[0].filter_aaaa="0"
uci set dhcp.@dnsmasq[0].cachesize="1000"
uci -q delete dhcp.@dnsmasq[0].server
uci add_list dhcp.@dnsmasq[0].server="8.8.8.8"
uci commit dhcp
sed -i '/filter-rr=HTTPS/d' /etc/dnsmasq.conf
/etc/init.d/dnsmasq restart
}
@@ -484,8 +546,8 @@ sing_box_inbound_proxy() {
{
"tag": "dns-in",
"type": "direct",
"listen": "127.0.0.1",
"listen_port": 5353
"listen": "127.0.0.42",
"listen_port": 53
}
],
"outbounds": [
@@ -526,6 +588,12 @@ sing_box_dns_rule_fakeip() {
jq \
'.dns += {
"rules": [
{
"query_type": [
"HTTPS"
],
"action": "reject"
},
{
"server": "fakeip-server",
"rule_set": []
@@ -686,8 +754,8 @@ sing_box_config_outbound_json() {
{
"tag": "dns-in",
"type": "direct",
"listen": "127.0.0.1",
"listen_port": 5353
"listen": "127.0.0.42",
"listen_port": 53
}
],
"outbounds": [],
@@ -1111,6 +1179,25 @@ sing_box_rules() {
fi
}
sing_box_quic_reject() {
local quic_rule_exists=$(jq -e '.route.rules[] | select(.protocol == "quic" and .action == "reject")' "$SING_BOX_CONFIG")
if [[ -z "$quic_rule_exists" ]]; then
jq '
.route.rules |= (
reduce .[] as $rule ([];
if $rule.protocol == "dns" and $rule.action == "hijack-dns" then
. + [$rule, {"protocol": "quic", "action": "reject"}]
else
. + [$rule]
end
)
)' "$SING_BOX_CONFIG" >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json "$SING_BOX_CONFIG"
log "QUIC reject rule added successfully"
fi
}
process_remote_ruleset() {
config_get_bool domain_list_enabled "$section" "domain_list_enabled" "0"
if [ "$domain_list_enabled" -eq 1 ]; then