mirror of
https://github.com/Rayzggz/server_torii.git
synced 2025-06-18 05:01:22 +08:00
fix: clearance failure caused by UA changes
This commit is contained in:
21
internal/utils/UAParser.go
Normal file
21
internal/utils/UAParser.go
Normal file
@ -0,0 +1,21 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mssola/useragent"
|
||||
)
|
||||
|
||||
func GetClearanceUserAgent(inputUA string) string {
|
||||
if len(inputUA) < 8 || inputUA[:8] != "Mozilla/" {
|
||||
return inputUA
|
||||
}
|
||||
|
||||
ua := useragent.New(inputUA)
|
||||
|
||||
engin, enginVersion := ua.Engine()
|
||||
browser, browserVersion := ua.Browser()
|
||||
|
||||
ret := fmt.Sprintf("Mozilla:%v,Module:%v,Platform:%v,OS:%v,Engine:%v,EngineVersion:%v,Browser:%v,BrowserVersion:%v", ua.Mozilla(), ua.Model(), ua.Platform(), ua.OS(), engin, enginVersion, browser, browserVersion)
|
||||
return ret
|
||||
|
||||
}
|
Reference in New Issue
Block a user