Ignore:
Timestamp:
06/26/2026 12:50:25 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
c7c7f02
Parents:
4c47eff
Message:

feat(ap): log source IP on dropped/rejected/ignored inbox hits

So an operator can see WHO is probing their fediverse inbox (e.g. unsigned/unknown
activities like Block/View). Uses req.ip (real client behind the proxy via trust
proxy). Added to the blocked, signature-rejected and ignored log lines:

[AP] inbox Block -> boiert from 1.2.3.4 (ignored)

No behavior change — visibility only.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    r4c47eff rbbce8da  
    569569  const act = req.body || {};
    570570  const type = act.type;
     571  // Real client IP (behind the proxy via `trust proxy`) — logged on dropped/rejected/
     572  // ignored inbox hits so an operator can see who is probing their fediverse inbox.
     573  const ip = req.ip || (req.connection && req.connection.remoteAddress) || '?';
    571574  const base = (process.env.PUBLIC_BASE_URL || `${req.protocol}://${req.get('host')}`).replace(/\/+$/, '');
    572575  const verified = await verifyRequest(req).catch(() => null);
     
    577580  const claimedActor = typeof act.actor === 'string' ? act.actor : (act.actor && act.actor.id);
    578581  // Blocked actor/domain → silently drop (202, don't reveal the block).
    579   if (claimedActor && isBlockedAny(claimedActor)) { console.log('[AP] inbox dropped (blocked)', claimedActor); return 202; }
     582  if (claimedActor && isBlockedAny(claimedActor)) { console.log('[AP] inbox dropped (blocked)', claimedActor, 'from', ip); return 202; }
    580583  const GATED = ['Create', 'Like', 'Announce', 'Follow', 'Delete', 'Undo', 'Accept', 'Reject', 'Add', 'Remove', 'Update'];
    581584  if (GATED.includes(type)) {
    582585    if (!verified || !claimedActor || verified.id !== claimedActor) {
    583       console.warn('[AP] inbox REJECTED (signature)', type, claimedActor || '?', verified ? '(signer mismatch)' : '(unsigned/invalid)');
     586      console.warn('[AP] inbox REJECTED (signature)', type, claimedActor || '?', 'from', ip, verified ? '(signer mismatch)' : '(unsigned/invalid)');
    584587      return 401;
    585588    }
     
    708711  }
    709712
    710   console.log('[AP] inbox', type || 'unknown', '→', slugParam || 'shared', '(ignored)');
     713  console.log('[AP] inbox', type || 'unknown', '→', slugParam || 'shared', 'from', ip, '(ignored)');
    711714  return 202;
    712715}
Note: See TracChangeset for help on using the changeset viewer.