fix: replace PREFIX_FULL_URL with API_PREFIX for cache-121.199.60.4 mirror#3
Open
ZenthXSin wants to merge 1 commit into
Open
Conversation
…irror The cache-121.199.60.4 server only proxies GitHub API v3 paths (/github/repos/...). Using Strategy.PREFIX_FULL_URL caused raw.githubusercontent.com URLs (e.g. mods.json) to be rewritten to http://121.199.60.4/github/https://raw.githubusercontent.com/... which the server cannot handle, returning HTTP 403. Replace with the new Strategy.API_PREFIX that: - Rewrites api.github.com URLs to the cache prefix (correctly) - Passes through raw.githubusercontent.com, github.com, and codeload.github.com URLs unchanged (skips unsupported origin types) This preserves the mirror for API requests while letting other candidates (gh.tinylake.top, ghproxy.com, etc.) handle downloads.
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.
问题
cache-121.199.60.4镜像使用Strategy.PREFIX_FULL_URL,对所有 GitHub 源头 URL 做prefix + fullUrl拼接:但该服务器只处理 GitHub API v3 路径(
/github/repos/...),对其他 URL 类型(raw、codeload、github.com 页面)一律返回 HTTP 403。这导致:MindustryModsIndexRepository.fetch()走MirrorSelector.wrap(INDEX_URL)→ raw URL → 403 → 回退到其他镜像/github/repos/...)只由硬编码的Metadata.UPSTREAM_MOD_INDEX和GitHubReleaseClient.CACHE_API_BASE生成,不走 MirrorSelector修复
不删镜像,改为新增
Strategy.API_PREFIX,只改写api.github.com来源的 URL:prefix + url.substring("https://api.github.com/".length())→http://121.199.60.4/github/repos/Anuken/Mindustry/...raw.githubusercontent.com、github.com、codeload.github.com来源保持原样,由其他镜像或直连处理测试验证