Skip to content

Accept not sending in a nickname. - #11

Merged
terjeinnerdal merged 2 commits into
mainfrom
accept_no_nickname
Apr 26, 2026
Merged

Accept not sending in a nickname.#11
terjeinnerdal merged 2 commits into
mainfrom
accept_no_nickname

Conversation

@terjeinnerdal

@terjeinnerdal terjeinnerdal commented Apr 26, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Configuration and exit-node scripts now auto-detect your device's Meshnet nickname so you typically don’t need to pass it manually.
  • Improvements

    • Scripts attempt nickname reuse before erroring and only show help/exit if detection fails.
    • Auto-connect configuration behavior updated for clearer startup handling.

@coderabbitai

coderabbitai Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ee766df9-6171-4314-b8b7-c6f7b228989f

📥 Commits

Reviewing files that changed from the base of the PR and between e121302 and d3f3bda.

📒 Files selected for processing (2)
  • bash/nord/config.sh
  • bash/nord/exit_node.sh
🚧 Files skipped from review as they are similar to previous changes (2)
  • bash/nord/exit_node.sh
  • bash/nord/config.sh

📝 Walkthrough

Walkthrough

Two NordVPN shell scripts now auto-resolve a Meshnet device nickname by parsing nordvpn meshnet peer list when no nickname argument is provided. exit_node.sh also removes set -e. config.sh updates autoconnect from nordvpn set autoconnect on to nordvpn set autoconnect on NO.

Changes

Cohort / File(s) Summary
NordVPN Meshnet scripts
bash/nord/config.sh, bash/nord/exit_node.sh
Both scripts accept an optional nickname: if $1 is missing they parse nordvpn meshnet peer list to extract the current device's Nickname and use it; error/help only shown if no nickname found. exit_node.sh no longer sets set -e. config.sh changes autoconnect call to nordvpn set autoconnect on NO and uses "$NICKNAME" in chained commands with && and updated messages.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped through peers and parsed a thread,

Found my nickname where it quietly spread,
No more missing args to make me fret,
Scripts now fetch what I’d already set,
A little hop, a tiny cheer — meshnet's clear! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: the scripts now accept cases where a nickname is not provided as an argument, attempting to reuse existing Meshnet device nicknames instead.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch accept_no_nickname

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (3)
bash/nord/config.sh (2)

42-42: Quote $NICKNAME to be safe.

Minor hygiene: the variable is unquoted here while it's correctly quoted everywhere else in the file (e.g. line 50 in exit_node.sh). Even if nicknames don't contain whitespace today, leaving this unquoted invites future surprises.

