Skip to content

Commit

Permalink
Merge pull request #109 from AdityaC4/master
Browse files Browse the repository at this point in the history
add: files and details for 1min temp access
  • Loading branch information
cuttlefishi authored Aug 5, 2024
2 parents d3d49ff + e45e6a3 commit 8c8d8e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 7 additions & 3 deletions router/manage_temp_firewall.ash
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ add_rule() {
echo " option dest wan" >> /root/xonefi/twpolicy.fw
echo " option proto all" >> /root/xonefi/twpolicy.fw
echo " option target ACCEPT" >> /root/xonefi/twpolicy.fw
echo "add_rule() called" >> /root/xonefi.log

increment_update_dat
cat /root/xonefi/firewall.orig /root/xonefi/twpolicy.fw /root/xonefi/wpolicy.fw /root/xonefi/policy.fw /root/xonefi/firewall-blocker.orig > /etc/config/firewall
/etc/init.d/firewall restart
echo "firewall restarted from temp manager" >> /root/xonefi.log
}

# Function to remove a rule from twpolicy.fw
Expand All @@ -32,6 +35,7 @@ remove_rule() {
if ! grep -q 'option src_ip' /root/xonefi/twpolicy.fw; then
rm /root/xonefi/twpolicy.fw
fi
echo "remove_rule() called" >> /root/xonefi.log

increment_update_dat
}
Expand All @@ -42,6 +46,7 @@ increment_update_dat() {
local current_value=$(cat ${update_file})
local new_value=$((current_value + 1))
echo ${new_value} > ${update_file}
echo "increment_update_dat() called" >> /root/xonefi.log
}

main() {
Expand Down Expand Up @@ -70,5 +75,4 @@ main() {
echo "Temporary rule for ${client_ip} added and removed." >> /root/xonefi.log
}

main $1

main $1
2 changes: 1 addition & 1 deletion router/puller.ash
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ while true; do
sleep 3
wget -q --user=$PINGER_USER --password=$PINGER_TOKEN $PROTOCOL://$PINGER_ADDRESS/$PINGER_USER/$ROUTER_NUMBER/wpolicy.fw -O /root/xonefi/wpolicy.fw
sleep 3
if [ -f "/root/xonefi/twpolicy.fw" ]
if [ -f "/root/xonefi/twpolicy.fw" ]; then
cat /root/xonefi/firewall.orig /root/xonefi/twpolicy.fw /root/xonefi/wpolicy.fw /root/xonefi/policy.fw /root/xonefi/firewall-blocker.orig > /etc/config/firewall
else
cat /root/xonefi/firewall.orig /root/xonefi/wpolicy.fw /root/xonefi/policy.fw /root/xonefi/firewall-blocker.orig > /etc/config/firewall
Expand Down
12 changes: 12 additions & 0 deletions router/routerconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ the firewall configurations should be set after Nodogsplash is set up to overrid
1. Copy Captive portal files: (These files are not on github yet)
```sh
cd /etc/nodogsplash/htdocs/
rm splash.css splash.html status.html
wget https://raw.githubusercontent.com/xmeshlab/xonefi/master/router/splash.html
wget https://raw.githubusercontent.com/xmeshlab/xonefi/master/router/splash.css
wget https://raw.githubusercontent.com/xmeshlab/xonefi/master/router/status.html
Expand All @@ -54,3 +55,14 @@ the firewall configurations should be set after Nodogsplash is set up to overrid
```sh
/etc/init.d/nodogsplash restart
```

# Temp 1 min access configuration

```sh
cd /root/xonefi/
wget wget https://raw.githubusercontent.com/xmeshlab/xonefi/master/router/manage_temp_firewall.ash
chmod +x manage_temp_firewall.ash
cd /www/cgi-bin/
wget wget https://raw.githubusercontent.com/xmeshlab/xonefi/master/router/set_temp_access.ash
chmod +x set_temp_access.ash
```

0 comments on commit 8c8d8e6

Please sign in to comment.