Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
5a40fb593c | |||
e47a96a597 | |||
4d861f037e |
@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"git.sati.ac/sati.ac/sati-go"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
@ -147,8 +148,8 @@ func (a *antigateV2Api) createTask(request struct {
|
||||
|
||||
var id uint32
|
||||
|
||||
switch taskType {
|
||||
case "TurnstileTask", "TurnstileTaskProxyless":
|
||||
switch strings.ToLower(taskType) {
|
||||
case "turnstiletask", "turnstiletaskproxyless":
|
||||
var task struct {
|
||||
WebsiteURL string `json:"websiteURL"`
|
||||
WebsiteKey string `json:"websiteKey"`
|
||||
@ -160,7 +161,7 @@ func (a *antigateV2Api) createTask(request struct {
|
||||
SiteKey: task.WebsiteKey,
|
||||
Action: task.Action,
|
||||
})
|
||||
case "RecaptchaV2Task", "RecaptchaV2TaskProxyless":
|
||||
case "recaptchav2task", "recaptchav2taskproxyless":
|
||||
var task struct {
|
||||
WebsiteURL string `json:"websiteURL"`
|
||||
WebsiteKey string `json:"websiteKey"`
|
||||
@ -170,7 +171,7 @@ func (a *antigateV2Api) createTask(request struct {
|
||||
PageUrl: task.WebsiteURL,
|
||||
SiteKey: task.WebsiteKey,
|
||||
})
|
||||
case "FunCaptchaTask", "FunCaptchaTaskProxyless":
|
||||
case "funcaptchatask", "funcaptchataskproxyless":
|
||||
var task struct {
|
||||
WebsiteURL string `json:"websiteURL"`
|
||||
WebsitePublicKey string `json:"websitePublicKey"`
|
||||
@ -209,7 +210,7 @@ func (a *antigateV2Api) getBalance(struct{}) any {
|
||||
}{0, 0, balance.InexactFloat64()}
|
||||
}
|
||||
|
||||
func jsonHandler[T any](handler func(data T) any) func(http.ResponseWriter, *http.Request) {
|
||||
func jsonHandler[T any](api *antigateV2Api, handler func(data T) any) func(http.ResponseWriter, *http.Request) {
|
||||
emptyRequest := reflect.Zero(reflect.TypeOf(handler).In(0)).Interface().(T)
|
||||
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -223,7 +224,9 @@ func jsonHandler[T any](handler func(data T) any) func(http.ResponseWriter, *htt
|
||||
return
|
||||
}
|
||||
|
||||
api.ctx.Logger.WithFields(logrus.Fields{"handler": api.Name(), "request": request}).Debug("request")
|
||||
response := handler(request)
|
||||
api.ctx.Logger.WithFields(logrus.Fields{"handler": api.Name(), "response": response}).Debug("response")
|
||||
|
||||
marshaled, _ := json.Marshal(response)
|
||||
w.Write(marshaled)
|
||||
@ -233,9 +236,9 @@ func jsonHandler[T any](handler func(data T) any) func(http.ResponseWriter, *htt
|
||||
func newAntigateV2Api(ctx *ApiContext) ApiHandler {
|
||||
api := &antigateV2Api{ctx, http.NewServeMux()}
|
||||
|
||||
api.mux.HandleFunc("/createTask", jsonHandler(api.createTask))
|
||||
api.mux.HandleFunc("/getTaskResult", jsonHandler(api.getTaskResult))
|
||||
api.mux.HandleFunc("/getBalance", jsonHandler(api.getBalance))
|
||||
api.mux.HandleFunc("/createTask", jsonHandler(api, api.createTask))
|
||||
api.mux.HandleFunc("/getTaskResult", jsonHandler(api, api.getTaskResult))
|
||||
api.mux.HandleFunc("/getBalance", jsonHandler(api, api.getBalance))
|
||||
|
||||
return api
|
||||
}
|
||||
|
2
main.go
2
main.go
@ -207,7 +207,7 @@ func addDomainsToHosts(ctx *api.ApiContext) error {
|
||||
|
||||
hosts = hostsModRE.ReplaceAll(hosts, []byte{}) // remove old entries
|
||||
|
||||
hostIp := "127.0.0.1"
|
||||
hostIp := strings.SplitN(ctx.Config.Host, ":", 2)[0]
|
||||
suffix := "\r\n#sati-bridge start, DO NOT MODIFY\r\n"
|
||||
for _, domain := range ctx.Server.GetDomains() {
|
||||
suffix += hostIp + " " + domain + "\r\n"
|
||||
|
Reference in New Issue
Block a user