Quote UDP tracker response error bodies with %#q

This commit is contained in:
Matt Joiner 2022-02-20 16:15:45 +11:00
parent 7d41b9b21c
commit fe43ce07c8
1 changed files with 3 additions and 1 deletions

View File

@ -164,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 = fmt.Errorf("error response: %s", 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)
}