Conversation
1. 修复 Amazon Prime Video 地区提取贪婪匹配导致抓取 Minerva 遥测 JS 乱码及终端折行 2. 修复 DB-IP 请求单引号字面量导致 $CurlARG 未展开丢失网络参数 3. 修复 YouTube 中国大陆地区硬编码 ANSI 颜色导致污染 JSON 归档 4. 修复 Check_DNS_3 在缺少 dig 或查询超时时将原生解锁误判为 DNS 解锁 5. 修复 Check_DNS_IP 在解析失败或未获取到 IP 时将原生解锁误判为 DNS 解锁 6. 补充 IP2Location 数据库公司类型 (Company Type) 写入 JSON 归档
在请求 ipapi 数据库后补充 JSON 合法性校验和提前退出机制,并在 awk 计算时对 scorenum 增加非空保护,避免返回 HTML 时触发 10 次 jq 语法报错及 1 次 awk 崩溃报错。
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 针对
ip.sh脚本在流媒体地区提取、网络参数传递、DNS解锁误判、ipapi 拦截崩溃以及 JSON 字段归档方面的 7 处关键 Bug 进行了全面修复与排查验证。详细修复内容
1. Amazon Prime Video 地区提取贪婪匹配导致 JS 乱码与排版坍塌
MediaUnlockTest_PrimeVideo_Region()currentTerritory,sed 's/.*currentTerritory//'存在贪婪匹配,直接截取到了 Amazon 前端 Minerva 遥测 JS 片段([],Program:{dataType:a.MinervaValueDataType.STRING,val:o?]),超长字符串导致终端排版折行。2. DB-IP 请求单引号字面量导致参数未展开
db_dbip()local tmpcurlarg='$CurlARG'使用了单引号字面量,导致$CurlARG(如网络接口--interface或代理-x)无法展开为实际变量值,影响网络协议连接。3. YouTube 中国大陆地区硬编码 ANSI 颜色导致污染 JSON 归档
MediaUnlockTest_Youtube()$Font_Red[CN]$Font_Green直接赋值给youtube[uregion],导致在输出 JSON 归档时产生未清洗干净的 ANSI 控制符乱码(如1mCN2m)。youtube[uregion]=" [CN] "4. DNS 解锁检测中缺少
dig或超时将原生解锁误判为 DNS 解锁Check_DNS_3()dnsutils(缺少dig)或公共 DNS 查询超时丢包时,$resultdnstext为空字符串。上游仅对== "0"进行了判断,导致空字符串落入else: echo 0分支,使得Get_Unlock_Type误判为 DNS 解锁。5. IP 解析失败时将原生解锁误判为 DNS 解锁
Check_DNS_IP()Check_DNS_IP的else分支直接返回0,而Get_Unlock_Type中0对应 DNS 解锁,导致未解析成功时被误报为 DNS 解锁假阳性。1,避免误报:6. IP2Location 数据库公司类型(Company Type)漏写入 JSON 归档
ip2location[scomtype]提取了公司类型并在终端展示,但在组装 JSON 时遗漏了该字段。IP2LOCATION的公司类型写入:type_updates+=".Type |= . * { Company: { IP2LOCATION: \"$(clean_ansi \"${ip2location[scomtype]:-null}\")\" } } | "7.
db_ipapi缺失 JSON 有效性校验导致 WAF 拦截时狂喷 10 次 jq 报错及 1 次 awk 崩溃db_ipapi()echo "$RESPONSE"|jq . >/dev/null 2>&1||RESPONSE=""进行格式校验防御,唯独db_ipapi漏掉了该判断,直接将 HTML 页面喂给后续 10 处jq语句,终端报jq: parse error: Invalid numeric literal。且后续计算ipapi[score]时因数值为空直接触发awk: line 1: syntax error at or near *语法崩溃。测试验证
bash -n ip.sh语法验证通过,无任何语法错误。