summaryrefslogtreecommitdiff
path: root/pkg/vpn/bonafide/auth_sip.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/vpn/bonafide/auth_sip.go')
-rw-r--r--pkg/vpn/bonafide/auth_sip.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/pkg/vpn/bonafide/auth_sip.go b/pkg/vpn/bonafide/auth_sip.go
index 5da562d..cc9d967 100644
--- a/pkg/vpn/bonafide/auth_sip.go
+++ b/pkg/vpn/bonafide/auth_sip.go
@@ -44,15 +44,21 @@ func (a *sipAuthentication) getToken(user, password string) ([]byte, error) {
}
credJSON, err := formatCredentials(user, password)
if err != nil {
- return nil, fmt.Errorf("Cannot encode credentials: %s", err)
+ log.Println("ERROR: cannot encode credentials.", err)
+ return nil, fmt.Errorf("TokenErrBadCred")
}
resp, err := a.client.Post(a.authURI, "text/json", strings.NewReader(credJSON))
if err != nil {
- return nil, fmt.Errorf("Error on auth request: %v", err)
+ log.Println("ERROR: failed auth request", err)
+ if os.IsTimeout(err) {
+ return nil, fmt.Errorf("TokenErrTimeout")
+ } else {
+ return nil, fmt.Errorf("TokenErrBadPost")
+ }
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
- return nil, fmt.Errorf("Cannot get token: Error %d", resp.StatusCode)
+ return nil, fmt.Errorf("TokenErrBadStatus %d", resp.StatusCode)
}
token, err := ioutil.ReadAll(resp.Body)
if err != nil {