bazbittorrent

package module
v0.0.0-...-86555eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2024 License: MIT Imports: 13 Imported by: 0

README

baz_bit-torrent

Implementation of the bit torrent specification

Documentation

Index

Constants

View Source
const (
	BitTorrentIdentifier = "BitTorrent protocol"
	BazPeerID            = "BazeengaBitTorrent24"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BencodingDecoder

type BencodingDecoder struct {
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(r io.Reader) *BencodingDecoder

func (*BencodingDecoder) Decode

func (d *BencodingDecoder) Decode() (map[string]any, error)

func (*BencodingDecoder) DecodeDict

func (d *BencodingDecoder) DecodeDict() (value map[string]any, err error)

func (*BencodingDecoder) DecodeInt

func (d *BencodingDecoder) DecodeInt() (value int, err error)

func (*BencodingDecoder) DecodeList

func (d *BencodingDecoder) DecodeList() (value []any, err error)

func (*BencodingDecoder) DecodeString

func (d *BencodingDecoder) DecodeString() (value string, err error)

type BencodingEncoder

type BencodingEncoder struct {
	EncodedData string
}

func (*BencodingEncoder) Encode

func (e *BencodingEncoder) Encode(decoded Mapable)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) Init

func (c *Client) Init(metaInfoFile MetaInfoFile)

func (*Client) SendConnectRequest

func (c *Client) SendConnectRequest()

type HandShakePayLoad

type HandShakePayLoad struct {
	// contains filtered or unexported fields
}

func (*HandShakePayLoad) Build

func (handShake *HandShakePayLoad) Build(PeerID []byte, InfoHash [20]byte) []byte

type Info

type Info struct {
	PieceLength int          `json:"piece length"` // common
	Pieces      string       `json:"pieces"`       // common
	Private     int          `json:"private"`      // common optional
	Name        string       `json:"name"`         // common
	Length      int          `json:"length"`       // single-file
	Md5sum      string       `json:"md5sum"`       // single-file optional
	Files       []MultiFiles `json:"files"`
}

func (Info) UnMarshallToDict

func (info Info) UnMarshallToDict() (ret map[string]any)

type Mapable

type Mapable interface {
	UnMarshallToDict() map[string]any
}

type MetaInfoFile

type MetaInfoFile struct {
	Announce     string     `json:"announce"`
	Info         Info       `json:"info"`
	AnnounceList [][]string `json:"announce-list"` // optional
	CreationDate int        `json:"creation date"` // optional
	Comment      string     `json:"comment"`       // optional
	CreatedBy    string     `json:"created by"`    // optional
	Encoding     string     `json:"encoding"`      // optional
}

func (*MetaInfoFile) HostDetails

func (metainfofile *MetaInfoFile) HostDetails() []*url.URL

func (MetaInfoFile) InfoHash

func (metainfofile MetaInfoFile) InfoHash() [20]byte

func (*MetaInfoFile) UnMarshalFile

func (metainfofile *MetaInfoFile) UnMarshalFile(filename string)

func (MetaInfoFile) UnMarshallToDict

func (metainfofile MetaInfoFile) UnMarshallToDict() (ret map[string]any)

type MultiFiles

type MultiFiles struct {
	Length int      `json:"length"`
	Md5sum string   `json:"md5sum"` // optional
	Path   []string `json:"path"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL