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

add subnet mask to interface address #332

Closed
wants to merge 2 commits into from
Closed
Changes from all 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
4 changes: 2 additions & 2 deletions root/etc/s6-overlay/s6-rc.d/init-wireguard-confs/run
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ DUDE"
fi
else
for idx in {2..254}; do
PROPOSED_IP="${INTERFACE}.${idx}"
if ! grep -q -R "${PROPOSED_IP}" /config/peer*/*.conf 2>/dev/null && ([[ -z "${ORIG_INTERFACE}" ]] || ! grep -q -R "${ORIG_INTERFACE}.${idx}" /config/peer*/*.conf 2>/dev/null); then
PROPOSED_IP="${INTERFACE}.${idx}/32"
if ! grep -q -R "${PROPOSED_IP}" /config/peer*/*.conf 2>/dev/null && ([[ -z "${ORIG_INTERFACE}" ]] || ! grep -q -R "${ORIG_INTERFACE}.${idx}/32" /config/peer*/*.conf 2>/dev/null); then
Comment on lines +59 to +60
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thespad, is something like this going to be better? If not, do you have any suggestions?

Suggested change
PROPOSED_IP="${INTERFACE}.${idx}/32"
if ! grep -q -R "${PROPOSED_IP}" /config/peer*/*.conf 2>/dev/null && ([[ -z "${ORIG_INTERFACE}" ]] || ! grep -q -R "${ORIG_INTERFACE}.${idx}/32" /config/peer*/*.conf 2>/dev/null); then
for idx in {2..254}; do
PROPOSED_IP="${INTERFACE}.${idx}/32"
if ! grep -q -R "${INTERFACE}.${idx}" /config/peer*/*.conf 2>/dev/null &&
! grep -q -R "${INTERFACE}.${idx}/32" /config/peer*/*.conf 2>/dev/null &&
([[ -z "${ORIG_INTERFACE}" ]] ||
(! grep -q -R "${ORIG_INTERFACE}.${idx}" /config/peer*/*.conf 2>/dev/null &&
! grep -q -R "${ORIG_INTERFACE}.${idx}/32" /config/peer*/*.conf 2>/dev/null)); then
CLIENT_IP="${PROPOSED_IP}"
break
fi
done

CLIENT_IP="${PROPOSED_IP}"
break
fi
Expand Down