Diff
-nordvpn meshnet set nickname $NICKNAME
+nordvpn meshnet set nickname "$NICKNAME"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/config.sh` at line 42, The command invocation uses an unquoted
shell variable NICKNAME in the call to nordvpn meshnet set nickname; update the
invocation for safety by quoting the variable (i.e., use "$NICKNAME") so
whitespace or special chars are handled consistently with other uses like in
exit_node.sh and avoid future word-splitting bugs.

1-10: Consider adding set -e for consistency with exit_node.sh.

exit_node.sh uses set -e at the top so that failed nordvpn … commands abort the script, but config.sh does not. With multiple nordvpn set … and nordvpn meshnet … calls below, a silent failure (e.g. autoconnect rejection, meshnet not authorized) would let the script continue in a half-configured state. Adding set -e (or at minimum checking exit statuses on the critical setup commands) would make behavior consistent and failures visible.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/config.sh` around lines 1 - 10, Add strict-fail behavior to
config.sh by enabling "set -e" near the top (same pattern used in exit_node.sh)
so any failing nordvpn commands (e.g. the various "nordvpn set …" and "nordvpn
meshnet …" calls) abort the script instead of leaving it half-configured;
alternatively, if you prefer not to use set -e, add explicit exit-status checks
after each critical command (checking "$?" or using "|| exit 1") for the
nordvpn-related commands to ensure failures are surfaced and the script stops.
bash/nord/exit_node.sh (1)

32-44: Refactor: extract duplicated nickname-resolution block.

This 12-line block is byte-for-byte identical to the one added in bash/nord/config.sh (lines 25–37). Once the parsing bug above is fixed in one place, the other will drift. Consider extracting into a shared script (e.g. bash/nord/_nickname.sh) and source-ing it from both callers, or wrapping it in a function.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/exit_node.sh` around lines 32 - 44, The nickname-resolution block
(variables EXISTING_NICKNAME / NICKNAME and the call to display_help) is
duplicated; extract it into a shared helper (e.g. a new bash file exporting a
function like resolve_nickname) that sources the logic and returns/sets
NICKNAME, then replace the in-file copy with sourcing that helper and calling
resolve_nickname; ensure the helper exposes the same behavior (sets NICKNAME,
prints the "No nickname provided..." message, calls display_help and exits on
error) so callers like exit_node.sh can simply source the helper and invoke
resolve_nickname "$1".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bash/nord/exit_node.sh`:
- Line 33: The EXISTING_NICKNAME extraction pipeline is wrong: change the
pipeline that sets EXISTING_NICKNAME (currently using nordvpn meshnet peer list
| grep -A 1 "This device:" | grep "Nickname:" | awk '{print $2}') to capture at
least two lines after "This device:" (e.g., grep -A 2) or parse the block with
awk/sed so the "Nickname:" line is included, then strip surrounding whitespace
and reject the placeholder "-" so that if the extracted value is empty or "-"
the script treats it as unset; update the logic around EXISTING_NICKNAME to only
call nordvpn meshnet set nickname when the cleaned value is non-empty and not
"-" (refer to the EXISTING_NICKNAME variable and the pipeline that uses nordvpn
meshnet peer list / grep / awk).

---

Nitpick comments:
In `@bash/nord/config.sh`:
- Line 42: The command invocation uses an unquoted shell variable NICKNAME in
the call to nordvpn meshnet set nickname; update the invocation for safety by
quoting the variable (i.e., use "$NICKNAME") so whitespace or special chars are
handled consistently with other uses like in exit_node.sh and avoid future
word-splitting bugs.
- Around line 1-10: Add strict-fail behavior to config.sh by enabling "set -e"
near the top (same pattern used in exit_node.sh) so any failing nordvpn commands
(e.g. the various "nordvpn set …" and "nordvpn meshnet …" calls) abort the
script instead of leaving it half-configured; alternatively, if you prefer not
to use set -e, add explicit exit-status checks after each critical command
(checking "$?" or using "|| exit 1") for the nordvpn-related commands to ensure
failures are surfaced and the script stops.

In `@bash/nord/exit_node.sh`:
- Around line 32-44: The nickname-resolution block (variables EXISTING_NICKNAME
/ NICKNAME and the call to display_help) is duplicated; extract it into a shared
helper (e.g. a new bash file exporting a function like resolve_nickname) that
sources the logic and returns/sets NICKNAME, then replace the in-file copy with
sourcing that helper and calling resolve_nickname; ensure the helper exposes the
same behavior (sets NICKNAME, prints the "No nickname provided..." message,
calls display_help and exits on error) so callers like exit_node.sh can simply
source the helper and invoke resolve_nickname "$1".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b1d1fb9f-ba48-44e0-8791-1bc79928ae94

📥 Commits

Reviewing files that changed from the base of the PR and between 760ac55 and e121302.

📒 Files selected for processing (2)
  • bash/nord/config.sh
  • bash/nord/exit_node.sh

Comment thread bash/nord/exit_node.sh
@terjeinnerdal

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@terjeinnerdal
terjeinnerdal merged commit cd6015a into main Apr 26, 2026
1 check passed
@terjeinnerdal
terjeinnerdal deleted the accept_no_nickname branch April 26, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant