haruki需要替换台服的host

This commit is contained in:
2026-10-26 23:27:46 +08:00
parent 070020a296
commit 0851713876
9 changed files with 90 additions and 64 deletions
@@ -11,24 +11,15 @@ data class CaptureProfile(
data class CaptureProfileStep(
val id: String,
val name: String,
/** 该步骤可能命中的上游域名;TW/KR 的 cdn / https 两个域名都会出现 */
val hosts: List<String>,
/** 匹配 path + query 的正则(Rust 侧 Regex::is_match) */
val path: String,
val fileName: String,
/**
* 该步骤抓成功后异步执行(不阻塞下一步的监听)。
* 没有填上传码时会走这里;参数是本次抓包的结果。
*/
val postAction: suspend (CaptureResult) -> Unit = {},
var postAction: suspend (CaptureResult) -> Unit = {},
)
/** 一步抓包完成后的结果,交给 postAction 用 */
data class CaptureResult(
val profile: CaptureProfile,
val step: CaptureProfileStep,
/** 命中的原始完整 URL(https://host/path?query,MySekai 的 flag 已改写为 True) */
val url: String,
/** 抓到的响应体文件 */
val file: File,
)
@@ -1,16 +1,8 @@
package net.bluemangoo.indpjsk.data
object PredefinedProfiles {
import net.bluemangoo.indpjsk.upload.Uploader
/**
* 两个数据接口的正则(Host 已去掉,Rust 侧是拿 path + query 去匹配的):
*
* 1. Suite(个人信息 / 卡牌 / 仓库主数据)
* Path 模板: /api/suite/user/{uid}
*
* 2. MySekai(烤森房间 / 地图全量数据)
* Path 模板: /api/user/{uid}/mysekai?isForceAllReloadOnlyMysekai=True
*/
object PredefinedProfiles {
private const val SUITE_PATH = "/api/suite/user/(\\d+)(\\?isLogin=true)?\$"
private const val MYSEKAI_PATH =
"/api/user/(\\d+)/mysekai\\?isForceAllReloadOnlyMysekai=True"
@@ -20,7 +12,10 @@ object PredefinedProfiles {
name = "Suite",
hosts = hosts,
path = SUITE_PATH,
fileName = "suite"
fileName = "suite",
postAction = { result ->
Uploader.tryUpload(result)
}
)
private fun mysekaiStep(hosts: List<String>) = CaptureProfileStep(
@@ -28,7 +23,10 @@ object PredefinedProfiles {
name = "烤森",
hosts = hosts,
path = MYSEKAI_PATH,
fileName = "mysekai"
fileName = "mysekai",
postAction = { result ->
Uploader.tryUpload(result)
}
)
private fun mysekaiBirthday(hosts: List<String>) = CaptureProfileStep(
@@ -36,7 +34,10 @@ object PredefinedProfiles {
name = "烤森生日双叶",
hosts = hosts,
path = "/api/user/(\\d+)/mysekai/birthday-party/(\\d+)/delivery",
fileName = "mysekai_birthday"
fileName = "mysekai_birthday",
postAction = { result ->
Uploader.tryUpload(result)
}
)
private val CN_HOSTS = listOf("mkcn-prod-public-60001-1.dailygn.com")
@@ -51,6 +52,15 @@ object PredefinedProfiles {
"mkkorea-obt-prod01-https.bytedgame.com"
)
fun rewriteTwUrl(result: CaptureResult): CaptureResult {
val originalUrl = result.url
val rewrittenUrl = originalUrl.replace(
"mk-zian-obt-https.bytedgame.com",
"mk-zian-obt-cdn.bytedgame.com"
)
return result.copy(url = rewrittenUrl)
}
val all: List<CaptureProfile> = listOf(
// 国服不支持烤森
CaptureProfile(
@@ -71,7 +81,22 @@ object PredefinedProfiles {
CaptureProfile(
id = "tw",
name = "台服",
steps = listOf(suiteStep(TW_HOSTS), mysekaiStep(TW_HOSTS), mysekaiBirthday(TW_HOSTS))
steps = listOf(suiteStep(TW_HOSTS).apply {
postAction = { result ->
val rewrittenResult = rewriteTwUrl(result)
Uploader.tryUpload(rewrittenResult)
}
}, mysekaiStep(TW_HOSTS).apply {
postAction = { result ->
val rewrittenResult = rewriteTwUrl(result)
Uploader.tryUpload(rewrittenResult)
}
}, mysekaiBirthday(TW_HOSTS).apply {
postAction = { result ->
val rewrittenResult = rewriteTwUrl(result)
Uploader.tryUpload(rewrittenResult)
}
})
),
CaptureProfile(
id = "kr",