fix: skip local daemon when cloning repos owned by a different DID#177
Open
LiranCohen wants to merge 1 commit into
Open
fix: skip local daemon when cloning repos owned by a different DID#177LiranCohen wants to merge 1 commit into
LiranCohen wants to merge 1 commit into
Conversation
resolveLocalDaemon() unconditionally routed all DID requests to the local daemon at localhost, regardless of which DID was being cloned. When machine B tried to clone machine A's repo, the resolver hit machine B's own daemon (which doesn't have the repo) and returned 404. Changes: - Add ownerDid field to DaemonLock type and writeLockfile() - Pass ctx.did from serve.ts so the lockfile records the daemon owner - In resolveLocalDaemon(), compare requested DID against lockfile ownerDid — only use local daemon when they match - Lockfiles without ownerDid (from older versions) are treated as matching for backwards compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes cloning repos from another user's DID. Previously,
resolveLocalDaemon()unconditionally routed all DID requests tolocalhost, so cloningdid::did:dht:machineA/repoon machine B would hit machine B's own daemon (which doesn't have the repo) and fail with 404.Root cause: The lockfile had no concept of which DID the daemon serves, so
resolveLocalDaemon()had no way to distinguish "my DID" from "someone else's DID."Changes:
ownerDidfield toDaemonLocktype andwriteLockfile()(src/daemon/lockfile.ts)ctx.didfromserve.tsso the lockfile records the daemon ownerresolveLocalDaemon(), compare requested DID againstlock.ownerDid— only use local daemon when they match; otherwise fall through to DID document resolutionownerDid(written by older versions) are treated as matching for backwards compatibilityTests added:
ownerDidwrite/readresolveGitEndpointuses local daemon when owner matchesresolveGitEndpointskips local daemon when owner differsBuild, test, and lint all pass.