Update TTL cgi

This commit is contained in:
iamromulan
2024-05-04 00:10:19 -04:00
parent d94fe733e1
commit 0ba950f9fa
2 changed files with 12 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Check iptables for ttlvalue # Check iptables for ttlvalue
ttlvalue=$(iptables -t mangle -vnL | awk '/TTL/ {print $13; exit}') ttlvalue=$(/opt/bin/sudo /usr/sbin/iptables -w 5 -t mangle -vnL | grep TTL | awk '{print $13}' | head -n1)
ttlenabled=true; ttlenabled=true;
# Set Variables # Set Variables
@@ -17,4 +17,4 @@ cat <<EOT
"isEnabled": $ttlenabled, "isEnabled": $ttlenabled,
"ttl": $ttlvalue "ttl": $ttlvalue
} }
EOT EOT

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
PATH=/bin:/usr/sbin:/usr/bin:/sbin:/opt/sbin:/opt/bin:/usrdata/root/bin
# Get query # Get query
QUERY_STRING=$(echo "${QUERY_STRING}" | sed 's/;//g') QUERY_STRING=$(echo "${QUERY_STRING}" | sed 's/;//g')
@@ -22,28 +22,28 @@ setTTL=$(printf '%b\n' "${ttlvalue//%/\\x}")
if [ -n "${setTTL}" ]; then if [ -n "${setTTL}" ]; then
# Stop Service To Remove Rules # Stop Service To Remove Rules
/usrdata/simplefirewall/ttl-override stop /opt/bin/sudo /usrdata/simplefirewall/ttl-override stop
# Check iptables is still set # Check iptables is still set
ttlcheck=$(iptables -t mangle -vnL | grep TTL | awk '{print $13}') ttlcheck=$(/opt/bin/sudo /usr/sbin/iptables -w 5 -t mangle -vnL | grep TTL | awk '{print $13}')
# If TTL is still set manually remove values # If TTL is still set manually remove values
if [ !-z "${ttlcheck}" ]; then if [ ! -z "${ttlcheck}" ]; then
iptables -t mangle -D POSTROUTING -o rmnet+ -j TTL --ttl-set ${ttlcheck} &>/dev/null || true /opt/bin/sudo /usr/sbin/iptables -w 5 -t mangle -D POSTROUTING -o rmnet+ -j TTL --ttl-set ${ttlcheck} &>/dev/null || true
ip6tables -t mangle -D POSTROUTING -o rmnet+ -j HL --hl-set ${ttlcheck} &>/dev/null || true /opt/bin/sudo /usr/sbin/ip6tables -w 5 -t mangle -D POSTROUTING -o rmnet+ -j HL --hl-set ${ttlcheck} &>/dev/null || true
fi fi
# Echo TTL to file # Echo TTL to file
echo $setTTL > /usrdata/simplefirewall/ttlvalue echo $setTTL > /usrdata/simplefirewall/ttlvalue
# Set Start Service # Set Start Service
/usrdata/simplefirewall/ttl-override start /opt/bin/sudo /usrdata/simplefirewall/ttl-override start
fi fi
# Check iptables for ttlvalue # Check iptables for ttlvalue
ttlvalue=$(iptables -t mangle -vnL | grep TTL | awk '{print $13}') ttlvalue=$(/opt/bin/sudo /usr/sbin/iptables -w 5 -t mangle -vnL | grep TTL | awk '{print $13}')
ttlenabled=true; ttlenabled=true;
# Set Variables # Set Variables
@@ -58,4 +58,5 @@ cat <<EOT
{ {
"isEnabled": $ttlenabled, "isEnabled": $ttlenabled,
"ttl": $ttlvalue "ttl": $ttlvalue
} }
EOT