Last active
October 31, 2025 07:18
-
-
Save koreapyj/483bb451d28a50ce8730d01574a3bef3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/ash | |
| uci show firewall | grep 'Proxy-HTTP-' | while read -r line; do | |
| uci_path="$(echo "$line" | sed -n 's/\(firewall.*\)\.name=.*/\1/p')"; | |
| domain="$(echo "$line" | sed -n "s/.*='Proxy-HTTP-\(.*\)'/\1/p")"; | |
| ipaddr="$(nslookup -type=a $domain 1.1.1.1 | sed -n 's/address: \(.*\)/\1/pi' | head -n1)"; | |
| dest_ip="$(uci get "${uci_path}.dest_ip")"; | |
| if [ -z "$uci_path" ] || [ -z "$domain" ] || [ -z "$ipaddr" ] || [ -z "$dest_ip" ]; then | |
| >&2 echo "something went wrong. abort."; | |
| >&2 echo "uci_path='$uci_path'"; | |
| >&2 echo "domain='$domain'"; | |
| >&2 echo "ipaddr='$ipaddr'"; | |
| >&2 echo "dest_ip='$dest_ip'"; | |
| uci revert firewall; | |
| exit 1; | |
| fi | |
| if [ "$dest_ip" != "$ipaddr" ]; then | |
| uci set "${uci_path}.dest_ip=$ipaddr" | |
| fi | |
| done | |
| uci commit firewall && service firewall reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment