Compare commits

..

No commits in common. "5a40fb593c66caabbaba024f8cda1ac03bd985fb" and "00b07f7e2b293531dbc2f73a138462ebf86aacad" have entirely different histories.

2 changed files with 9 additions and 12 deletions

View File

@ -5,7 +5,6 @@ import (
"io"
"net/http"
"reflect"
"strings"
"git.sati.ac/sati.ac/sati-go"
"github.com/mitchellh/mapstructure"
@ -148,8 +147,8 @@ func (a *antigateV2Api) createTask(request struct {
var id uint32
switch strings.ToLower(taskType) {
case "turnstiletask", "turnstiletaskproxyless":
switch taskType {
case "TurnstileTask", "TurnstileTaskProxyless":
var task struct {
WebsiteURL string `json:"websiteURL"`
WebsiteKey string `json:"websiteKey"`
@ -161,7 +160,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"`
@ -171,7 +170,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"`
@ -210,7 +209,7 @@ func (a *antigateV2Api) getBalance(struct{}) any {
}{0, 0, balance.InexactFloat64()}
}
func jsonHandler[T any](api *antigateV2Api, handler func(data T) any) func(http.ResponseWriter, *http.Request) {
func jsonHandler[T any](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) {
@ -224,9 +223,7 @@ func jsonHandler[T any](api *antigateV2Api, handler func(data T) any) func(http.
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)
@ -236,9 +233,9 @@ func jsonHandler[T any](api *antigateV2Api, handler func(data T) any) func(http.
func newAntigateV2Api(ctx *ApiContext) ApiHandler {
api := &antigateV2Api{ctx, http.NewServeMux()}
api.mux.HandleFunc("/createTask", jsonHandler(api, api.createTask))
api.mux.HandleFunc("/getTaskResult", jsonHandler(api, api.getTaskResult))
api.mux.HandleFunc("/getBalance", jsonHandler(api, api.getBalance))
api.mux.HandleFunc("/createTask", jsonHandler(api.createTask))
api.mux.HandleFunc("/getTaskResult", jsonHandler(api.getTaskResult))
api.mux.HandleFunc("/getBalance", jsonHandler(api.getBalance))
return api
}

View File

@ -207,7 +207,7 @@ func addDomainsToHosts(ctx *api.ApiContext) error {
hosts = hostsModRE.ReplaceAll(hosts, []byte{}) // remove old entries
hostIp := strings.SplitN(ctx.Config.Host, ":", 2)[0]
hostIp := "127.0.0.1"
suffix := "\r\n#sati-bridge start, DO NOT MODIFY\r\n"
for _, domain := range ctx.Server.GetDomains() {
suffix += hostIp + " " + domain + "\r\n"