Repository navigation
Add M-Team metafile download through the signed link - #27
Merged
Merged
Conversation
M-Team serves a .torrent only through a signed link: genDlToken returns it, and fetching it may redirect once. Add a linked metafile route for that flow without widening the direct contract TJUPT uses. - site: NewLinkedMetafileFetchConfig declares a linked route. The new MaxLinkRequests limit and LinkRequestsAttempted usage count the requests before the one metafile GET; MaxRequests still means that GET and RedirectsFollowed stays 0. Both fields are omitempty, so TJUPT reports and sealed binding records keep their exact bytes, and Record.Validate bounds the link count. - httpguard: SecretLink holds a signed URL that redacts itself when formatted, and GetLinkOnce sends one credential-free GET of it, reporting a redirect target only when the caller approves it. - mteam: route mteam.download_by_token.v1 POSTs genDlToken, accepts only an HTTPS dlv2 link on an M-Team host signed for the requested ID, pauses 3s, GETs it on a fresh client bound to that host, and follows one redirect only to an HTTPS m-team.cc or m-team.io host on the default port. Not-found, daily-limit, and burst refusals map to not_found and rate_limited. - cli: site metafile fetch accepts --api-key-stdin, names the required credential flag before reading stdin, and reports the link accounting, linked scope, evidence basis, and warnings. not_found joins the public stop reasons. Live, the route was exercised only against IDs with no torrent: genDlToken signs a link for any ID, so not_found is read from the link's JSON answer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
M-Team serves a
.torrentonly through a signed link:POST /api/torrent/genDlTokenreturns it, and fetching it may redirect once. This adds a linked metafile route for that flow. The direct contract TJUPT uses is unchanged.Route
mteam.download_by_token.v1:POST /api/torrent/genDlToken(API key, form fieldid). The link is accepted only if it is HTTPS, on an M-Team host, at/api/rss/dlv2, and signed for exactly the requested ID.m-team.cc/m-team.iohost on the default port: one more GET on another such client. These targets stop asredirect_rejectedwithout ever being contacted: another host, a lookalike domain, an explicit port,http:,magnet:, or a second redirect.Supporting changes:
httpguard.SecretLinkandGetLinkOncecarry the signed link and the redirect target. Both redact themselves when formatted and never appear in errors, reports, or records.MaxRequestsstays 1 and still means the metafile GET. The token request and a redirect hop are counted in the newLinkRequestsAttempted, bounded by the newMaxLinkRequests(2).RedirectsFollowedstays 0. The CLI accepts a success only whenrequests_made == 1 + link_requests_attempted. The sealed binding record validates the same bound.not_found; the per-torrent daily limit, request bursts, code4, and HTTP 429 map torate_limited.Deliberate public changes
torrent.metafile.read_effectful, sosite listshows a capability count of5for it.site metafile fetchaccepts--api-key-stdin. The usage line is nowptctl site metafile fetch (--cookie-stdin | --api-key-stdin) .... Help text gains a section on direct and linked routes and a "Credentials" section.--api-key-stdin is required; ...for mteam. These are new messages:--cookie-stdin and --api-key-stdin are mutually exclusive, andsite %q does not support %s authentication.limits.max_link_requestsandused.link_requests_attemptedare added and omitted for direct routes. TJUPT JSON, human output, and sealed records are byte-identical.site_link_requests_then_one_remote_metafile_get;effectful_site_issued_link_get_for_remote_id;LINK REQUEST LIMITandLINK REQUESTS USEDlines in the table output.not_foundis now a public metafile stop reason.Live verification
The account is in its newbie-task period, so no real torrent was downloaded. The route was exercised only against IDs with no torrent:
genDlTokensigns a link even for a nonexistent ID. That link points atapi2.m-team.cc.1with the not-found message. That answer motivated readingnot_foundat the link step.ptctl site metafile fetch --api-key-stdin ... mteam 99999999then reportednot_foundwithrequests_made2, and the output contained no link material./api/rss/dlv2answers JSON參數錯誤with no redirect.redirect_rejectedbefore contacting it.Reconciliation still reads live site detail with a cookie only.
Tests
SIGN-CANARYlinks, a metafile announcing totracker.invalid, and CANARY keys.gofmt,go vet ./...,go test -race ./...,go build -trimpath ./cmd/ptctl.Docs updated: MTEAM_ADAPTER (new "Metafile download" section), ADDING_A_SITE gaps table, FEATURES, ARCHITECTURE B1, THREAT_MODEL, AUTOMATION, guide/metafiles, guide/sites, and both READMEs.
🤖 Generated with Claude Code