feat: add funcaptcha support
All checks were successful
release-tag / release (push) Successful in 2m6s
All checks were successful
release-tag / release (push) Successful in 2m6s
This commit is contained in:
parent
197918a26d
commit
00b07f7e2b
@ -115,19 +115,20 @@ func (a *antigateV2Api) getTaskResult(request struct {
|
|||||||
response.Status = "ready"
|
response.Status = "ready"
|
||||||
response.EndTime = &task.EndTime
|
response.EndTime = &task.EndTime
|
||||||
response.Cost = task.Entity.Cost
|
response.Cost = task.Entity.Cost
|
||||||
switch task.Result.(type) {
|
switch result := task.Result.(type) {
|
||||||
case *sati.ReCaptcha2Result:
|
case *sati.ReCaptcha2Result:
|
||||||
response.Solution = struct {
|
response.Solution = struct {
|
||||||
GRecaptchaResponse string `json:"gRecaptchaResponse"`
|
GRecaptchaResponse string `json:"gRecaptchaResponse"`
|
||||||
}{task.Result.(*sati.ReCaptcha2Result).Token}
|
}{result.Token}
|
||||||
case *sati.TurnstileResult:
|
case *sati.TurnstileResult:
|
||||||
response.Solution = struct {
|
response.Solution = struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
UserAgent string `json:"userAgent"`
|
UserAgent string `json:"userAgent"`
|
||||||
}{
|
}{result.Token, a.ctx.Config.AntiGateV2.TurnstileUserAgent}
|
||||||
task.Result.(*sati.TurnstileResult).Token,
|
case *sati.FunCaptchaResult:
|
||||||
a.ctx.Config.AntiGateV2.TurnstileUserAgent,
|
response.Solution = struct {
|
||||||
}
|
Token string `json:"token"`
|
||||||
|
}{result.Token}
|
||||||
default:
|
default:
|
||||||
return errorTaskNotSupported
|
return errorTaskNotSupported
|
||||||
}
|
}
|
||||||
@ -169,6 +170,18 @@ func (a *antigateV2Api) createTask(request struct {
|
|||||||
PageUrl: task.WebsiteURL,
|
PageUrl: task.WebsiteURL,
|
||||||
SiteKey: task.WebsiteKey,
|
SiteKey: task.WebsiteKey,
|
||||||
})
|
})
|
||||||
|
case "FunCaptchaTask", "FunCaptchaTaskProxyless":
|
||||||
|
var task struct {
|
||||||
|
WebsiteURL string `json:"websiteURL"`
|
||||||
|
WebsitePublicKey string `json:"websitePublicKey"`
|
||||||
|
Data map[string]string `json:"data"`
|
||||||
|
}
|
||||||
|
mapstructure.Decode(request.Task, &task)
|
||||||
|
id = a.ctx.Registry.CreateTask(&sati.FunCaptchaTask{
|
||||||
|
PageUrl: task.WebsiteURL,
|
||||||
|
SiteKey: task.WebsitePublicKey,
|
||||||
|
Data: task.Data,
|
||||||
|
})
|
||||||
default:
|
default:
|
||||||
return errorTaskNotSupported
|
return errorTaskNotSupported
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,24 @@ type okResponse simpleResponse
|
|||||||
|
|
||||||
func (r *okResponse) text() string { return "OK|" + r.Request }
|
func (r *okResponse) text() string { return "OK|" + r.Request }
|
||||||
|
|
||||||
|
func parsePhpAssociativeArray(values map[string][]string, arrayName string) map[string]string {
|
||||||
|
result := make(map[string]string)
|
||||||
|
prefix := arrayName + "["
|
||||||
|
suffix := "]"
|
||||||
|
|
||||||
|
for key, values := range values {
|
||||||
|
if strings.HasPrefix(key, prefix) && strings.HasSuffix(key, suffix) && len(values) > 0 {
|
||||||
|
result[key[len(prefix):len(key)-len(suffix)]] = values[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(result) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func (a *ruCaptchaApi) endpointIn(params url.Values) ruCaptchaResponse {
|
func (a *ruCaptchaApi) endpointIn(params url.Values) ruCaptchaResponse {
|
||||||
var id uint32
|
var id uint32
|
||||||
switch params.Get("method") {
|
switch params.Get("method") {
|
||||||
@ -125,6 +143,26 @@ func (a *ruCaptchaApi) endpointIn(params url.Values) ruCaptchaResponse {
|
|||||||
Action: action,
|
Action: action,
|
||||||
CData: cData,
|
CData: cData,
|
||||||
})
|
})
|
||||||
|
case "funcaptcha":
|
||||||
|
siteKey := params.Get("publickey")
|
||||||
|
pageUrl := params.Get("pageurl")
|
||||||
|
data := parsePhpAssociativeArray(params, "data")
|
||||||
|
if siteKey == "" || pageUrl == "" {
|
||||||
|
return &simpleResponse{0, "ERROR_BAD_PARAMETERS"}
|
||||||
|
}
|
||||||
|
|
||||||
|
var serviceUrl *string
|
||||||
|
if params.Has("surl") {
|
||||||
|
val := params.Get("surl")
|
||||||
|
serviceUrl = &val
|
||||||
|
}
|
||||||
|
|
||||||
|
id = a.ctx.Registry.CreateTask(&sati.FunCaptchaTask{
|
||||||
|
SiteKey: siteKey,
|
||||||
|
PageUrl: pageUrl,
|
||||||
|
ServiceUrl: serviceUrl,
|
||||||
|
Data: data,
|
||||||
|
})
|
||||||
default:
|
default:
|
||||||
return &simpleResponse{0, "ERROR_ZERO_CAPTCHA_FILESIZE"}
|
return &simpleResponse{0, "ERROR_ZERO_CAPTCHA_FILESIZE"}
|
||||||
}
|
}
|
||||||
@ -143,11 +181,13 @@ func (r *get2Response) text() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *ruCaptchaApi) convertTaskResult(task *Task) string {
|
func (a *ruCaptchaApi) convertTaskResult(task *Task) string {
|
||||||
switch task.Result.(type) {
|
switch result := task.Result.(type) {
|
||||||
case *sati.ReCaptcha2Result:
|
case *sati.ReCaptcha2Result:
|
||||||
return task.Result.(*sati.ReCaptcha2Result).Token
|
return result.Token
|
||||||
case *sati.TurnstileResult:
|
case *sati.TurnstileResult:
|
||||||
return task.Result.(*sati.TurnstileResult).Token
|
return result.Token
|
||||||
|
case *sati.FunCaptchaResult:
|
||||||
|
return result.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
a.ctx.Logger.WithFields(logrus.Fields{
|
a.ctx.Logger.WithFields(logrus.Fields{
|
||||||
|
2
go.mod
2
go.mod
@ -2,7 +2,7 @@ module git.sati.ac/sati.ac/bridge
|
|||||||
|
|
||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require git.sati.ac/sati.ac/sati-go v0.0.0-20230630184329-03a405a25122
|
require git.sati.ac/sati.ac/sati-go v0.0.0-20230713145537-57719018ca00
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gorilla/websocket v1.5.0 // indirect
|
github.com/gorilla/websocket v1.5.0 // indirect
|
||||||
|
2
go.sum
2
go.sum
@ -4,6 +4,8 @@ git.sati.ac/sati.ac/sati-go v0.0.0-20230629103120-de6961c4f6ec h1:DHmxYp62PfGP+j
|
|||||||
git.sati.ac/sati.ac/sati-go v0.0.0-20230629103120-de6961c4f6ec/go.mod h1:dsLvwV5+2YUjWRAuTYFf/EMvoH/twUu/NWA0t5Yl3pQ=
|
git.sati.ac/sati.ac/sati-go v0.0.0-20230629103120-de6961c4f6ec/go.mod h1:dsLvwV5+2YUjWRAuTYFf/EMvoH/twUu/NWA0t5Yl3pQ=
|
||||||
git.sati.ac/sati.ac/sati-go v0.0.0-20230630184329-03a405a25122 h1:Uff2QZeRDk+3cm3cN9tUiUoT2VoKcwbIf32wYgYSUNU=
|
git.sati.ac/sati.ac/sati-go v0.0.0-20230630184329-03a405a25122 h1:Uff2QZeRDk+3cm3cN9tUiUoT2VoKcwbIf32wYgYSUNU=
|
||||||
git.sati.ac/sati.ac/sati-go v0.0.0-20230630184329-03a405a25122/go.mod h1:dsLvwV5+2YUjWRAuTYFf/EMvoH/twUu/NWA0t5Yl3pQ=
|
git.sati.ac/sati.ac/sati-go v0.0.0-20230630184329-03a405a25122/go.mod h1:dsLvwV5+2YUjWRAuTYFf/EMvoH/twUu/NWA0t5Yl3pQ=
|
||||||
|
git.sati.ac/sati.ac/sati-go v0.0.0-20230713145537-57719018ca00 h1:emjsk5AubG3EiCbiG0WAG6xAZXoNNwO/yteYj/J0TqA=
|
||||||
|
git.sati.ac/sati.ac/sati-go v0.0.0-20230713145537-57719018ca00/go.mod h1:dsLvwV5+2YUjWRAuTYFf/EMvoH/twUu/NWA0t5Yl3pQ=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user