feat: add WinZip AES CTR zip encryption#91
Closed
ayueyang wants to merge 7 commits into
Closed
Conversation
adcf510 to
6d4aa22
Compare
added 6 commits
June 9, 2026 20:14
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.
这个 PR 做什么
新增一种算法:
winzip-aes-ctr。命中该算法的路径上传文件时,会把原文件包装成标准单文件 WinZip AES ZIP:
加密后的完整原文件名.zip,例如视频.mp4不再存成.mp4.zip,raw 侧不暴露原扩展名。payload.ext,例如payload.mp4,保证解压出来能直接播放,同时不暴露原标题。未命中
winzip-aes-ctr的路径继续走原来的aesctr、rc4等逻辑。ZIP 识别方式
受管文件:
.zip。.zip前面的部分能用当前路径密码和winzip-aes-ctr解出完整原文件名。.zip。外部压缩软件制作的 ZIP:
abc.zip或abc.mp4.zip。abc.zip时才懒识别;命中后本次详情页按内部文件类型播放,不命中就保持普通 ZIP 下载页。zipAutoCache,列表请求只把外部 ZIP 放入低优先级后台队列,后台单并发探测并写缓存,列表响应本身不等待、不改名、不改 type。电影.mp4时按视频处理。是否可播放不只看文件名。代码会解析 ZIP 原生字段,并且同时满足这些条件才按可播放 ZIP 处理:
99。0x9901,vendor 为AE。0。compressed size = plain size + salt + password verifier + auth code,确认是可直接 Range 映射的 Store AES 数据。普通 ZIP、多文件 ZIP、非 WinZip AES、或压缩方式不是 Store 的 ZIP 会保持普通 ZIP 处理,不进入在线播放解密逻辑;失败探测会写短期 negative cache,避免同一个普通 ZIP 被反复探测。
主要代码位置
node-proxy/src/utils/winZipAesZip.jspayloadOffset,把明文 Range 映射到 ZIP payload 密文 Range。content-range、content-length、content-type。node-proxy/src/utils/winZipAesZipCache.jsnode-proxy/src/utils/flowEnc.jswinzip-aes-ctr类型。node-proxy/app.js/api/fs/get点击文件时懒识别外部 ZIP,命中后返回明文大小和代理 raw_url。/redirect/:key和下载代理按 Range 解密返回。node-proxy/src/encNameRouter.js.zip在列表中恢复原名;外部 raw.zip默认列表不解析,只在zipAutoCache开启时入队。node-proxy/src/encDavHandle.jsnode-proxy/src/dao/fileDao.jsnode-proxy/src/utils/commonUtil.tsconvertRealName()/convertShowName()的 WinZip AES 文件名映射。isEncryptedZipName()/isRawZipName()区分受管文件和外部 ZIP。getAListFileTypeByName()用虚拟名或内部名还原 AList 类型。enc-webui/src/views/setting-alist/index.vueenc-webui/src/views/setting-webdav/index.vueWinZip-AES-CTR选项,配置值为winzip-aes-ctr。ZIP缓存开关,保存到zipAutoCache,默认关闭。node-proxy/test/winZipAesZipTest.js性能测试
测试口径:从
/api/fs/get开始计时,到raw_url的Range: bytes=0-31真正拿到包含ftyp的视频字节为止。每个视频 10 次,每次间隔 10 秒。/api/fs/get平均1920-1080-4205-h264.mp42026-01-08 17-59-30.mp41920-1080-4205-h264.mp42026-01-08 17-59-30.mp4结果:受管 WinZip AES ZIP 开启
zipInfoCache后,/api/fs/get不再重复解析 ZIP 字段,从约 0.95s - 1.03s 降到约 0.02s - 0.03s。总耗时主要剩远端 Range 请求;以上请求均返回206,首段都包含ftyp。验证
本地已验证:
npm exec -- ts-node -r tsconfig-paths/register test/winZipAesZipTest.js git diff --check npm run webpack结果:
winZipAesZipTest okgit diff --check通过npm run webpack通过,仅有原项目 log4js 动态依赖 warning也做过本地手动验证:
.zip。.mp4。206 video/mp4,首段包含ftyp。