Draft
Conversation
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
There was a problem hiding this comment.
Code Review
这个 PR 引入了对蓝图分享的多源支持,是一个很棒的功能增强。主要变更包括:
- 新增了
PastebinShare.kt模块,用于管理多个分享源(如pastebin.com和PrivateBin),并实现了上传时的失败回退逻辑。 - 引入了新的
SchemV2聊天协议,以更好地区分不同来源的分享,并为PrivateBin增加了客户端加密支持。 - 对
ShareFeature.kt进行了重构,使其利用新的分享模块,简化了代码。
代码整体结构清晰,对新旧协议的兼容性处理考虑得比较周到。
我发现了一些与自定义加密实现相关的潜在风险,并已在代码中提出了具体的审查意见。请关注这些安全性和健壮性方面的建议。
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.
变更概览
https://pastebin.com,并将默认备用源临时调整为https://0x0.st。pastebin.com时继续发送旧版聊天分享格式;其他源统一改走新的SchemV2协议,避免旧版客户端误去pastebin.com/raw/<code>拉取错误内容。SchemV2,其中0x0.st备用源按直链方式读取。这次为什么临时去掉 PrivateBin
PrivateBin方案暂时回滚了。0x0.st当前更适合作为临时替代:它不要求客户端额外实现加解密协议,上传和读取都是普通 HTTP 流程,故障面明显更小。参考的 0x0.st 使用方式
基于
https://0x0.st/当前公开说明,这次接入使用了它的基础文件上传接口:multipart/form-datafile: 上传文件内容secret: 让返回链接更难猜expires: 控制过期时间User-Agent实现细节
1. 新增分享源配置模块
src/mindustryX/features/PastebinShare.kt。SettingsV2.Data<List<Source>>("arcExtra.schematicShare.pastebinSources", ...)持久化分享源列表。Source当前包含:enabled:是否参与上传尝试type:pastebin/directname:显示名baseUrl:站点基地址expire:该源使用的过期时间参数2. 上传逻辑改为“多源回退 + 成功源记忆”
ShareFeature.shareSchematic()/shareSchematicClipboard()现在统一委托给PastebinShare.upload()。PastebinShare.upload()会按已启用源顺序尝试上传;若某源失败,则记录失败原因并继续尝试下一个源。http(s)://.../<id><id>Bad API request, ...或其他非预期文本都视为失败并继续回退3. 0x0.st 备用源接入方式
https://0x0.stmultipart/form-datasecret=1expires=24(小时)User-Agent: MindustryX-schematic-share/<version>ShareLinkPrivateBin的本地解密步骤4. 聊天分享协议升级
旧协议(仅
pastebin.com继续使用)<MDTX {Iconc.paste}><ARCxMDTX><Schem> ... <id>新协议(非
pastebin.com源)<MDTX {Iconc.link}><ARCxMDTX><SchemV2> <type> <baseUrl> <id>Iconc.paste<Schem>type目前支持:pastebin:按<baseUrl>/raw/<id>读取direct:按<baseUrl>/<id>直接读取5. 接收端兼容
ShareFeature.resolve()顺序调整为:先解析SchemV2,再回退到旧<Schem>/<MDTX paste>逻辑。resolveSchematicShareV2()只在ArcOld.schematicShare开启时工作,行为与旧逻辑保持一致。6. 文案与设置
assets/bundles/bundle-mdtx.propertiesassets/bundles/bundle-mdtx_en.propertiessettingV2.arcExtra.schematicShare.pastebinSources.name/description0x0.st,原因是它更稳定兼容性说明
pastebin.com,因此“默认配置下的首次行为”仍然是旧协议。pastebin.com失效并回退到其他源时,消息自动切换为SchemV2,这是为了防止旧客户端错误拉取。shareSchematicClipboard()在回退到0x0.st时会复制站点返回的完整直链。验证
work/下执行:gradle :core:compileKotlin --stacktrace后续评审重点
0x0.st在实际蓝图分享频率下的稳定性和可接受性SchemV2协议字段是否需要进一步抽象,而不是仅靠type + baseUrl + idPrivateBin,建议单独做成独立分支重新验证