Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(peer): ignore trailing dots when matching our own address
  • Loading branch information
hackobi committed Nov 12, 2026
commit a147dad03020b302f69b0e33befe5c9763fb93a2
1 change: 1 addition & 0 deletions scripts/test-consensus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ SUITE_FILES=(
src/libs/omniprotocol/transport/preauthBuffering.test.ts
src/libs/peer/routines/checkOfflinePeers.test.ts
src/libs/peer/routines/peerBootstrap.test.ts
src/libs/peer/selfUrlAlias.test.ts
src/libs/peer/syncClaims.test.ts
src/libs/utils/clockProbe.test.ts
src/libs/utils/keyMaker.test.ts
Expand Down
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export { loadConfig } from "./loader"
export {
parseNodeUrl,
isLoopbackHost,
stripTrailingDots,
validateExposedUrl,
validateBuildProvenance,
} from "./nodeUrl"
Expand Down
2 changes: 1 addition & 1 deletion src/config/nodeUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function stripZoneId(host: string): string {
return at < 0 ? host : host.slice(0, at)
}

function stripTrailingDots(host: string): string {
export function stripTrailingDots(host: string): string {
let end = host.length
while (end > 0 && host.charCodeAt(end - 1) === 46) end--
return host.slice(0, end)
Expand Down
7 changes: 5 additions & 2 deletions src/libs/peer/PeerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Peer from "./Peer"
import log from "src/utilities/logger"
import { getSharedState } from "src/utilities/sharedState"
import { isLoopbackHost, parseNodeUrl } from "src/config"
import { isLoopbackHost, parseNodeUrl, stripTrailingDots } from "src/config"

Check warning on line 17 in src/libs/peer/PeerManager.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'src/config' imported multiple times.

See more on https://sonarcloud.io/project/issues?id=kynesyslabs_node&issues=AaHO_mwv0v7uGd5-a7hL&open=AaHO_mwv0v7uGd5-a7hL&pullRequest=1198
import { RPCResponse } from "@kynesyslabs/demosdk/types"
import type { HelloPeerRequest } from "../network/manageHelloPeer"
import {
Expand Down Expand Up @@ -597,7 +597,10 @@

try {
const ours = new URL(getSharedState.exposedUrl)
return url.hostname === ours.hostname && url.port === ours.port
return (
stripTrailingDots(url.hostname) ===
stripTrailingDots(ours.hostname) && url.port === ours.port
)
} catch (_e) {
return false
}
Expand Down
2 changes: 2 additions & 0 deletions src/libs/peer/selfUrlAlias.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const sharedState: Record<string, unknown> = {
mockCore(sharedState)
mockHelloDeps()

// eslint-disable-next-line @typescript-eslint/naming-convention
const { default: PeerManager } = await import("src/libs/peer/PeerManager")
// eslint-disable-next-line @typescript-eslint/naming-convention
const { Peer } = await import("src/libs/peer")

function clearTable() {
Expand Down
Loading