Skip to content
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

ffmuc-mesh-vpn-wireguard-vxlan: Fix wrong context for ntp-server update #92

Merged
merged 9 commits into from
Mar 10, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,20 @@
if [ "$CONNECTED" -ne "1" ]; then
logger -t checkuplink "Reconnecting ..."
NTP_SERVERS=$(uci get system.ntp.server)
# shellcheck disable=SC3060 # busybox sh supports string replacement
NTP_SERVERS="${NTP_SERVERS// / -p }" # each separate NTP server needs to be behind a "-p"
# shellcheck disable=SC2086 # we need to expand the list of NTP_SERVERS here
if ! gluon-wan /usr/sbin/ntpd -n -N -S /usr/sbin/ntpd-hotplug -p ${NTP_SERVERS} -q
for NTP_SERVER in $NTP_SERVERS; do
ipv6="$(gluon-wan nslookup "$NTP_SERVER" | grep 'Address:\? [0-9]' | grep -E -o '([a-f0-9:]+:+)+[a-f0-9]+')"
ipv4="$(gluon-wan nslookup "$NTP_SERVER" | grep 'Address:\? [0-9]' | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")"
if ip -6 route show table 1 | grep -q 'default via'
then
NTP_SERVERS_ADDRS=$(for ip in $ipv6; do echo -n "-p $ip "; done)
else
NTP_SERVERS_ADDRS=$(for ip in $ipv4; do echo -n "-p $ip "; done)
fi
done
if ! LD_PRELOAD=libpacketmark.so LIBPACKETMARK_MARK=1 gluon-wan /usr/sbin/ntpd -n -N -S /usr/sbin/ntpd-hotplug ${NTP_SERVERS_ADDRS} -q

Check notice on line 88 in ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink#L88 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink:88:114: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
awlx marked this conversation as resolved.
Show resolved Hide resolved
then
logger -p err -t checkuplink "Unable to establish NTP connection to ${NTP_SERVERS}."
exit 3
fi

# Get the number of configured peers and randomly select one
Expand Down Expand Up @@ -114,7 +122,7 @@
else
PROTO=https
fi
gluon-wan wget -q -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$PROTO://$(uci get wireguard.mesh_vpn.broker)"
LD_PRELOAD=libpacketmark.so LIBPACKETMARK_MARK=1 gluon-wan wget -q -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$PROTO://$(uci get wireguard.mesh_vpn.broker)"

# Bring up the wireguard interface
ip link add dev "$MESH_VPN_IFACE" type wireguard
Expand Down
Loading