]> Sergey Matveev's repositories - btrtrc.git/blobdiff - tracker/udp/client.go
Quote UDP tracker response error bodies with %#q
[btrtrc.git] / tracker / udp / client.go
index dc67a9001fd43aec5bc915f1acd1832b042d5627..0095a912aaac378995dd359f4bfa57d6d53e5380 100644 (file)
@@ -4,7 +4,6 @@ import (
        "bytes"
        "context"
        "encoding/binary"
-       "errors"
        "fmt"
        "io"
        "net"
@@ -165,7 +164,9 @@ func (cl *Client) request(ctx context.Context, action Action, body []byte) (resp
                        respBody = dr.Body
                        addr = dr.Addr
                } else if dr.Header.Action == ActionError {
-                       err = errors.New(string(dr.Body))
+                       // I've seen "Connection ID mismatch.^@" in less and other tools, I think they're just
+                       // not handling a trailing \x00 nicely.
+                       err = fmt.Errorf("error response: %#q", dr.Body)
                } else {
                        err = fmt.Errorf("unexpected response action %v", dr.Header.Action)
                }