Skip to content

Commit feb4a86

Browse files
committed
Reuse remote host helper in inbox metrics
Route signature verification failure metrics through the shared remote host helper so inbox rejection paths use the same host extraction as delivery metrics. #755 (comment) #755 (comment) #755 (comment) Assisted-by: gpt-5.5
1 parent 876e81c commit feb4a86

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

packages/fedify/src/federation/handler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import type {
6464
import { routeActivity } from "./inbox.ts";
6565
import { KvKeyCache } from "./keycache.ts";
6666
import type { KvKey, KvStore } from "./kv.ts";
67-
import { getFederationMetrics } from "./metrics.ts";
67+
import { getFederationMetrics, getRemoteHost } from "./metrics.ts";
6868
import type { MessageQueue } from "./mq.ts";
6969
import { acceptsJsonLd } from "./negotiation.ts";
7070

@@ -995,8 +995,8 @@ async function handleInboxInternal<TContextData>(
995995
});
996996
if (verification.verified === false) {
997997
const reason = verification.reason;
998-
const remoteHost = "keyId" in reason
999-
? reason.keyId?.hostname
998+
const remoteHost = "keyId" in reason && reason.keyId != null
999+
? getRemoteHost(reason.keyId)
10001000
: undefined;
10011001
getFederationMetrics(parameters.meterProvider)
10021002
.recordSignatureVerificationFailure(reason.type, remoteHost);
@@ -1137,7 +1137,7 @@ async function handleInboxInternal<TContextData>(
11371137
getFederationMetrics(parameters.meterProvider)
11381138
.recordSignatureVerificationFailure(
11391139
"actorKeyMismatch",
1140-
httpSigKey.id?.hostname,
1140+
httpSigKey.id == null ? undefined : getRemoteHost(httpSigKey.id),
11411141
);
11421142
logger.error(
11431143
"The signer ({keyId}) and the actor ({actorId}) do not match.",
@@ -1170,7 +1170,7 @@ async function handleInboxInternal<TContextData>(
11701170
getFederationMetrics(parameters.meterProvider)
11711171
.recordSignatureVerificationFailure(
11721172
"invalidNonce",
1173-
httpSigKey?.id?.hostname,
1173+
httpSigKey?.id == null ? undefined : getRemoteHost(httpSigKey.id),
11741174
);
11751175
logger.error(
11761176
"Signature nonce verification failed (missing, expired, or replayed).",

0 commit comments

Comments
 (0)