aboutsummaryrefslogtreecommitdiff
path: root/cmd/mybittorrent
diff options
context:
space:
mode:
authorjet2tlf <jet2tlf@gmail.com>2024-06-03 17:45:17 +0000
committerjet2tlf <jet2tlf@gmail.com>2024-06-03 17:45:17 +0000
commitb01c839940e6ea22ddc28aa0c975d3cd3da69e72 (patch)
tree3f1811c4980d6fe24bdd0cf78a12acb5a696b1bf /cmd/mybittorrent
parent6091bea631659a2e5d152726f3581ca2d1bd235c (diff)
downloadbittorrent-go-b01c839940e6ea22ddc28aa0c975d3cd3da69e72.tar.gz
bittorrent-go-b01c839940e6ea22ddc28aa0c975d3cd3da69e72.zip
codecrafters submit [skip ci]
Diffstat (limited to 'cmd/mybittorrent')
-rw-r--r--cmd/mybittorrent/main.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/cmd/mybittorrent/main.go b/cmd/mybittorrent/main.go
index d8014e7..5eecb20 100644
--- a/cmd/mybittorrent/main.go
+++ b/cmd/mybittorrent/main.go
@@ -36,12 +36,22 @@ func main() {
panic(err)
}
+ fmt.Printf("Tracker URL: %s\n", meta.Announce)
+ fmt.Printf("Length: %d\n", meta.Info.Length)
+
sha := sha1.New()
if err = bencode.Marshal(sha, meta.Info); err != nil {
panic(err)
}
- fmt.Printf("Tracker URL: %s\nLength: %d\nInfo Hash: %x", meta.Announce, meta.Info.Length, sha.Sum(nil))
+ fmt.Printf("Info Hash: %x", sha.Sum(nil))
+
+ fmt.Printf("Piece Length: %d\n", meta.Info.PieceLength)
+ fmt.Println("Piece Hashes:")
+
+ for i := 0; i < len(meta.Info.Pieces); i += 20 {
+ fmt.Printf("%x\n", meta.Info.Pieces[i:i+20])
+ }
default:
fmt.Println("Unknown command: " + command)