mirror of
https://github.com/Rayzggz/server_torii.git
synced 2025-06-21 14:31:31 +08:00
feat: log error
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"server_torii/internal/action"
|
||||
@ -57,12 +58,19 @@ func CheckCaptcha(r *http.Request, reqData dataType.UserRequest, ruleSet *config
|
||||
|
||||
resp, err := http.PostForm("https://api.hcaptcha.com/siteverify", data)
|
||||
if err != nil {
|
||||
log.Printf("Error sending request to hCaptcha: %v", err)
|
||||
decision.SetResponse(action.Done, []byte("500"), []byte("bad"))
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func(Body io.ReadCloser) {
|
||||
err := Body.Close()
|
||||
if err != nil {
|
||||
log.Printf("Error closing response body: %v", err)
|
||||
}
|
||||
}(resp.Body)
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Printf("Error reading response from hCaptcha: %v", err)
|
||||
decision.SetResponse(action.Done, []byte("500"), []byte("bad"))
|
||||
return
|
||||
}
|
||||
@ -70,6 +78,7 @@ func CheckCaptcha(r *http.Request, reqData dataType.UserRequest, ruleSet *config
|
||||
var hCaptchaResp HCaptchaResponse
|
||||
err = json.Unmarshal(body, &hCaptchaResp)
|
||||
if err != nil {
|
||||
log.Printf("Error parsing response from hCaptcha: %v", err)
|
||||
decision.SetResponse(action.Done, []byte("500"), []byte("bad"))
|
||||
return
|
||||
}
|
||||
@ -105,6 +114,7 @@ func verifyClearanceCookie(reqData dataType.UserRequest, ruleSet config.RuleSet)
|
||||
timeNow := time.Now().Unix()
|
||||
parsedTimestamp, err := strconv.ParseInt(timestamp, 10, 64)
|
||||
if err != nil {
|
||||
log.Printf("Error parsing timestamp: %v", err)
|
||||
return false
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user