Clean the error message on connect failure so username and password is not shown.
This commit is contained in:
parent
27b69ccca3
commit
e4a80edc95
1 changed files with 5 additions and 1 deletions
|
@ -11,6 +11,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MarshallAndSend takes the reply structure, marshalls it to json, and
|
// MarshallAndSend takes the reply structure, marshalls it to json, and
|
||||||
|
@ -34,7 +35,10 @@ func MarshallAndSend(rawReply Reply, w io.Writer) (string, error) {
|
||||||
func jsonRpcSend(user string, password string, server string, message []byte) (*http.Response, error) {
|
func jsonRpcSend(user string, password string, server string, message []byte) (*http.Response, error) {
|
||||||
resp, err := http.Post("http://"+user+":"+password+"@"+server,
|
resp, err := http.Post("http://"+user+":"+password+"@"+server,
|
||||||
"application/json", bytes.NewBuffer(message))
|
"application/json", bytes.NewBuffer(message))
|
||||||
|
// We do not want to log the username/password in the errors.
|
||||||
|
re := regexp.MustCompile(`http://\w+:\w+`)
|
||||||
|
errString := re.ReplaceAllString(fmt.Sprintf("%v", err), "")
|
||||||
|
err = fmt.Errorf(errString)
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue