init
This commit is contained in:
18
metadata.go
Normal file
18
metadata.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/zeebo/bencode"
|
||||
)
|
||||
|
||||
type TorrentMetadata struct {
|
||||
Info bencode.RawMessage `bencode:"info"`
|
||||
}
|
||||
|
||||
func getTorrentInfoHash(torrent []byte) (string, error) {
|
||||
torrentMetadata := &TorrentMetadata{}
|
||||
if err := bencode.DecodeBytes(torrent, torrentMetadata); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return toSha1(torrentMetadata.Info), nil
|
||||
}
|
||||
Reference in New Issue
Block a user