Skip to content

Add WHOIS privacy user mode +p - #267

Open
Jazzzzz-hub wants to merge 2 commits into
DALnet:masterfrom
Jazzzzz-hub:whois-privacy-mode
Open

Jazzzzz-hub wants to merge 2 commits into
DALnet:masterfrom
Jazzzzz-hub:whois-privacy-mode

Conversation

@Jazzzzz-hub

Copy link
Copy Markdown
Contributor

Summary

This pull request adds a new user mode, +p, to provide optional WHOIS privacy.

When +p is enabled, selected WHOIS information is hidden from normal users while remaining visible to IRC operators and to the user performing a WHOIS on themselves.

Behaviour

When the WHOIS target has +p enabled:

  • RPL_WHOISCHANNELS (319) is hidden from normal users.
  • RPL_WHOISIDLE (317) is hidden from normal users.
  • IRC operators continue to receive the full WHOIS response.
  • Self-WHOIS continues to return the full WHOIS response.
  • Other standard WHOIS information remains unchanged.

A new WHOIS reply is also added:

320 RPL_WHOISPRIVACY

Example:

Jazzzzz is using WHOIS privacy mode (+p)

@Jazzzzz-hub

Copy link
Copy Markdown
Contributor Author

New User Mode

+p - WHOIS privacy

This is separate from the existing channel mode +p.

The existing uppercase user mode +P remains unchanged.

Implementation

The patch:

  • Adds UMODE_p
  • Adds IsUmodep()
  • Adds p to the user-mode table
  • Includes UMODE_p in USER_UMODES
  • Includes UMODE_p in SEND_UMODES
  • Updates relevant user-mode handling to use long
  • Hides WHOIS channel information for normal users when +p is enabled
  • Hides WHOIS idle/sign-on information for normal users when +p is enabled
  • Keeps full WHOIS visibility for IRC operators
  • Keeps full WHOIS visibility for self-WHOIS
  • Adds RPL_WHOISPRIVACY as numeric 320

Access Behaviour

Requester Target has +p Channels Idle / Sign-on
Normal user Yes Hidden Hidden
IRC operator Yes Visible Visible
Self-WHOIS Yes Visible Visible
Any user No Existing behaviour Existing behaviour

Testing

Tested on a standalone Bahamut 2.2.4 server.

Verified:

  • MODE nick +p
  • MODE nick -p
  • +p appears in the user's active modes
  • Normal WHOIS hides channel information
  • Normal WHOIS hides idle/sign-on information
  • IRC operator WHOIS remains complete
  • Self-WHOIS remains complete
  • Numeric 320 is returned when +p is active
  • Disabling +p restores normal WHOIS behaviour
  • WATCH/client reconnect behaviour remains functional
  • Server remains stable after restart

Implementation Note

UMODE_p currently uses 0x80000000L.

The implementation has been tested on a 64-bit build where long provides sufficient width. Relevant user-mode table variables were updated to use long.

Review from the SRC team would be appreciated regarding portability expectations on platforms where the width or signedness of long may differ.

@devin-ai-integration

Copy link
Copy Markdown

Thanks for this. I built it and tested it on a local 3-server network. WHOIS works as described: normal users, on the same server or a remote one, and including WHOIS nick nick, get no 319/317 and do get the 320 line. Opers and the user themselves get the full WHOIS, and -p restores normal output. A few things need fixing before this can merge, though.

Required changes

  1. Rebase on Use long consistently for user mode bitmasks #271 and drop the type changes from this PR. The two PRs conflict in src/m_services.c and src/s_user.c. This PR's copy of the long changes is also incomplete: send_umode_out(..., int old) and m_rwho.c's int umodes[2] are still int. Because of that, RWHO m p returns no users: bit 31 gets sign-extended, so (umode & mask) != mask is always true. When I applied Use long consistently for user mode bitmasks #271's two changes to this branch, RWHO m p worked.
  2. UMODE_p, 'p' is inside #ifdef SPAMFILTER in user_modes[] (see the inline comment). Without SPAMFILTER, p is still in USER_UMODES, but the mode can't be set or sent to other servers.
  3. WHO +nC <nick> bypasses the mode. C asks WHO for the channel column, and first_visible_channel() in src/m_who.c hands any user the target's first visible channel, whether or not they're +p (or +i). WHO's channel lookup needs the same !IsUmodep(ac) || IsAnOper(sptr) || sptr == ac check. InspIRCd's hidechans hooks WHO for the same reason.
  4. The 004 welcome line doesn't list p. That mode list is hardcoded in src/s_err.c (the RPL_MYINFO line). doc/opers.txt should also document the new mode.
  5. Please undo the unrelated reformatting. The 319 channel loop was re-wrapped, the send_umode() signature was reformatted, and two new if lines are indented 16 spaces. Wrapping the existing loop in one guard keeps the diff small.
  6. The WARNING ... 0x40000000 comment in include/struct.h now contradicts the new bit. Fixing it in Use long consistently for user mode bitmasks #271 is fine.

