You've already forked speedtest-go
							
							Fix missing format calls and minor error handling (#17)
This commit is contained in:
		
							
								
								
									
										12
									
								
								web/web.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								web/web.go
									
									
									
									
									
								
							@@ -86,7 +86,7 @@ func listenProxyProtocol(conf *config.Config, r *chi.Mux) {
 | 
				
			|||||||
		addr := net.JoinHostPort(conf.BindAddress, conf.ProxyProtocolPort)
 | 
							addr := net.JoinHostPort(conf.BindAddress, conf.ProxyProtocolPort)
 | 
				
			||||||
		l, err := net.Listen("tcp", addr)
 | 
							l, err := net.Listen("tcp", addr)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			log.Fatal("Cannot listen on proxy protocol port %s: %s", conf.ProxyProtocolPort, err)
 | 
								log.Fatalf("Cannot listen on proxy protocol port %s: %s", conf.ProxyProtocolPort, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		pl := &proxyproto.Listener{Listener: l}
 | 
							pl := &proxyproto.Listener{Listener: l}
 | 
				
			||||||
@@ -108,8 +108,12 @@ func pages(w http.ResponseWriter, r *http.Request) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func empty(w http.ResponseWriter, r *http.Request) {
 | 
					func empty(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
	io.Copy(ioutil.Discard, r.Body)
 | 
						_, err := io.Copy(ioutil.Discard, r.Body)
 | 
				
			||||||
	r.Body.Close()
 | 
						if err != nil {
 | 
				
			||||||
 | 
							w.WriteHeader(http.StatusBadRequest)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_ = r.Body.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	w.Header().Set("Connection", "keep-alive")
 | 
						w.Header().Set("Connection", "keep-alive")
 | 
				
			||||||
	w.WriteHeader(http.StatusOK)
 | 
						w.WriteHeader(http.StatusOK)
 | 
				
			||||||
@@ -129,7 +133,7 @@ func garbage(w http.ResponseWriter, r *http.Request) {
 | 
				
			|||||||
		i, err := strconv.ParseInt(ckSize, 10, 64)
 | 
							i, err := strconv.ParseInt(ckSize, 10, 64)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			log.Errorf("Invalid chunk size: %s", ckSize)
 | 
								log.Errorf("Invalid chunk size: %s", ckSize)
 | 
				
			||||||
			log.Warn("Will use default value %d", chunks)
 | 
								log.Warnf("Will use default value %d", chunks)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			// limit max chunk size to 1024
 | 
								// limit max chunk size to 1024
 | 
				
			||||||
			if i > 1024 {
 | 
								if i > 1024 {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user