diff options
| author | Randall Meyer <[email protected]> | 2023-02-15 14:17:00 -0800 |
|---|---|---|
| committer | Randall Meyer <[email protected]> | 2023-02-22 09:18:25 -0800 |
| commit | bfa2e2b0fa93b6059fba0581b52d6d60a53b5a4a (patch) | |
| tree | ff8a9707caf844be368106ee8000ce7c6e0b57db /rpm/rpm.go | |
| parent | aba993ed378297f48ff6be18b17c6a963d3fd190 (diff) | |
new flag: --connect-to
Allows user to override DNS for the initial config request. This is
accomplished using a custom DialContext overring the hostname used to
Dial to. This allows for TLS certificate validation to still
happen(optionally) while connecting to TLS secured resources.
Also,
- allows for optional enforcement of certificate verification
- stamp built git version into binary and adds a --version option
- adds a user-agent to all outgoing request
- exit(1) on failures for easier shell error detection
Diffstat (limited to 'rpm/rpm.go')
| -rw-r--r-- | rpm/rpm.go | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -32,7 +32,6 @@ import ( "github.com/network-quality/goresponsiveness/stats" "github.com/network-quality/goresponsiveness/traceable" "github.com/network-quality/goresponsiveness/utilities" - "golang.org/x/net/http2" ) func addFlows( @@ -61,8 +60,10 @@ func addFlows( } type ProbeConfiguration struct { - URL string - Host string + ConnectToAddr string + URL string + Host string + InsecureSkipVerify bool } type ProbeDataPoint struct { @@ -157,12 +158,9 @@ func Probe( return err } - // To support test_endpoint - if len(probeHost) != 0 { - probe_req.Host = probeHost - } // Used to disable compression probe_req.Header.Set("Accept-Encoding", "identity") + probe_req.Header.Set("User-Agent", utilities.UserAgent()) probe_resp, err := client.Do(probe_req) if err != nil { @@ -292,8 +290,9 @@ func CombinedProber( probeCount+1, ) } - transport := http2.Transport{} + transport := &http.Transport{} transport.TLSClientConfig = &tls.Config{} + transport.Proxy = http.ProxyFromEnvironment if !utilities.IsInterfaceNil(keyLogger) { if debug.IsDebug(debugging.Level) { @@ -311,9 +310,12 @@ func CombinedProber( // https://github.com/golang/go/blob/7ca6902c171b336d98adbb103d701a013229c806/src/net/http/transport.go#L74 transport.TLSClientConfig.KeyLogWriter = keyLogger } - transport.TLSClientConfig.InsecureSkipVerify = true - foreignProbeClient := &http.Client{Transport: &transport} + transport.TLSClientConfig.InsecureSkipVerify = foreignProbeConfiguration.InsecureSkipVerify + + utilities.OverrideHostTransport(transport, foreignProbeConfiguration.ConnectToAddr) + + foreignProbeClient := &http.Client{Transport: transport} // Start Foreign Connection Prober probeCount++ |
