preserve Incomplete/Complete
This commit is contained in:
parent
737053bd0e
commit
c8f0c1eed8
2 changed files with 7 additions and 3 deletions
|
@ -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{
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue