From 7ca6c3457a8b63040e102a5208dcbcf51a713201 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 21 Jun 2016 20:28:31 +0200 Subject: Update TrackerRequest --- meta/tracker.go | 27 ++++++++++++++------------- tracker/query.go | 12 ------------ 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/meta/tracker.go b/meta/tracker.go index 111f4b7..1150849 100644 --- a/meta/tracker.go +++ b/meta/tracker.go @@ -12,19 +12,19 @@ const ( ) type TrackerRequest struct { - InfoHash []byte // info_hash - PeerID []byte // peer_id - Port int - Uploaded int - Downloaded int - Left int - Compact bool // always true - NoPeerID bool - Event Event - IP net.IPAddr - NumWant int - Key []byte - TrackerID []byte + InfoHash []byte `query:"info_hash"` // info_hash + PeerID []byte `query:"peer_id"` // peer_id + Port int `query:"port,optional"` + Uploaded int `query:"uploaded,optional"` + Downloaded int `query:"downloaded,optional"` + Left int `query:"left,optional"` + Compact bool `query:"compact,optional"` // always true + NoPeerID bool `query:"no_peer_id,optional"` + Event Event `query:"event,optional"` + IP net.IPAddr `query:"ip,optional"` + NumWant int `query:"numwant,optional"` + Key []byte `query:"key,optional"` + TrackerID []byte `query:"tracker_id,optional"` } // we support only compact mode @@ -35,6 +35,7 @@ type TrackerResponse struct { Interval int `bencode:"interval"` MinInterval int `bencode:"min interval"` Peers []byte `bencode:"peers"` + Peers6 []byte `bencode:"peers6"` TrackerId string `bencode:"tracker id"` WarningMessage string `bencode:"warning message"` } diff --git a/tracker/query.go b/tracker/query.go index 5f9e695..4e233b8 100644 --- a/tracker/query.go +++ b/tracker/query.go @@ -2,24 +2,12 @@ package tracker import ( "errors" - "net" "net/url" "reflect" "strconv" "strings" ) -type Request struct { - InfoHash []byte `query:"info_hash"` - PeerID []byte `query:"peer_id"` - Port int `query:"port"` - Uploaded int `query:"uploaded"` - Downloaded int `query:"downloaded"` - Left int `query:"left"` - IP net.IPAddr `query:"ip,optional"` - NumWant int `query:"numwant,optional"` -} - func MarshalQuery(v interface{}) (string, error) { val := reflect.ValueOf(v) return marshalQuery(val) -- cgit v1.2.3