diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2021-07-04 17:13:28 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2021-07-04 17:13:28 +0100 |
| commit | 5881f58af573346eb0c25945a433bf9859191ac5 (patch) | |
| tree | be668c6173795acbbc660b980a1e55d7373afe7b | |
| parent | e59a2421c020d4b7c224750e486f40d09db52c89 (diff) | |
Check and log more possible errors
| -rw-r--r-- | cmd/fwdsms/mailer.go | 4 | ||||
| -rw-r--r-- | pkg/twilio/filter.go | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/cmd/fwdsms/mailer.go b/cmd/fwdsms/mailer.go index f8c1db6..cb687c9 100644 --- a/cmd/fwdsms/mailer.go +++ b/cmd/fwdsms/mailer.go @@ -35,7 +35,9 @@ func (m *mailer) sendEmail(e email) error { if err != nil { return err } - conn.SetDeadline(time.Now().Add(5 * time.Second)) + if err := conn.SetDeadline(time.Now().Add(5 * time.Second)); err != nil { + log.Printf("Failed to set the SMTP connection deadline: %s.", err) + } h, _, _ := net.SplitHostPort(m.hostname) c, err := smtp.NewClient(conn, h) if err != nil { diff --git a/pkg/twilio/filter.go b/pkg/twilio/filter.go index 90e84cc..48e92ef 100644 --- a/pkg/twilio/filter.go +++ b/pkg/twilio/filter.go @@ -8,6 +8,7 @@ import ( "crypto/sha1" "encoding/base64" "errors" + "fmt" "log" "net/http" "sort" @@ -55,7 +56,9 @@ func (th *Filter) CheckRequestSignature(r *http.Request) error { } s := r.URL.String() + strings.Join(parts, "") h := hmac.New(sha1.New, th.AuthToken) - h.Write([]byte(s)) + if _, err := h.Write([]byte(s)); err != nil { + return fmt.Errorf("failed to write bytes to calculate signature: %s", err) + } ourSig := h.Sum(nil) if !hmac.Equal(reqSig, ourSig) { |
