diff --git a/node/http.go b/node/http.go index 1e75ae624b07d912c8f0a12a271611d0127f8fe4..ac468ddd7fb8a8c4dbdafdce46d734c1cb5fece3 100644 --- a/node/http.go +++ b/node/http.go @@ -141,7 +141,7 @@ func withMount(n *Node, f func(*pb.Mount, http.ResponseWriter, *http.Request)) h mountPath := strings.TrimSuffix(r.URL.Path, ".m3u") mount, ok := n.mounts.GetMount(mountPath) if !ok { - log.Printf("http: %s: not found", mountPath) + //log.Printf("http: %s: mount point not found", mountPath) http.NotFound(w, r) return } @@ -152,7 +152,7 @@ func withMount(n *Node, f func(*pb.Mount, http.ResponseWriter, *http.Request)) h func serveSource(n *Node, mount *pb.Mount, w http.ResponseWriter, r *http.Request) { // Can't connect sources to relay streams. if mount.IsRelay() { - log.Printf("source connection to relay stream %s", mount.Path) + log.Printf("error: source connection to relay stream %s", mount.Path) http.Error(w, "Stream is relayed, no source connections allowed", http.StatusBadRequest) return } @@ -184,7 +184,7 @@ func serveRedirect(lb *loadBalancer, mount *pb.Mount, w http.ResponseWriter, r * // 1:1 mapping between Icecasts and frontends. targetNode := lb.chooseNode(&httpRequestContext{r}) if targetNode == nil { - log.Printf("http: %s: no nodes available", mount.Path) + log.Printf("error: http: %s: no nodes available", mount.Path) http.Error(w, "No nodes available", http.StatusServiceUnavailable) return } diff --git a/node/proxy.go b/node/proxy.go index 9b94d829ff6c0ccec17900db06acc760b66f50a2..c642eb9bb1271e45c434a1d2184f0e9627e92cb0 100644 --- a/node/proxy.go +++ b/node/proxy.go @@ -64,7 +64,7 @@ type wrappedWriter interface { // request. The additional streamName parameter is used for // instrumentation. func doIcecastProxy(rw http.ResponseWriter, req *http.Request, target *url.URL, streamName string) { - log.Printf("proxy: in=%s out=%s stream=%s", req.URL.String(), target.String(), streamName) + //log.Printf("proxy: in=%s out=%s stream=%s", req.URL.String(), target.String(), streamName) outreq := new(http.Request) *outreq = *req // includes shallow copies of maps, but okay @@ -119,7 +119,7 @@ func doIcecastProxy(rw http.ResponseWriter, req *http.Request, target *url.URL, // to it. upstream, err := dialer.Dial("tcp", outreq.URL.Host) if err != nil { - log.Printf("http: proxy dial error: %v", err) + log.Printf("error: http: proxy dial error: %v", err) rw.WriteHeader(http.StatusInternalServerError) proxyConnectErrs.WithLabelValues(streamName, target.Host).Inc() return @@ -130,7 +130,7 @@ func doIcecastProxy(rw http.ResponseWriter, req *http.Request, target *url.URL, // stuck on unresponsive TCP servers. upstream.SetDeadline(time.Now().Add(requestWriteTimeout)) // nolint: errcheck if err := outreq.Write(upstream); err != nil { - log.Printf("http: proxy request write error: %v", err) + log.Printf("error: http: proxy request write error: %v", err) rw.WriteHeader(http.StatusInternalServerError) proxyConnectErrs.WithLabelValues(streamName, target.Host).Inc() return @@ -147,7 +147,7 @@ func doIcecastProxy(rw http.ResponseWriter, req *http.Request, target *url.URL, var err error conn, _, err = h.Hijack() if err != nil { - log.Printf("http: proxy hijack error: %v", err) + log.Printf("error: http: proxy hijack error: %v", err) rw.WriteHeader(http.StatusInternalServerError) return } @@ -159,13 +159,13 @@ func doIcecastProxy(rw http.ResponseWriter, req *http.Request, target *url.URL, } } if conn == nil { - log.Printf("http: proxy error: could not find hijackable connection") + log.Printf("error: http: proxy error: could not find hijackable connection") http.Error(rw, "could not find hijackable connection", http.StatusInternalServerError) return } defer conn.Close() if err := conn.SetDeadline(time.Time{}); err != nil { - log.Printf("http: proxy setdeadline error: %v", err) + log.Printf("error: http: proxy setdeadline error: %v", err) } // Run two-way proxying. @@ -190,16 +190,17 @@ func copyStream(tag string, out io.WriteCloser, in io.ReadCloser, promCounter pr if cntr != nil { atomic.AddUint64(cntr, uint64(n)) } - if err != nil && !isCloseError(err) { - log.Printf("http: proxy error (%s): %v", tag, err) + if err != nil && isInterestingError(err) { + log.Printf("error: http: proxy error (%s): %v", tag, err) } } // This is a bad implementation (see https://github.com/golang/go/issues/4373 // for some notes on why it is a layering violation), and we could replace it // with an atomic 'closing' flag. -func isCloseError(err error) bool { - return strings.Contains(err.Error(), "use of closed network connection") +func isInterestingError(err error) bool { + s := err.Error() + return !(strings.Contains(s, "use of closed network connection") || strings.Contains(s, "connection reset by peer")) } // Simple two-way TCP proxy that copies data in both directions and