Skip to content

Commit

Permalink
Merge pull request #18 from DennoN-RUS/V3.9.0-test-ipset
Browse files Browse the repository at this point in the history
V3.9 IPSet addon
  • Loading branch information
DennoN-RUS committed Aug 6, 2024
2 parents 2cdc006 + 0399b4c commit fe17178
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lists/
scripts/
scripts/
IPset4Static/
2 changes: 2 additions & 0 deletions Install/common/func.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ diff_funk() {
echo -e "\n########### $(date) STEP_3: diff $(echo $1 | awk -F/ '{print $NF}' ) ###########\n" >&2
diff -u $1 $2 > $patch_file
cat $patch_file && patch $1 $patch_file
rm $patch_file
else
diff -u $1 $2 | patch $1 -
fi
Expand All @@ -93,6 +94,7 @@ get_as_func() {
if [[ "$DEBUG" == 1 ]]; then out=2; echo -e "\n$cur_as" >&$out; fi
for i in $out 1; do
curl -sk https://stat.ripe.net/data/announced-prefixes/data.json?resource=$cur_as | awk -F '"' '/([0-9]{1,3}.){3}[0-9]{1,3}\/[0-9]{1,2}/{print $4}' | iprange - >&$i
#whois -h whois.radb.net -- "-i origin $cur_as" | awk '/^route:/{print $2}' | iprange - >&$i
done
done
awk '!/^AS([0-9]{1,5})/{print $0}' "$1"
Expand Down
24 changes: 12 additions & 12 deletions Install/double_vpn/bird-table.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin

start(){
if [ -z "$(ip rule | awk '/^30000/')" ]; then
ip rule add table 1000 priority 30000
if [ -z "$(ip rule | awk '/^30020/')" ]; then
ip rule add table 1020 priority 30020
fi
if [ -z "$(ip rule | awk '/^30001/')" ]; then
ip rule add table 1001 priority 30001
if [ -z "$(ip rule | awk '/^30021/')" ]; then
ip rule add table 1021 priority 30021
fi
if [ -z "$(ip rule | awk '/^30002/')" ]; then
ip rule add table 1002 priority 30002
if [ -z "$(ip rule | awk '/^30022/')" ]; then
ip rule add table 1022 priority 30022
fi
}

stop(){
if [ -n "$(ip rule | awk '/^30000/')" ]; then
ip rule del table 1000
if [ -n "$(ip rule | awk '/^30020/')" ]; then
ip rule del table 1020
fi
if [ -n "$(ip rule | awk '/^30001/')" ]; then
ip rule del table 1001
if [ -n "$(ip rule | awk '/^30021/')" ]; then
ip rule del table 1021
fi
if [ -n "$(ip rule | awk '/^30002/')" ]; then
ip rule del table 1002
if [ -n "$(ip rule | awk '/^30022/')" ]; then
ip rule del table 1022
fi
}

Expand Down
6 changes: 3 additions & 3 deletions Install/double_vpn/bird.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ filter pref_150_vpn2 {
}

protocol kernel kernel_force from KERNEL_BASE {
kernel table 1000;
kernel table 1020;
ipv4 {
table route_force;
export filter pref_50_force;
};
}
protocol kernel kernel_vpn1 from KERNEL_BASE {
kernel table 1001;
kernel table 1021;
ipv4 {
export filter pref_100_vpn1;
table route_vpn1;
};
}
protocol kernel kernel_vpn2 from KERNEL_BASE {
kernel table 1002;
kernel table 1022;
ipv4 {
export filter pref_150_vpn2;
table route_vpn2;
Expand Down
12 changes: 12 additions & 0 deletions Install/install_func.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,16 @@ run_func(){
$SYSTEM_FOLDER/etc/init.d/S10cron restart
$SYSTEM_FOLDER/etc/init.d/S70bird restart
$SCRIPTS/add-bird4_routes.sh
}

# Get addon ipset
install_ipset4static(){
echo -e "Do you want install IPset4Static addon? y/n"
read ANS
if [ "$ANS" == "y" ]; then
cd $HOME_FOLDER
git clone https://github.com/DennoN-RUS/IPset4Static.git
chmod +x ./IPset4Static/*.sh
./IPset4Static/install.sh
fi
}
16 changes: 8 additions & 8 deletions Install/one_vpn/bird-table.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin

start()
{
if [ -z "$(ip rule | awk '/^30000/')" ]; then
ip rule add table 1000 priority 30000
if [ -z "$(ip rule | awk '/^30020/')" ]; then
ip rule add table 1020 priority 30020
fi
if [ -z "$(ip rule | awk '/^30001/')" ]; then
ip rule add table 1001 priority 30001
if [ -z "$(ip rule | awk '/^30021/')" ]; then
ip rule add table 1021 priority 30021
fi
}

stop(){
if [ -n "$(ip rule | awk '/^30000/')" ]; then
ip rule del table 1000
if [ -n "$(ip rule | awk '/^30020/')" ]; then
ip rule del table 1020
fi
if [ -n "$(ip rule | awk '/^30001/')" ]; then
ip rule del table 1001
if [ -n "$(ip rule | awk '/^30021/')" ]; then
ip rule del table 1021
fi
}

Expand Down
4 changes: 2 additions & 2 deletions Install/one_vpn/bird.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ filter pref_100_vpn1 {
}

protocol kernel kernel_force from KERNEL_BASE {
kernel table 1000;
kernel table 1020;
ipv4 {
table route_force;
export filter pref_50_force;
};
}
protocol kernel kernel_vpn1 from KERNEL_BASE {
kernel table 1001;
kernel table 1021;
ipv4 {
table route_vpn1;
export filter pref_100_vpn1;
Expand Down
13 changes: 12 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

VERSION_NEW="v3.8.1"
VERSION_NEW="v3.9"

while true; do
echo -e "\nBegin install? y/n"
Expand Down Expand Up @@ -64,6 +64,17 @@ rm_old_list_func
# Starting Services
run_func

#IPset4Static addon
if [ -d "$HOME_FOLDER/IPset4Static" ]; then
echo -e "\nFound iPset4Static\nDo you want to try update it y/n"
read ANS
if [ "$ANS" == "y" ]; then
sh $HOME_FOLDER/IPset4Static/update.sh
fi
else
install_ipset4static
fi

exit 0
;;
[Nn]* ) exit 0;;
Expand Down
9 changes: 9 additions & 0 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ rm $SYSTEM_FOLDER/etc/cron.hourly/add-bird4_routes.sh
# Remove bird lists
rm -r $SYSTEM_FOLDER/etc/bird4*.list

#IPset4Static addon
if [ -d "$HOME_FOLDER/IPset4Static" ]; then
echo -e "\nFound iPset4Static\nDo you want uninstall it? y/n"
read ANS
if [ "$ANS" == "y" ]; then
sh $HOME_FOLDER/IPset4Static/uninstal.sh
fi
fi

exit 0
;;
[Nn]* ) exit 0;;
Expand Down

0 comments on commit fe17178

Please sign in to comment.