Skip to content

Commit 9465e20

Browse files
jolavilletteclaude
andcommitted
fix(peermgr): default SSL-only friends to RS_NODE_PERM_NONE
addSslOnlyFriend() registers a friend without creating an entry in mFriendsPermissionFlags. This is the path taken by every short-invite add (webui, mobile, QR code). Later, gossip discovery (p3gossipdiscovery.cc) and loadList() call addFriend() with the RS_NODE_PERM_ALL "keep existing flags" mask, which is only reduced (service_flags &= entry) when a per-friend entry already exists. For SSL-only friends no entry exists, so the RS_NODE_PERM_ALL mask is written verbatim and persisted, silently granting the peer DIRECT_DL | ALLOW_PUSH | REQUIRE_WL. The stray REQUIRE_WL then makes incoming connections from non-whitelisted addresses get refused (NOT_WHITELISTED) in pqissl::accept_locked(), spamming the log with "This should never happen at this point!" stack traces. GUI-added friends are unaffected because addFriend() always writes an entry (RS_NODE_PERM_DEFAULT). Establish the same default here so the downstream mask stays a no-op. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 92cf193 commit 9465e20

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/pqi/p3peermgr.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,19 @@ bool p3PeerMgrIMPL::addSslOnlyFriend( const RsPeerId& sslId, const RsPgpId& pgp_
11851185
{ RS_STACK_MUTEX(mPeerMtx);
11861186
mFriendList[sslId] = pstate;
11871187
mStatusChanged = true;
1188+
1189+
/* Establish default (empty) service permissions for this PGP id if none
1190+
* exist yet. This is essential: addSslOnlyFriend() is the entry point
1191+
* used by short invites (webui, mobile, QR code...) and, unlike
1192+
* addFriend(), it would otherwise leave mFriendsPermissionFlags without
1193+
* an entry for this friend. Later on, gossip discovery and loadList call
1194+
* addFriend() with the RS_NODE_PERM_ALL "keep the existing flags" mask,
1195+
* relying on the per-friend entry to reduce it (service_flags &= entry).
1196+
* With no entry that mask is written verbatim, silently granting the peer
1197+
* DIRECT_DL | ALLOW_PUSH | REQUIRE_WL. Registering RS_NODE_PERM_NONE here
1198+
* makes the mask a no-op and matches the default of GUI-added friends. */
1199+
if(mFriendsPermissionFlags.find(pgp_id) == mFriendsPermissionFlags.end())
1200+
mFriendsPermissionFlags[pgp_id] = RS_NODE_PERM_NONE;
11881201
} // RS_STACK_MUTEX(mPeerMtx);
11891202

11901203
IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW);

0 commit comments

Comments
 (0)