diff --git a/middleware/fixedpeer/fixedpeer.go b/middleware/fixedpeer/fixedpeer.go index 51d16e9..2af03ec 100644 --- a/middleware/fixedpeer/fixedpeer.go +++ b/middleware/fixedpeer/fixedpeer.go @@ -53,11 +53,15 @@ func NewHook(cfg Config) (middleware.Hook, error) { if err != nil { return nil, err } + ip := net.ParseIP(parts[0]).To4() + if ip == nil { + panic("Invalid ip4 on fixed_peers") + } peers = append(peers, bittorrent.Peer{ ID: bittorrent.PeerID{0}, Port: uint16(port), - IP: bittorrent.IP{net.ParseIP(parts[0]), bittorrent.IPv4}, + IP: bittorrent.IP{IP: ip}, }) } h := &hook{ diff --git a/middleware/hooks.go b/middleware/hooks.go index cd4ae62..23a104c 100644 --- a/middleware/hooks.go +++ b/middleware/hooks.go @@ -98,8 +98,8 @@ func (h *responseHook) HandleAnnounce(ctx context.Context, req *bittorrent.Annou // Add the Scrape data to the response. s := h.store.ScrapeSwarm(req.InfoHash, req.IP.AddressFamily) - resp.Incomplete = s.Incomplete - resp.Complete = s.Complete + resp.Incomplete += s.Incomplete + resp.Complete += s.Complete err = h.appendPeers(req, resp) return ctx, err