aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bencode/bencode.go4
-rw-r--r--examples/OpenBSD_songs_ogg-2016-03-25-0127.torrentbin0 -> 16847 bytes
-rw-r--r--torrent/torrent.go27
3 files changed, 31 insertions, 0 deletions
diff --git a/bencode/bencode.go b/bencode/bencode.go
index 119723b..8675f35 100644
--- a/bencode/bencode.go
+++ b/bencode/bencode.go
@@ -1,5 +1,9 @@
package bencode
+// mapping / limitations
+// dict -> struct
+// list -> aray of same type
+
type itemType int
const (
diff --git a/examples/OpenBSD_songs_ogg-2016-03-25-0127.torrent b/examples/OpenBSD_songs_ogg-2016-03-25-0127.torrent
new file mode 100644
index 0000000..f8fe7c1
--- /dev/null
+++ b/examples/OpenBSD_songs_ogg-2016-03-25-0127.torrent
Binary files differ
diff --git a/torrent/torrent.go b/torrent/torrent.go
new file mode 100644
index 0000000..f0c4b67
--- /dev/null
+++ b/torrent/torrent.go
@@ -0,0 +1,27 @@
+import "time"
+
+type File struct {
+ Length int `bencode:"length"`
+ MD5Sum []byte `bencode:md5sum,omitempty"`
+ Path string `bencode:"path"`
+}
+
+type Info struct {
+ Length int `bencode:"length"`
+ MD5Sum []byte `bencode:md5sum,omitempty"`
+ Name string `bencode:"name"`
+ PieceLength int `bencode:"piece length"`
+ Pieces []byte `bencode:"pieces"`
+ Files []File `bencode:"files"`
+}
+
+type Torrent struct {
+ Announce string `bencode:"announce"`
+ AnnounceList []string `bencode:"announce-list,omitemtpy"`
+ Comment string `bencode:"comment"`
+ CreatedBy string `bencode:"created by,omitempty"`
+ CreationDate time.Time `bencode:"creation date"`
+ HTTPSeeds []string `bencode:"httpseeds"` // not in draft
+ Info Info `bencode:"info"`
+ URLList string `bencode:"url-list,omitemtpy"` // not in draft
+}