fuck! without token
All checks were successful
Gitea Go Release Actions / Release Go Binary (amd64, darwin) (push) Successful in 1m25s
Gitea Go Release Actions / Release Go Binary (arm, linux) (push) Successful in 1m36s
Gitea Go Release Actions / Release Go Binary (loong64, linux) (push) Successful in 1m23s
Gitea Go Release Actions / Release Go Binary (mips, linux) (push) Successful in 1m16s
Gitea Go Release Actions / Release Go Binary (arm64, darwin) (push) Successful in 1m6s
Gitea Go Release Actions / Release Go Binary (amd64, windows) (push) Successful in 1m28s
Gitea Go Release Actions / Release Go Binary (amd64, linux) (push) Successful in 1m38s
Gitea Go Release Actions / Release Go Binary (riscv64, linux) (push) Successful in 1m16s
Gitea Go Release Actions / Release Go Binary (arm64, linux) (push) Successful in 1m14s

EnsureConnection: check GetWorkDetailResponse
This commit is contained in:
yzqzss 2024-07-05 03:29:04 +08:00
parent 022c16c731
commit fb9a1a0b98
2 changed files with 36 additions and 6 deletions

View File

@ -173,7 +173,7 @@ func ShowStatus(t *savewebtracker.Tracker) {
}
func main() {
tracker := savewebtracker.GetTracker(project_id, "0.3", savewebtracker.Archivist())
tracker := savewebtracker.GetTracker(project_id, "0.4", savewebtracker.Archivist())
tracker.PING_client = GetRetryableHttpClient(10*time.Second, DEBUG)
tracker.HTTP_client = GetRetryableHttpClient(10*time.Second, DEBUG)
tracker.SelectBestTracker().StartSelectTrackerBackground().StartFetchProjectBackground()

View File

@ -1,13 +1,14 @@
package huashijie_api
import (
"crypto/md5"
"encoding/json"
"fmt"
"io"
"log"
"math/rand"
"net/http"
"os"
"strconv"
"strings"
"time"
)
@ -48,10 +49,39 @@ func EnsureConnection(client http.Client) {
panic(err)
}
text := string(body)
fmt.Println(text)
Logger.Println(text)
if !strings.Contains(text, "update_ver_code") {
panic("NotImplementedError: " + text)
}
// 125277547
body, r_status := GetWorkDetailResponse(client, "125277547")
if r_status != 200 {
Logger.Println("HTTP status code:", r_status, "body:", string(body))
panic("HTTP status code: " + strconv.Itoa(r_status))
}
var r_json map[string]interface{}
if err := json.Unmarshal(body, &r_json); err != nil {
Logger.Println("failed to parse JSON:", string(body), "error:", err)
panic("failed to parse JSON: " + string(body))
}
// check if 'status' in r_json
if status, ok := r_json["status"]; ok {
switch status := status.(type) {
case float64:
if status == 1 {
// OK
Logger.Println("len(body):", len(body), "->", string(body[:256]), "...OK")
return
}
}
}
Logger.Println("JSON:", string(body))
panic("assertion failed: status == 1")
}
var cur_fake_user_id = -1
@ -81,9 +111,9 @@ func GetWorkDetailResponse(client http.Client, work_id string) ([]byte, int) {
}
// fake token = md5(visitorId + "huashijie")
md5hash := md5.New()
md5hash.Write([]byte(visitorId + "huashijie"))
token = fmt.Sprintf("%x", md5hash.Sum(nil))
// md5hash := md5.New()
// md5hash.Write([]byte(visitorId + "huashijie"))
// token = fmt.Sprintf("%x", md5hash.Sum(nil))
Logger.Println("USERID:", visitorId, "token:", token, "left", time.Until(cur_fake_user_left))
}