MCPcopy Create free account
hub / github.com/Aur0ra-m/APIKiller / Start

Method Start

internal/core/async/asyncCheckEngineX.go:34–77  ·  view source on GitHub ↗

Start @Description: start to check @receiver e

()

Source from the content-addressed store, hash-verified

32// @receiver e
33//
34func (e *AsyncCheckEngine) Start() {
35 // heart beat detection
36 if !e.heartbeat() {
37 logger.Errorln("cannot access target website successfully: http://api.ceye.io")
38 return
39 }
40
41 // build a request
42 request, _ := http.NewRequest("GET", e.httpAPI, nil)
43 client := http.Client{}
44 // polling API interface
45 for {
46 // make a http request
47 response, _ := client.Do(request)
48
49 // get data from json body
50 if response.Body != nil {
51 all, err := ioutil.ReadAll(response.Body)
52 if err != nil {
53 logger.Errorln(err)
54 }
55 results := gjson.Get(string(all), "data").Array()
56
57 for _, result := range results {
58 if result.Get("id").String() <= e.lastRecordId {
59 continue
60 }
61
62 name := result.Get("name")
63 token := strings.Replace(name.String(), "http://zpysri.ceye.io/", "", 1)
64
65 go e.check(token)
66 }
67
68 if len(results) > 0 {
69 e.lastRecordId = results[0].Get("id").String()
70 }
71
72 }
73
74 // sleep
75 time.Sleep(5 * 1000 * time.Millisecond)
76 }
77}
78
79//
80// heartbeat

Callers 1

Calls 3

heartbeatMethod · 0.95
checkMethod · 0.95
ErrorlnFunction · 0.92

Tested by 1