Skip to content

Commit

Permalink
renaming of variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarazzutti committed Aug 21, 2023
1 parent c11211d commit b1dda97
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ type Config struct {
Referrer string
AuthUsername string
AuthPassword string
Http1 bool
Http2 bool
Http3 bool
HTTP1 bool
HTTP2 bool
HTTP3 bool
FullDNS bool
DNSServer string
CacheDNSRequests bool
Expand Down
2 changes: 1 addition & 1 deletion app/http3.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"strings"
)

func newHttp3RoundTripper(config *Config, runtimeConfig *RuntimeConfig, w *webClientImpl) (http.RoundTripper, error) {
func newHTTP3RoundTripper(config *Config, runtimeConfig *RuntimeConfig, w *webClientImpl) (http.RoundTripper, error) {
if config.Method == http.MethodGet {
config.Method = http3.MethodGet0RTT
}
Expand Down
22 changes: 11 additions & 11 deletions app/httpping.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ type httpPingImpl struct {

type httpPingTestVersion struct {
baseConfig *Config
advertisedHttp3 bool
advertisedHTTP3 bool
logger *standardLogger
}

func (h *httpPingTestVersion) Run() error {
http1 := h.checkHttp(func(c *Config) {
c.Http1 = true
http1 := h.checkHTTP(func(c *Config) {
c.HTTP1 = true
})

http2 := h.checkHttp(func(c *Config) {
c.Http2 = true
http2 := h.checkHTTP(func(c *Config) {
c.HTTP2 = true
})

http3 := h.checkHttp(func(c *Config) {
c.Http3 = true
http3 := h.checkHTTP(func(c *Config) {
c.HTTP3 = true
})

_, _ = h.logger.Printf("Checking available versions of HTTP protocol on " + h.baseConfig.Target)
Expand All @@ -59,19 +59,19 @@ func (h *httpPingTestVersion) Run() error {
_, _ = h.logger.Printf(" - v2 " + <-http2 + "\n")
_, _ = h.logger.Printf(" - v3 " + <-http3 + "\n")
_, _ = h.logger.Printf("\n")
if h.advertisedHttp3 {
if h.advertisedHTTP3 {
_, _ = h.logger.Printf(" (*) advertises HTTP/3 availability in HTTP headers\n")
}
return nil
}

func (h *httpPingTestVersion) checkHttp(prep func(*Config)) <-chan string {
func (h *httpPingTestVersion) checkHTTP(prep func(*Config)) <-chan string {
r := make(chan string)

go func() {
configCopy := *h.baseConfig

configCopy.Http3 = false
configCopy.HTTP3 = false
prep(&configCopy)

rc := RuntimeConfig{}
Expand All @@ -82,7 +82,7 @@ func (h *httpPingTestVersion) checkHttp(prep func(*Config)) <-chan string {

if m != nil && !m.IsFailure {
if m.AltSvcH3 != nil {
h.advertisedHttp3 = true
h.advertisedHTTP3 = true
http3Advertisement = " (*)"
}

Expand Down
26 changes: 13 additions & 13 deletions app/webclientimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (webClient *webClientImpl) updateConnTarget() {
}
}

func newHttp2RoundTripper(config *Config, runtimeConfig *RuntimeConfig, w *webClientImpl) (http.RoundTripper, error) {
func newHTTP2RoundTripper(config *Config, runtimeConfig *RuntimeConfig, w *webClientImpl) (http.RoundTripper, error) {

webClient := webClientImpl{config: config, runtimeConfig: runtimeConfig, logger: w.logger}
parsedURL, err := url.Parse(config.Target)
Expand Down Expand Up @@ -117,7 +117,7 @@ func newHttp2RoundTripper(config *Config, runtimeConfig *RuntimeConfig, w *webCl

var tlsNextProto map[string]func(string, *tls.Conn) http.RoundTripper = nil

if webClient.config.Http1 {
if webClient.config.HTTP1 {
tlsNextProto = make(map[string]func(string, *tls.Conn) http.RoundTripper)
}

Expand All @@ -129,7 +129,7 @@ func newHttp2RoundTripper(config *Config, runtimeConfig *RuntimeConfig, w *webCl
InsecureSkipVerify: config.NoCheckCertificate,
},
DisableCompression: config.DisableCompression,
ForceAttemptHTTP2: !webClient.config.Http1,
ForceAttemptHTTP2: !webClient.config.HTTP1,
MaxIdleConns: 10,
DisableKeepAlives: config.DisableKeepAlive,
IdleConnTimeout: config.Interval + config.Wait,
Expand All @@ -139,10 +139,10 @@ func newHttp2RoundTripper(config *Config, runtimeConfig *RuntimeConfig, w *webCl

func newTransport(config *Config, runtimeConfig *RuntimeConfig, w *webClientImpl) (http.RoundTripper, error) {

if config.Http3 {
return newHttp3RoundTripper(config, runtimeConfig, w)
if config.HTTP3 {
return newHTTP3RoundTripper(config, runtimeConfig, w)
}
return newHttp2RoundTripper(config, runtimeConfig, w)
return newHTTP2RoundTripper(config, runtimeConfig, w)
}

func newWebClient(config *Config, runtimeConfig *RuntimeConfig, logger ConsoleLogger) (*webClientImpl, error) {
Expand Down Expand Up @@ -267,11 +267,11 @@ func (webClient *webClientImpl) DoMeasure(followRedirect bool) *HTTPMeasure {

altSvcH3 := checkAltSvcH3Header(res.Header)

if !strings.HasPrefix(req.RequestURI, "http://") && altSvcH3 != nil && !strings.HasPrefix(res.Proto, "HTTP/3") && !webClient.config.Http1 && !webClient.config.Http2 {
if !strings.HasPrefix(req.RequestURI, "http://") && altSvcH3 != nil && !strings.HasPrefix(res.Proto, "HTTP/3") && !webClient.config.HTTP1 && !webClient.config.HTTP2 {

webClient.logger.Printf(" ─→ server advertised HTTP/3 endpoint, using HTTP/3\n")

return webClient.moveToHttp3(*altSvcH3, measureContext.timerRegistry, followRedirect)
return webClient.moveToHTTP3(*altSvcH3, measureContext.timerRegistry, followRedirect)
}

measureContext.startIngestion()
Expand Down Expand Up @@ -301,15 +301,15 @@ func (webClient *webClientImpl) DoMeasure(followRedirect bool) *HTTPMeasure {
failureCause = "Server-side error"
}

if strings.HasPrefix(res.Proto, "HTTP/1.") && webClient.config.Http2 {
if strings.HasPrefix(res.Proto, "HTTP/1.") && webClient.config.HTTP2 {
failed = true
failureCause = "HTTP/2 not supported by server"
}

i := atomic.SwapInt64(&webClient.reads, 0)
o := atomic.SwapInt64(&webClient.writes, 0)

tlsVersion := extractTlsVersion(res)
tlsVersion := extractTLSVersion(res)

var remoteAddr = measureContext.remoteAddr
if remoteAddr == "" {
Expand Down Expand Up @@ -339,7 +339,7 @@ func (webClient *webClientImpl) DoMeasure(followRedirect bool) *HTTPMeasure {

}

func extractTlsVersion(res *http.Response) string {
func extractTLSVersion(res *http.Response) string {

if res.TLS != nil {
code := int(res.TLS.Version) - 0x0301
Expand All @@ -353,7 +353,7 @@ func extractTlsVersion(res *http.Response) string {
}
}

func (webClient *webClientImpl) moveToHttp3(altSvcH3 string, timerRegistry *stats.TimerRegistry, followRedirect bool) *HTTPMeasure {
func (webClient *webClientImpl) moveToHTTP3(altSvcH3 string, timerRegistry *stats.TimerRegistry, followRedirect bool) *HTTPMeasure {

if altSvcH3 == ":443" {
// nothing
Expand All @@ -364,7 +364,7 @@ func (webClient *webClientImpl) moveToHttp3(altSvcH3 string, timerRegistry *stat
}

c := *webClient.config
c.Http3 = true
c.HTTP3 = true
err := webClient.update(&c, webClient.runtimeConfig)

if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ func prepareRootCmd(appLogic func(config *app.Config, consoleLogger app.ConsoleL

rootCmd.Flags().StringVarP(&config.AuthPassword, "auth-password", "", "", "authentication password")

rootCmd.Flags().BoolVarP(&config.Http1, "http1", "1", false, "use the HTTP/1 protocol")
rootCmd.Flags().BoolVarP(&config.HTTP1, "http1", "1", false, "use the HTTP/1 protocol")

rootCmd.Flags().BoolVarP(&config.Http2, "http2", "2", false, "use the HTTP/2 protocol")
rootCmd.Flags().BoolVarP(&config.HTTP2, "http2", "2", false, "use the HTTP/2 protocol")

rootCmd.Flags().BoolVarP(&config.Http3, "http3", "3", false, "use the HTTP/3 protocol")
rootCmd.Flags().BoolVarP(&config.HTTP3, "http3", "3", false, "use the HTTP/3 protocol")

rootCmd.Flags().BoolVarP(&config.FullDNS, "dns-full-resolution", "D", false, "enable full DNS resolution from the root servers")

Expand Down

0 comments on commit b1dda97

Please sign in to comment.