Design: matching other ircds

  • UnrealIRCd (+p), ircd-hybrid (+p), Solanum's hide_uncommon_channels and Ergo all keep showing channels that the person asking shares with the target. This PR hides those too, which also makes it inconsistent with WHO +nC. Please show shared channels (IsMember(sptr, chptr)).
  • Hybrid hides idle time with a separate mode (+q), and Solanum's idle-hiding add-on uses +I. Unreal's +p only hides channels. Consider splitting idle-hiding into its own mode, or at least say clearly in the docs that +p hides both.
  • Numeric 320 is RPL_WHOISSPECIAL (a free-text WHOIS line) in UnrealIRCd, InspIRCd and Solanum, and RPL_WHOISWEBIRC in ircu. Your <nick> :text format is compatible with how clients display it. You could define it generically as ":%s 320 %s %s :%s" so other WHOIS notes can reuse it.
  • Channel membership is still visible through NAMES and WHO #chan for users who aren't +i. That's expected and matches other ircds, but the docs should say +p only covers WHOIS (and WHO once item 3 is fixed).

Written by Devin

Comment thread src/s_user.c Outdated
UMODE_I, 'I',
#ifdef SPAMFILTER
UMODE_P, 'P',
UMODE_p, 'p',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is inside #ifdef SPAMFILTER. Builds without SPAMFILTER would have UMODE_p in USER_UMODES but no entry in this table, so MODE nick +p couldn't be set or sent to other servers. Please move it below the #endif.

Comment thread src/s_user.c Outdated
#endif
mlen = strlen(me.name) + strlen(parv[0]) + 9 + strlen(name);
for (len = 0, *buf = '\0', lp = user->channel; lp; lp = lp->next)
if (!IsUmodep(acptr) || IsAnOper(sptr) || sptr == acptr)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The indentation here is off (16 spaces), and the loop below was re-wrapped even though its logic didn't change. Could you keep the original loop and add only this guard? Also, other ircds with this mode still show channels the requester shares with the target. Consider moving the check inside the loop as something like if (IsUmodep(acptr) && !IsAnOper(sptr) && sptr != acptr && !IsMember(sptr, chptr)) continue;.

@Jazzzzz-hub

Copy link
Copy Markdown
Contributor Author

Updated the PR based on the review feedback.

Changes made:

  • Rebased cleanly on merged Use long consistently for user mode bitmasks #271 and removed duplicate/incomplete user-mode type changes from this PR.
  • Moved UMODE_p, 'p' outside #ifdef SPAMFILTER.
  • Fixed the WHO +nC privacy bypass.
  • Shared channels remain visible for +p users, while non-shared channels are hidden.
  • Added p to numeric 004.
  • Documented +p behavior in doc/opers.txt.
  • Removed unrelated formatting changes to keep the diff small.
  • Updated the old 0x40000000 warning for the new user-mode bit.

Runtime testing completed:

  • MODE +p / -p
  • RWHO m p
  • shared vs non-shared WHOIS channels
  • WHO +nC with a shared channel
  • WHO +nC with no shared channel returns *
  • self-WHOIS
  • oper WHOIS bypass
  • idle/signon hiding
  • normal behavior restoration after -p

The branch now contains a single clean +p commit on top of #271.

@Jazzzzz-hub

Jazzzzz-hub commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

@eaescob Just following up on this PR.

The requested review fixes have been applied and tested, and the branch was rebased on the merged user-mode bitmask changes.

From our earlier discussion, I believe the remaining question is the design choice around +p whether it should continue hiding both non-shared WHOIS channels and idle/sign-on information, or whether idle privacy should be split into a separate user mode.

I have left the current implementation as one +p mode for now and documented its behaviour clearly.

When you get a chance, please let me know which direction you prefer, or if there is anything else you would like changed in #267.

-Jazzzzz

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