Contains the Concourse pipeline definition for building a line-server container
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
517 B

  1. package torrent
  2. import (
  3. "crypto/sha1"
  4. )
  5. const (
  6. TORRENT_PIECE_LENGTH = 262144
  7. )
  8. type TorrentInfo struct {
  9. PieceLength int `bencode:"piece length"`
  10. Pieces string `bencode:"pieces"`
  11. Name string `bencode:"name"`
  12. Length int `bencode:"length"`
  13. }
  14. type Torrent struct {
  15. Encoding string `bencode:"encoding"`
  16. Info TorrentInfo `bencode:"info"`
  17. UrlList []string `bencode:"url-list"`
  18. }
  19. func HashPiece(piece []byte) []byte {
  20. h := sha1.New()
  21. h.Write(piece)
  22. return h.Sum(nil)
  23. }