-
Notifications
You must be signed in to change notification settings - Fork 110
Fix Pirania issue/1206 and overall captive portal stability #1224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
usg-ishimura
wants to merge
13
commits into
libremesh:master
Choose a base branch
from
usg-ishimura:issue/1206
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eddadc2
fixed portal front-end js errors
usg-ishimura a6999cc
fixed portal and read_for_access 502 bad gateway redirect bug
usg-ishimura 538141a
aligned read_for_access test to 502 bad gateway bug fix
usg-ishimura c8c011f
added packets drop for unauthorized macs on 443 and restored init.d p…
usg-ishimura 2742ff4
Changed portal host to gateway.info
usg-ishimura 9138be1
Created pirania-mesh-sync and added to crontabs
usg-ishimura 612d7d9
Updated captive-portal
usg-ishimura d08e7f1
Added ips functions in pirania
usg-ishimura 76d8c82
Updated pirania tests
usg-ishimura 9835ad5
Fixed diffs from develop
usg-ishimura 6b1d5fc
Added show_authorized_ips to /usr/bin/voucher
usg-ishimura dcf1d1b
Activate secondary node voucher if ip OR mac is not authorized
usg-ishimura 67ddb06
Flush macs and ips auth lists to exclude invalidated addresses
usg-ishimura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/bin/sh /etc/rc.common | ||
|
|
||
| START=99 | ||
|
|
||
| start() { | ||
| ( | ||
| TIMEOUT=60 | ||
| INTERVAL=2 | ||
| ELAPSED=0 | ||
| ntpd -q -p pool.ntp.org | ||
| while [ $ELAPSED -lt $TIMEOUT ]; do | ||
| WAN_IF=$(ifstatus wan | jsonfilter -e '@.l3_device') | ||
| DEFAULT_ROUTE=$(ip route | awk '/^default/ {print $3" "$5; exit}') | ||
| BR_LAN_IP=$(ip -4 -o addr show dev br-lan | awk '{print $4}' | cut -d/ -f1) | ||
| GATEWAY=$(echo "$DEFAULT_ROUTE" | awk '{print $1}') | ||
| DEV=$(echo "$DEFAULT_ROUTE" | awk '{print $2}') | ||
| WLAN_MESH_MAC=$(ip link show "$DEV" | awk '/link\/ether/ {print $2}') | ||
| echo "DEBUG: WAN_IF=$WAN_IF" | ||
| echo "DEBUG: DEFAULT_ROUTE=$DEFAULT_ROUTE" | ||
| echo "DEBUG: BR_LAN_IP=$BR_LAN_IP" | ||
| echo "DEBUG: GATEWAY=$GATEWAY" | ||
| echo "DEBUG: DEV=$DEV" | ||
| echo "DEBUG: WLAN_MESH_MAC=$WLAN_MESH_MAC" | ||
| if [ -n "$DEV" ] && [ -n "$BR_LAN_IP" ] && [ -n "$WLAN_MESH_MAC" ] && [ -n "$GATEWAY" ] && [ "$DEV" != "$WAN_IF" ]; then | ||
| echo "DEBUG: SECONDARY" | ||
| if ! /usr/bin/voucher show_authorized_macs | grep -iq "$WLAN_MESH_MAC" || ! /usr/bin/voucher show_authorized_ips | grep -iq "$BR_LAN_IP"; then | ||
| CODE=$(/usr/bin/voucher add '# whitelist-secondary-node' | awk '{print $4}') | ||
| /usr/bin/voucher activate "$CODE" "$WLAN_MESH_MAC" "$BR_LAN_IP" | ||
| fi | ||
| for f in /etc/pirania/hooks/db_change/*; do | ||
| [ -x "$f" ] && "$f" | ||
| done | ||
| uci set dhcp.pirania="hostrecord" | ||
| uci set dhcp.pirania.name="gateway.info" | ||
| uci set dhcp.pirania.ip="$GATEWAY" | ||
| uci commit dhcp | ||
| /etc/init.d/dnsmasq reload | ||
| exit 0 | ||
| elif [ -n "$DEV" ] && [ -n "$BR_LAN_IP" ] && [ "$DEV" = "$WAN_IF" ]; then | ||
| echo "DEBUG: PRIMARY" | ||
| if [ "$1" != "skip" ]; then | ||
| sleep 300 | ||
| fi | ||
| for f in /etc/pirania/vouchers/*.json; do | ||
| if grep -q '"name"[[:space:]]*:[[:space:]]*"# whitelist-secondary-node"' "$f"; then | ||
| MAC=$(grep -o '"mac"[[:space:]]*:[[:space:]]*"[^"]*"' "$f" | awk -F'"' '{print $4}') | ||
| IP=$(grep -o '"ip"[[:space:]]*:[[:space:]]*"[^"]*"' "$f" | awk -F'"' '{print $4}') | ||
| if [ -n "$MAC" ] && [ -n "$IP" ]; then | ||
| lua -e "require('read_for_access.read_for_access').authorize_mac('$MAC', '$IP')" | ||
| fi | ||
| fi | ||
| done | ||
| uci set dhcp.pirania="hostrecord" | ||
| uci set dhcp.pirania.name="gateway.info" | ||
| uci set dhcp.pirania.ip="$BR_LAN_IP" | ||
| uci commit dhcp | ||
| /etc/init.d/dnsmasq reload | ||
| exit 0 | ||
| fi | ||
| sleep $INTERVAL | ||
| ELAPSED=$((ELAPSED + INTERVAL)) | ||
| done | ||
| echo "DEBUG: VARIABLES NOT FOUND" | ||
| uci set dhcp.pirania="hostrecord" | ||
| uci set dhcp.pirania.name="gateway.info" | ||
| uci set dhcp.pirania.ip="$BR_LAN_IP" | ||
| uci commit dhcp | ||
| /etc/init.d/dnsmasq reload | ||
| exit 1 | ||
| ) & | ||
| } |
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
12 changes: 12 additions & 0 deletions
12
packages/pirania/files/etc/uci-defaults/91-mesh-sync-update
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/sh | ||
| /etc/init.d/pirania-mesh-sync enable | ||
| /etc/init.d/pirania-mesh-sync start | ||
|
|
||
| unique_append() | ||
| { | ||
| grep -qF "$1" "$2" || echo "$1" >> "$2" | ||
| } | ||
|
|
||
| unique_append \ | ||
| '*/10 * * * * /etc/init.d/pirania-mesh-sync restart &> /dev/null' \ | ||
| /etc/crontabs/root |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/usr/bin/lua | ||
|
|
||
| local portal = require('portal.portal') | ||
|
|
||
| for _, ip in pairs(portal.get_authorized_ips()) do | ||
| print(ip) | ||
| end |
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.