Skip to content
Closed
Show file tree
Hide file tree
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
33 changes: 30 additions & 3 deletions bash/nord/config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#! /usr/bin/bash


# Check for jq
if ! command -v jq &> /dev/null
then
Expand Down Expand Up @@ -32,18 +31,29 @@ echo "The nickname is: $1"

NICKNAME=$1

#nordvpn set meshnet off
#nordvpn set routing disable

# Enable Meshnet and set the device's nickname
nordvpn set meshnet on
nordvpn meshnet set nickname $NICKNAME

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Quote the variable to prevent word splitting.

The $NICKNAME variable should be quoted to prevent potential issues if the nickname contains spaces or special characters.

🛡️ Proposed fix
-nordvpn meshnet set nickname $NICKNAME
+nordvpn meshnet set nickname "$NICKNAME"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
nordvpn meshnet set nickname $NICKNAME
nordvpn meshnet set nickname "$NICKNAME"
🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 39-39: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bash/nord/config.sh` at line 39, The nordvpn command uses an unquoted shell
variable; update the invocation that calls nordvpn meshnet set nickname
$NICKNAME to quote the variable (use "$NICKNAME") so the NICKNAME variable is
passed intact to the nordvpn meshnet set nickname command and avoids
word-splitting or globbing issues.


# Enable notifications for connection status changes.
nordvpn set notify on

# Disable Perfect Forward Secrecy (PFS) to allow for better compatibility with certain devices and configurations.
nordvpn set pq off
Comment on lines +44 to 45

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

What does the 'nordvpn set pq' command control in NordVPN?

💡 Result:

The command nordvpn set pq controls NordVPN’s post-quantum (PQ) protection setting (it enables or disables “Post-quantum encryption”). [1][2] When you run it with on/off (for example nordvpn set pq on or nordvpn set pq off), NordVPN turns that PQ protection feature on or off for subsequent connections. [1] NordVPN’s PQ feature is specifically described as “post-quantum encryption” / “post-quantum protection.” [1][2]

Citations:


Correct the comment to accurately describe the pq setting.

The code comment refers to "Perfect Forward Secrecy (PFS)" but nordvpn set pq off actually disables Post-Quantum encryption protection, not PFS. These are different security mechanisms. Update the comment to say something like: # Disable Post-Quantum encryption protection to allow for better compatibility with certain devices and configurations.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bash/nord/config.sh` around lines 44 - 45, Update the inaccurate comment that
mentions "Perfect Forward Secrecy (PFS)": replace it with a correct description
for the `pq` setting (Post-Quantum encryption protection) so the comment
accurately describes `nordvpn set pq off` — e.g., change the comment above the
`nordvpn set pq off` command to state that it disables Post-Quantum encryption
protection to improve compatibility with certain devices/configurations.


# Disable LAN discovery to prevent the device from being visible on the local network, enhancing security when acting as an exit node.
nordvpn set lan-discovery off

# Set the VPN protocol to NordLynx for improved performance and security.
nordvpn set technology nordlynx

# Set auto-connect for this device
nordvpn set autoconnect on
# Set auto-connect for this device to a specific country (e.g., Norway). Adjust as needed.
nordvpn set autoconnect on Norway

#
PEERS_FILE="$(dirname "$0")/peers.json"

# Check if the peers file exists
Expand All @@ -67,8 +77,25 @@ if ! mapfile -t ALL_PEERS < <(jq -r '.all_peers[]' "$PEERS_FILE"); then
exit 1
fi

if ! mapfile -t FILESHARE_PEERS < <(jq -r '.allowed_for_fileshare[]' "$PEERS_FILE"); then
echo "Error: Failed to parse 'allowed_for_fileshare' from '$PEERS_FILE'." >&2
echo "Please ensure it's a valid JSON file with an 'allowed_for_fileshare' key containing an array of strings." >&2
exit 1
fi

echo "Reading all peers from '$PEERS_FILE'..."
if ! mapfile -t ALL_PEERS < <(jq -r '.all_peers[]' "$PEERS_FILE"); then
echo "Error: Failed to parse 'all_peers' from '$PEERS_FILE'." >&2
echo "Please ensure it's a valid JSON file with an 'all_peers' key containing an array of strings." >&2
exit 1
fi

echo "Configuring fileshare and auto-accept for specific peers..."
for PEER in "${FILESHARE_PEERS[@]}"; do
# Don't try to change permissions for the device this script is running on.
if [[ "$PEER" == "$NICKNAME" ]]; then
continue
fi
nordvpn meshnet peer fileshare allow "$PEER" && echo " - Allowed fileshare for '$PEER'."
nordvpn meshnet peer auto-accept enable "$PEER" && echo " - Enabled auto-accept for '$PEER'."
done
Expand Down
8 changes: 8 additions & 0 deletions bash/nord/exit_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,19 @@ fi

echo "Allowing specific peers to route through '$NICKNAME':"
for PEER in "${ROUTING_PEERS[@]}"; do
# Don't try to change permissions for the device this script is running on.
if [[ "$PEER" == "$NICKNAME" ]]; then
continue
fi
nordvpn meshnet peer routing allow "$PEER" && echo " - Allowed '$PEER' to route through this device."
done

echo "Allowing specific peers to access this device's local network:"
for PEER in "${LOCAL_PEERS[@]}"; do
# Don't try to change permissions for the device this script is running on.
if [[ "$PEER" == "$NICKNAME" ]]; then
continue
fi
nordvpn meshnet peer local allow "$PEER" && echo " - Allowed '$PEER' to access this device's local network."
done

Expand Down