Add more logging to incoming handler

This commit is contained in:
Peter Stuifzand 2018-04-08 00:02:46 +02:00
parent 42a73d6ccd
commit 551d9f233a
2 changed files with 7 additions and 1 deletions

View File

@ -63,6 +63,7 @@ func (h *incomingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// find secret // find secret
secret := h.Backend.GetSecret(feed) secret := h.Backend.GetSecret(feed)
if secret == "" { if secret == "" {
log.Printf("missing secret for feed %d\n", feed)
http.Error(w, "Unknown", 400) http.Error(w, "Unknown", 400)
return return
} }
@ -72,11 +73,13 @@ func (h *incomingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
parts := strings.Split(sig, "=") parts := strings.Split(sig, "=")
if len(parts) != 2 { if len(parts) != 2 {
log.Printf("signature format %d %#v\n", feed, parts)
http.Error(w, "Signature format", 400) http.Error(w, "Signature format", 400)
return return
} }
if sig != "sha1" { if parts[0] != "sha1" {
log.Printf("signature format %d %s\n", feed, sig)
http.Error(w, "Unknown signature format", 400) http.Error(w, "Unknown signature format", 400)
return return
} }
@ -89,6 +92,7 @@ func (h *incomingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
signature := mac.Sum(nil) signature := mac.Sum(nil)
if fmt.Sprintf("%x", signature) != parts[1] { if fmt.Sprintf("%x", signature) != parts[1] {
log.Printf("signature no match feed=%d %s %s\n", feed, Signature, parts[1])
http.Error(w, "Signature doesn't match", 400) http.Error(w, "Signature doesn't match", 400)
return return
} }

View File

@ -109,6 +109,7 @@ func (h *hubIncomingBackend) CreateFeed(topic string, channel string) (int64, er
} }
func (h *hubIncomingBackend) UpdateFeed(feedID int64, contentType string, body io.Reader) error { func (h *hubIncomingBackend) UpdateFeed(feedID int64, contentType string, body io.Reader) error {
log.Printf("updating feed %d", feedID)
u, err := redis.String(h.conn.Do("HGET", fmt.Sprintf("feed:%d", feedID), "url")) u, err := redis.String(h.conn.Do("HGET", fmt.Sprintf("feed:%d", feedID), "url"))
if err != nil { if err != nil {
return err return err
@ -118,6 +119,7 @@ func (h *hubIncomingBackend) UpdateFeed(feedID int64, contentType string, body i
return err return err
} }
log.Printf("updating feed %d - %s %s\n", feedID, u, channel)
h.backend.ProcessContent(channel, u, contentType, body) h.backend.ProcessContent(channel, u, contentType, body)
return err return err