MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / runChecks

Function runChecks

internal/nodeapi/check.go:455–499  ·  view source on GitHub ↗
(ctx context.Context, client *http.Client)

Source from the content-addressed store, hash-verified

453}
454
455func runChecks(ctx context.Context, client *http.Client) []serviceCheckResult {
456results := make([]serviceCheckResult, len(streamServices))
457var wg sync.WaitGroup
458
459for i, svc := range streamServices {
460wg.Add(1)
461go func(idx int, s streamServiceDef) {
462defer wg.Done()
463result := serviceCheckResult{Service: s.name}
464
465if s.customCheck != nil {
466result.Unlocked, result.Region, result.Note = s.customCheck(ctx, client)
467results[idx] = result
468return
469}
470
471req, err := http.NewRequestWithContext(ctx, http.MethodGet, s.url, nil)
472if err != nil {
473result.Note = "请求构建失败"
474results[idx] = result
475return
476}
477req.Header.Set("User-Agent", checkUserAgent)
478req.Header.Set("Accept-Language", "en-US,en;q=0.9")
479req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
480
481resp, err := client.Do(req)
482if err != nil {
483result.Note = "连接超时"
484results[idx] = result
485return
486}
487defer resp.Body.Close()
488
489body, _ := io.ReadAll(io.LimitReader(resp.Body, 65536))
490result.Unlocked, result.Region, result.Note = s.checkFn(
491resp.StatusCode, resp.Request.URL.String(), string(body),
492)
493results[idx] = result
494}(i, svc)
495}
496
497wg.Wait()
498return results
499}
500
501// checkSpotify 参考 HsukqiLee/MediaUnlockTest checks/Spotify.go:
502// 通过 signup API 触发账号创建预检,返回 status/Country/is_country_launched 判定。

Callers 1

DoCheckUnlockMethod · 0.85

Calls 4

AddMethod · 0.80
DoneMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected