mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-07 22:06:38 +08:00
split helper http utilities
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package helper
|
||||
|
||||
import "strings"
|
||||
|
||||
// IsCloudflareChallenge checks if the HTML content is a Cloudflare challenge page.
|
||||
func IsCloudflareChallenge(html string) bool {
|
||||
challengeTitles := []string{
|
||||
"Just a moment...",
|
||||
"请稍候…",
|
||||
"DDOS-GUARD",
|
||||
}
|
||||
challengeSelectors := []string{
|
||||
"#cf-challenge-running",
|
||||
".ray_id",
|
||||
".attack-box",
|
||||
"#cf-please-wait",
|
||||
"#challenge-spinner",
|
||||
"#trk_jschal_js",
|
||||
}
|
||||
|
||||
lowerHTML := strings.ToLower(html)
|
||||
for _, title := range challengeTitles {
|
||||
titleLower := strings.ToLower(title)
|
||||
if strings.Contains(lowerHTML, strings.ToLower("<title>"+title)) ||
|
||||
strings.Contains(lowerHTML, titleLower) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
for _, selector := range challengeSelectors {
|
||||
if strings.Contains(lowerHTML, strings.ToLower(selector)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user