Skip to content

Commit

Permalink
Исправлена ошибка возникающая при старте или перезагрузке Adguard сер…
Browse files Browse the repository at this point in the history
…виса, на шаге 'Очищаем все ранее созданные iptables правила для VPN'. Так же, исправлена ошибка отпредедения статуса Adguard сервиса [issue #69 и #73].
  • Loading branch information
qzeleza committed Nov 23, 2023
1 parent e61bb01 commit 9bb866f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 29 deletions.
Binary file modified ipk/kvas_1.1.5-pre_release_3_all.ipk
Binary file not shown.
11 changes: 9 additions & 2 deletions opt/bin/libs/main
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,18 @@ reset_ISP_connection() {
curl -s -d '{"up":"true"}' "${INFACE_PART_REQUEST}/${id}" &> /dev/null
}


# ------------------------------------------------------------------------------------------
#
# Получаем список гостевых интерфейсов из файла конфигурации
#
# ------------------------------------------------------------------------------------------
get_guest_inface_list_from_config(){
get_config_value INFACE_GUEST_ENT | tr ',' ' '
}

# ------------------------------------------------------------------------------------------
#
# Получаем нумерованный список с именами интерфейсов
# Перегружаем заданное соединение inface_cli
#
# ------------------------------------------------------------------------------------------
reset_connection() {
Expand Down
15 changes: 10 additions & 5 deletions opt/bin/libs/vpn
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ adguardhome_check_config() {
echo "После всех произведенных настроек нажмите Ctrl-C"
# echo -e "И затем снова запустите ${BLUE}kvas adguard on${NOCL}"
print_line
/opt/bin/AdGuardHome && cmd_adguardhome_on
/opt/bin/AdGuardHome
cmd_adguardhome_on
fi
fi
}
Expand Down Expand Up @@ -473,9 +474,11 @@ cmd_adguardhome_on() {

status=$(cmd_adguardhome_status)
if echo "${status}" | grep -q "НЕ УСТАНОВЛЕН" ; then
echo "Пакет AdGuard Home не установлен на роутере."
error "Пакет AdGuard Home не установлен на роутере."
print_line
answer=''; read_ynq "Установить его на роутер [Y] или отказаться [N]?" answer
if [ "${answer}" = y ]; then
print_line
adguardhome_install_locally
fi
elif echo "${status}" | grep -q "НЕ НАСТРОЕН" ; then
Expand Down Expand Up @@ -1525,7 +1528,7 @@ select_vpn_interface() {
total=$(cat < "${INFACE_NAMES_FILE}" | wc -l)
while true; do
print_line
ready "${BLUE}Выберите номер варианта VPN соединения от 1 до ${total}|S-скан.|Q-выход:${NOCL}"
ready "${BLUE}Выберите номер варианта VPN соединения 1-${total} | S-скан. | Q-выход:${NOCL}"
read -r num_vpn_inface
if ! echo "${num_vpn_inface}" | grep -qiE "[1-${total}qs]"; then
error "Введите цифру от 1 до ${total} или S - сканирование, Q - выход."
Expand All @@ -1551,14 +1554,15 @@ select_vpn_interface() {
cli="$(get_router_host)/a"
print_line
echo -e "${RED}Процедура настройки прервана пользователем!${NOCL}"
print_line
/opt/etc/init.d/S56dnsmasq stop &> /dev/null
echo "В случае, если сейчас у Вас пропал интернет, то для восстановления подключения"
echo -e "необходимо зайти в админ панель роутера по адресу: ${GREEN}${cli}${NOCL}"
echo "и выполнить последовательно три следующих команды: "
print_line
echo -e "1. ${GREEN}no opkg dns-override ${NOCL} - вновь подключаем DNS провайдера,"
echo -e "1. ${GREEN}no opkg dns-override ${NOCL} - вновь подключаем DNS провайдера,"
echo -e "2. ${GREEN}system configuration save ${NOCL} - сохраняем изменения,"
echo -e "3. ${GREEN}system reboot ${NOCL} - перегружаем роутер."
echo -e "3. ${GREEN}system reboot ${NOCL} - перегружаем роутер."
print_line
exit 1
else
Expand Down Expand Up @@ -1872,6 +1876,7 @@ host_add() {
reset="${2}"
clear_host=$(echo "${host}" | sed 's/\*//')


ready "Добавляем ${YELLOW}${_host}${NOCL} в список разблокировки..."
echo "${_host}" >> "${UNBLOCK_LIST_FILE}"
# если включен блокировщик рекламы
Expand Down
14 changes: 7 additions & 7 deletions opt/bin/main/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ready() {
size=$(diff_len "${1}")
printf "%b%-${size}s%b" "${1}"
}
when_ok() (echo -e "${GREEN}ГОТОВО${NOCL}")
when_good() (echo -e "${GREEN}ГОТОВО${NOCL}")
when_err() (echo -e "${RED}ОШИБКА${NOCL}" )

package_name=kvas_all.ipk
Expand All @@ -35,32 +35,32 @@ upgrade(){
ready 'Обновляем opkg...'
{
opkg update && opkg upgrade && opkg install curl iptables
} &>/dev/null && when_ok || when_err
} &>/dev/null && when_good || when_err


ready 'Загружаем пакет...'
{

cd /opt/packages
curl -sOL "${package_url}"
} &>/dev/null && when_ok || when_err
} &>/dev/null && when_good || when_err

[ -f "${host_list}" ] && {
ready 'Сохраняем список разблокировки в архив...'
mv "${host_list}" "${list_backup}" &>/dev/null && when_ok || when_err
mv "${host_list}" "${list_backup}" &>/dev/null && when_good || when_err
}

ready 'Удаляем предыдущую версию пакета...'
{
kvas rm yes

} &>/dev/null && when_ok || when_err
} &>/dev/null && when_good || when_err

ready 'Устанавливаем новую версию пакета...'
{
opkg install "./${package_name}"

} &>/dev/null && when_ok || when_err
} &>/dev/null && when_good || when_err

print_line
sleep 1
Expand All @@ -72,7 +72,7 @@ upgrade(){

[ -f "${list_backup}" ] && {
ready 'Восстанавливаем список разблокировки из архива...'
kvas import "${list_backup}" &>/dev/null && when_ok || when_err
kvas import "${list_backup}" &>/dev/null && when_good || when_err
}

print_line
Expand Down
41 changes: 26 additions & 15 deletions opt/etc/ndm/ndm
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ ip4_add_selected_guest_to_vpn_network(){
}
ip4_add_guest_to_vpn_network(){

for guest_inface in $(get_guest_inface_list)
for guest_inface in $(get_guest_inface_list_from_config)
do
ip4_add_selected_guest_to_vpn_network "${guest_inface}"
done
Expand Down Expand Up @@ -254,7 +254,7 @@ ip4_add_selected_guest_to_ssr_network(){
}

ip4_add_guest_to_ssr_network(){
for guest_inface in $(get_guest_inface_list)
for guest_inface in $(get_guest_inface_list_from_config)
do
ip4_add_selected_guest_to_ssr_network "${guest_inface}"
done
Expand All @@ -273,7 +273,7 @@ set_selected_guest_nets_rules(){
set_guest_nets_rules(){

# в случае наличия гостевой сети
if [ -n "$(get_guest_inface_list)" ]; then
if [ -n "$(get_guest_inface_list_from_config)" ]; then
if has_ssr_enable; then
# для ssr
ip4_add_guest_to_ssr_network &>/dev/null
Expand Down Expand Up @@ -504,7 +504,7 @@ ip4_firewall_rm_vpn_selected_guest_net(){
}
# для всех гостевых интерфейсов
ip4_firewall_flush_vpn_guest_rules(){
for guest_inface in $(get_guest_inface_list)
for guest_inface in $(get_guest_inface_list_from_config)
do
ip4_firewall_rm_vpn_selected_guest_net "${guest_inface}" &>/dev/null
done
Expand All @@ -525,9 +525,12 @@ ip4_firewall_rm_ssr_selected_guest_net(){
iptab -D PREROUTING -t nat -p udp -i "${guest_inface}" -m set --match-set unblock dst -j REDIRECT --to-port "${ssr_port}"
iptab -D PREROUTING -t nat -p tcp -i "${guest_inface}" -m set --match-set unblock dst -j REDIRECT --to-port "${ssr_port}"
}



# для всех гостевых интерфейсов
ip4_firewall_flush_ssr_guest_rules(){
for guest_inface in $(get_guest_inface_list)
for guest_inface in $(get_guest_inface_list_from_config)
do
ip4_firewall_rm_ssr_selected_guest_net "${guest_inface}" &>/dev/null
done
Expand All @@ -550,11 +553,16 @@ ip4_firewall_rm_selected_guest_net(){
ip4_firewall_nofastnet_vpn_prune &>/dev/null
fi

if has_ssr_enable; then
ip4_firewall_rm_ssr_selected_guest_net "${guest_inface}" &>/dev/null;
else
ip4_firewall_rm_vpn_selected_guest_net "${guest_inface}" &>/dev/null;
fi
for guest_inface in $(get_guest_inface_list_from_config)
do
if has_ssr_enable; then
ip4_firewall_rm_ssr_selected_guest_net "${guest_inface}" &>/dev/null;
else
ip4_firewall_rm_vpn_selected_guest_net "${guest_inface}" &>/dev/null;
fi
done


}

# для всех гостевых интерфейсов
Expand All @@ -567,11 +575,14 @@ ip4_firewall_flush_vpn_rules() {
ip4_firewall_nofastnet_vpn_prune &>/dev/null
fi

if has_ssr_enable; then
ip4_firewall_flush_ssr_guest_rules &>/dev/null;
else
ip4_firewall_flush_vpn_guest_rules &>/dev/null;
fi
for guest_inface in $(get_guest_inface_list_from_config)
do
if has_ssr_enable; then
ip4_firewall_flush_ssr_guest_rules &>/dev/null;
else
ip4_firewall_flush_vpn_guest_rules &>/dev/null;
fi
done
}
# ------------------------------------------------------------------------------------------
#
Expand Down

0 comments on commit 9bb866f

Please sign in to comment.