aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-06-21 20:28:31 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-06-21 20:28:31 +0200
commit7ca6c3457a8b63040e102a5208dcbcf51a713201 (patch)
tree8a6eebf3aa2418b5048dff8de499c30304b80753
parent789d0b498ad424a4f602d6082d764968be456ebe (diff)
Update TrackerRequest
-rw-r--r--meta/tracker.go27
-rw-r--r--tracker/query.go12
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)