Compare commits
0
Commits
No files matched your search
@@ -7,8 +7,6 @@ require (
|
|||||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
|
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||||
github.com/go-ini/ini v1.67.0
|
github.com/go-ini/ini v1.67.0
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
|
||||||
github.com/mssola/user_agent v0.6.0
|
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/spaolacci/murmur3 v1.1.0
|
github.com/spaolacci/murmur3 v1.1.0
|
||||||
github.com/stretchr/testify v1.8.2
|
github.com/stretchr/testify v1.8.2
|
||||||
@@ -18,6 +16,7 @@ require (
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/tidwall/match v1.1.1 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
github.com/tidwall/pretty v1.2.1 // indirect
|
github.com/tidwall/pretty v1.2.1 // indirect
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
|||||||
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/mssola/user_agent v0.6.0 h1:uwPR4rtWlCHRFyyP9u2KOV0u8iQXmS7Z7feTrstQwk4=
|
|
||||||
github.com/mssola/user_agent v0.6.0/go.mod h1:TTPno8LPY3wAIEKRpAtkdMT0f8SE24pLRGPahjCH4uw=
|
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
@@ -30,6 +28,7 @@ github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
|
|||||||
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||||
|
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ package util
|
|||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mssola/user_agent"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultUserAgentList = []string{
|
var defaultUserAgentList = []string{
|
||||||
@@ -100,77 +98,3 @@ func (ua *userAgent) GetRandomUA() string {
|
|||||||
idx := rand.Intn(len(ua.list))
|
idx := rand.Intn(len(ua.list))
|
||||||
return ua.list[idx]
|
return ua.list[idx]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse 解析UA
|
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 16:31 2023/4/20
|
|
||||||
func (ua *userAgent) Parse(inputUA string) *UAInfo {
|
|
||||||
uaInstance := user_agent.New(inputUA)
|
|
||||||
uaInfo := &UAInfo{
|
|
||||||
Mozilla: uaInstance.Mozilla(),
|
|
||||||
Platform: uaInstance.Platform(),
|
|
||||||
OS: uaInstance.OS(),
|
|
||||||
Localization: uaInstance.Localization(),
|
|
||||||
Model: uaInstance.Model(),
|
|
||||||
Browser: &BrowserInfo{
|
|
||||||
Engine: "",
|
|
||||||
EngineVersion: "",
|
|
||||||
Name: "",
|
|
||||||
Version: "",
|
|
||||||
},
|
|
||||||
OSInfo: &OSInfo{
|
|
||||||
FullName: uaInstance.OSInfo().FullName,
|
|
||||||
Name: uaInstance.OSInfo().Name,
|
|
||||||
Version: uaInstance.OSInfo().Version,
|
|
||||||
},
|
|
||||||
Bot: false,
|
|
||||||
Mobile: false,
|
|
||||||
Undecided: false,
|
|
||||||
}
|
|
||||||
uaInfo.Browser.Engine, uaInfo.Browser.EngineVersion = uaInstance.Engine()
|
|
||||||
uaInfo.Browser.Name, uaInfo.Browser.Version = uaInstance.Browser()
|
|
||||||
return uaInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
// UAInfo ua解析结果
|
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 16:34 2023/4/20
|
|
||||||
type UAInfo struct {
|
|
||||||
Mozilla string `json:"mozilla"`
|
|
||||||
Platform string `json:"platform"`
|
|
||||||
OS string `json:"os"`
|
|
||||||
OSInfo *OSInfo `json:"os_info"`
|
|
||||||
Localization string `json:"localization"`
|
|
||||||
Model string `json:"model"`
|
|
||||||
Browser *BrowserInfo `json:"browser"`
|
|
||||||
Bot bool `json:"bot"`
|
|
||||||
Mobile bool `json:"mobile"`
|
|
||||||
Undecided bool `json:"undecided"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// BrowserInfo 浏览器信息
|
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 16:34 2023/4/20
|
|
||||||
type BrowserInfo struct {
|
|
||||||
Engine string `json:"engine"` // 浏览器引擎
|
|
||||||
EngineVersion string `json:"engine_version"` // 浏览器引擎版本
|
|
||||||
Name string `json:"name"` // 浏览器名称
|
|
||||||
Version string `json:"version"` // 浏览器版本
|
|
||||||
}
|
|
||||||
|
|
||||||
// OSInfo 系统信息
|
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 16:34 2023/4/20
|
|
||||||
type OSInfo struct {
|
|
||||||
FullName string `json:"full_name"` // 操作系统全称
|
|
||||||
Name string `json:"name"` // 操作系统名称
|
|
||||||
Version string `json:"version"` // 操作系统版本
|
|
||||||
}
|
|
||||||