From 1bd28b097cf64e60ab5b62cde2ce4ad16ff1f6ee Mon Sep 17 00:00:00 2001 From: Leo Balduf Date: Thu, 8 Sep 2016 11:38:25 -0400 Subject: [PATCH] udp: add scrape address length to context --- frontend/udp/frontend.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/udp/frontend.go b/frontend/udp/frontend.go index fb1017d..40fa913 100644 --- a/frontend/udp/frontend.go +++ b/frontend/udp/frontend.go @@ -15,6 +15,7 @@ import ( "github.com/chihaya/chihaya/bittorrent" "github.com/chihaya/chihaya/frontend" "github.com/chihaya/chihaya/frontend/udp/bytepool" + "github.com/chihaya/chihaya/middleware" ) func init() { @@ -222,8 +223,10 @@ func (t *Frontend) handleRequest(r Request, w ResponseWriter) (actionName string return } + ctx := context.WithValue(context.Background(), middleware.ScrapeIsIPv6Key, len(r.IP) == net.IPv6len) + var resp *bittorrent.ScrapeResponse - resp, err = t.logic.HandleScrape(context.Background(), req) + resp, err = t.logic.HandleScrape(ctx, req) if err != nil { WriteError(w, txID, err) return