package meta // see also: https://en.wikipedia.org/wiki/Torrent_file import ( "fmt" "time" ) type Nodes map[string]int // Host:Port type Torrent struct { Announce string `bencode:"announce"` AnnounceList [][]string `bencode:"announce-list,optional"` // BEP-0012 Comment string `bencode:"comment,optional"` CreatedBy string `bencode:"created by,optional"` CreationDate time.Time `bencode:"creation date,optional"` Encoding string `bencode:"encoding,optional"` HTTPSeeds []string `bencode:"httpseeds,optional"` // BEP-0017 Info Info `bencode:"info"` InfoHash []byte `bencode:"-"` //Nodes Nodes `bencode:"nodes"` // BEP-0005 //URLList []string `bencode:"url-list,optional"` } func (t Torrent) String() string { s := fmt.Sprintf("announce: %s\n", t.Announce) s += fmt.Sprintf("comment: %s\n", t.Comment) s += fmt.Sprintf("date: %s\n", t.CreationDate) s += fmt.Sprintf("%v", t.Info) s += fmt.Sprintf("info hash: % x", t.InfoHash) return s }