Skip to content

Commit 27890ab

Browse files
committed
ipn/proxy: useragent for http checks
1 parent c439342 commit 27890ab

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

intra/ipn/proxy.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,15 @@ func httpsReaches(who string, c *http.Client, url *url.URL) (bool, error) {
699699
if err != nil {
700700
return false, fmt.Errorf("proxy: reaches: err creating req: %w", err)
701701
}
702-
req.Header.Set("User-Agent", "intra")
702+
703+
setua := settings.SetUserAgentForDoH.Load()
704+
if setua {
705+
// standard for 204 connectivity checks
706+
// PROBE_HTTPS https://www.google.com/generate_204 time=183ms ret=204 request={Connection=[close], User-Agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.32 Safari/537.36]}
707+
// headers={null=[HTTP/1.1 204 No Content], Alt-Svc=[h3=":443"; ma=2592000,h3-29=":443"; ma=2592000], Connection=[close], Content-Length=[0], Cross-Origin-Resource-Policy=[cross-origin],
708+
// Date=[Fri, 27 Jun 2025 10:56:24 GMT], X-Android-Received-Millis=[1751021784573], X-Android-Response-Source=[NETWORK 204], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1751021784495]}
709+
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.32 Safari/537.36")
710+
}
703711

704712
resp, err := c.Do(req)
705713
if resp != nil {
@@ -714,8 +722,8 @@ func httpsReaches(who string, c *http.Client, url *url.URL) (bool, error) {
714722

715723
ok := err == nil && statuscode > 0 && statuscode < 500
716724

717-
logeif(!ok)("proxy: %s reaches: %v; ok? %t, status: %d, rtt: %s; err: %v",
718-
who, url, ok, statuscode, core.FmtPeriod(rtt), err)
725+
logeif(!ok)("proxy: %s reaches: %v (ua? %t); ok? %t, status: %d, rtt: %s; err: %v",
726+
who, url, setua, ok, statuscode, core.FmtPeriod(rtt), err)
719727

720728
if ok {
721729
err = nil // wipe out err as it makes core.Race discard "ok"

0 commit comments

Comments
 (0)