feat(health): add managed SOCKS probe configuration
Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
69077fb708
commit
5c540ce03b
7 files changed
+392
-24
No files matched your search
@@ -120,26 +120,12 @@ func discoverYoutube(args []string, stdout, stderr io.Writer, runner playerRunne
|
||||
fmt.Fprintln(stderr, "error: discover youtube", err)
|
||||
return 2
|
||||
}
|
||||
payload, _ := json.Marshal(map[string]interface{}{
|
||||
"videoId": videoID,
|
||||
"context": map[string]interface{}{"client": map[string]interface{}{
|
||||
"clientName": "ANDROID", "clientVersion": "21.02.35", "androidSdkVersion": 30,
|
||||
"userAgent": playerUserAgent, "osName": "Android", "osVersion": "11",
|
||||
}},
|
||||
})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 35*time.Second)
|
||||
defer cancel()
|
||||
var body bytes.Buffer
|
||||
output := &playerBoundedWriter{dst: &body, limit: playerResponseLimit}
|
||||
diagnostics := &playerBoundedWriter{dst: io.Discard, limit: 64 << 10}
|
||||
// Disable curlrc and NO_PROXY bypasses: the explicit proxy must be used.
|
||||
err = runner(ctx, []string{"--disable", "--silent", "--show-error", "--fail", "--max-time", "30",
|
||||
"--noproxy", "", "--proxy", proxy, "--user-agent", playerUserAgent, "--json", string(payload), playerURL}, output, diagnostics)
|
||||
if err != nil || output.exceeded || diagnostics.exceeded {
|
||||
fmt.Fprintln(stderr, "error: player request failed or exceeded output limit")
|
||||
body, err := requestPlayer(videoID, proxy, runner)
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, "error:", err)
|
||||
return 1
|
||||
}
|
||||
host, err := playerHostname(body.Bytes())
|
||||
host, err := playerHostname(body)
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, "error:", err)
|
||||
return 1
|
||||
@@ -154,3 +140,25 @@ func discoverYoutube(args []string, stdout, stderr io.Writer, runner playerRunne
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func requestPlayer(videoID, proxy string, runner playerRunner) ([]byte, error) {
|
||||
payload, _ := json.Marshal(map[string]interface{}{
|
||||
"videoId": videoID,
|
||||
"context": map[string]interface{}{"client": map[string]interface{}{
|
||||
"clientName": "ANDROID", "clientVersion": "21.02.35", "androidSdkVersion": 30,
|
||||
"userAgent": playerUserAgent, "osName": "Android", "osVersion": "11",
|
||||
}},
|
||||
})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 35*time.Second)
|
||||
defer cancel()
|
||||
var body bytes.Buffer
|
||||
output := &playerBoundedWriter{dst: &body, limit: playerResponseLimit}
|
||||
diagnostics := &playerBoundedWriter{dst: io.Discard, limit: 64 << 10}
|
||||
// Disable curlrc and NO_PROXY bypasses: the explicit proxy must be used.
|
||||
err := runner(ctx, []string{"--disable", "--silent", "--show-error", "--fail", "--max-time", "30",
|
||||
"--noproxy", "", "--proxy", proxy, "--user-agent", playerUserAgent, "--json", string(payload), playerURL}, output, diagnostics)
|
||||
if err != nil || output.exceeded || diagnostics.exceeded {
|
||||
return nil, errors.New("player request failed or exceeded output limit")
|
||||
}
|
||||
return body.Bytes(), nil
|
||||
}
|
||||
Reference in new issue
Block a user