fix: Fix secondary route configuration

This commit is contained in:
Ivan Kvashonkin
2024-11-10 16:07:59 +03:00
parent 20d0d00620
commit 6179306da9
7 changed files with 172 additions and 98 deletions

View File

@@ -35,9 +35,9 @@ start_service() {
fi
config_get_bool second_enable "second" "second_enable" "0"
config_get mode "second" "mode" "0"
if [ "$second_enable" -eq "1" ] && [ "$mode" = "proxy" ]; then
config_get proxy_string second "proxy_string"
config_get second_mode "second" "second_mode" "0"
if [ "$second_enable" -eq "1" ] && [ "$second_mode" = "proxy" ]; then
config_get proxy_string "second" "second_proxy_string"
if [[ "$proxy_string" =~ ^ss:// ]]; then
sing_box_config_shadowsocks "$proxy_string" "1603"
elif [[ "$proxy_string" =~ ^vless:// ]]; then
@@ -53,9 +53,9 @@ start_service() {
/etc/init.d/sing-box enable
fi
if [ "$second_enable" -eq "1" ] && [ "$mode" = "vpn" ]; then
if [ "$second_enable" -eq "1" ] && [ "$second_mode" = "vpn" ]; then
log "VPN mode for second"
config_get interface "second" "interface" "0"
config_get interface "second" "second_interface" "0"
if [ -n "$interface" ]; then
add_route_interface "$interface" "podkop2"
else
@@ -72,8 +72,8 @@ start_service() {
# Main - proxy, Second - proxy
config_get_bool second_enable "second" "second_enable" "0"
config_get mode "second" "mode" "0"
if [ "$second_enable" -eq "1" ] && [ "$mode" = "proxy" ]; then
config_get second_mode "second" "second_mode" "0"
if [ "$second_enable" -eq "1" ] && [ "$second_mode" = "proxy" ]; then
log "Two proxy enable"
outbound_main=$(mktemp)
outbound_second=$(mktemp)
@@ -88,7 +88,7 @@ start_service() {
return
fi
config_get proxy_string second "proxy_string"
config_get proxy_string "second" "second_proxy_string"
if [[ "$proxy_string" =~ ^ss:// ]]; then
sing_box_config_outbound_shadowsocks "$proxy_string" "$outbound_second" second
elif [[ "$proxy_string" =~ ^vless:// ]]; then
@@ -109,8 +109,8 @@ start_service() {
# Main proxy, second disable/vpn
config_get_bool second_enable "second" "second_enable" "0"
config_get mode "second" "mode" "0"
if [ "$second_enable" -eq "0" ] || [ "$mode" = "vpn" ]; then
config_get second_mode "second" "second_mode" "0"
if [ "$second_enable" -eq "0" ] || [ "$second_mode" = "vpn" ]; then
config_get proxy_string main "proxy_string"
if [[ "$proxy_string" =~ ^ss:// ]]; then
sing_box_config_shadowsocks "$proxy_string" "1602"
@@ -130,11 +130,11 @@ start_service() {
# Main proxy, Second VPN
config_get_bool second_enable "second" "second_enable" "0"
config_get mode "second" "mode" "0"
if [ "$second_enable" -eq "1" ] && [ "$mode" = "vpn" ]; then
config_get second_mode "second" "second_mode" "0"
if [ "$second_enable" -eq "1" ] && [ "$second_mode" = "vpn" ]; then
log "VPN mode for seconds"
log "You are using VPN mode, make sure you have installed all the necessary packages, configured, created the zone and forwarding."
config_get interface "second" "interface" "0"
config_get interface "second" "second_interface" "0"
if [ -n "$interface" ]; then
add_route_interface "$interface" "podkop2"
else
@@ -225,7 +225,7 @@ stop_service() {
log "Stop sing-box"
config_get mode_main "main" "mode" "0"
config_get mode_second "second" "mode" "0"
config_get mode_second "second" "second_mode" "0"
if [ "$mode_main" = "proxy" ] || [ "$mode_second" = "proxy" ]; then
/etc/init.d/sing-box stop
@@ -396,7 +396,11 @@ add_set() {
log "Create set $set_name"
nft add chain inet PodkopTable mangle { type filter hook prerouting priority -150 \; policy accept \;}
nft add set inet PodkopTable "$set_name" { type ipv4_addr\; flags interval\; auto-merge\; }
config_get mode "$connect" "mode"
if [ "$connect" = "main" ]; then
config_get mode "$connect" "mode"
else
config_get mode "$connect" "second_mode"
fi
case "$mode" in
"vpn")
if ! nft list chain inet PodkopTable mangle | grep -q "ip daddr @"$set_name" meta mark set"; then
@@ -537,8 +541,11 @@ lists_domains_download() {
while true; do
if curl -m 3 github.com; then
curl -f $URL --output /tmp/dnsmasq.d/podkop-domains.lst
sed -i 's/fw4#vpn_domains/PodkopTable#podkop_domains/g' /tmp/dnsmasq.d/podkop-domains.lst
return 0
if [ "$connect" = "second" ]; then
sed -i 's/fw4#vpn_domains/PodkopTable#podkop2_domains/g' /tmp/dnsmasq.d/podkop-domains.lst
else
sed -i 's/fw4#vpn_domains/PodkopTable#podkop_domains/g' /tmp/dnsmasq.d/podkop-domains.lst
fi return 0
else
log "GitHub is not available. Check the internet availability [$count sec]"
count=$((count + 1))