bittor

package module
v0.0.0-...-025fffd Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2014 License: GPL-2.0 Imports: 6 Imported by: 0

README

bittor

Parses bittorrent files. Atm it assumes there is a "master dictionary" with an info dictionary inside of it (This is what http://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure sais). Dictionariy keys are assumed to only be strings, while values can be anything (http://wiki.theory.org/BitTorrentSpecification#Dictionaries). Will implement torrent encoding later when the main torrent client are done.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInfoDict

func GetInfoDict(m map[string]interface{}) (map[string]interface{}, error)

Gets the info dict out of a main dict, returns nil if it doesn't exists

func GetInfoHash

func GetInfoHash(tData []byte) (hash.Hash, error)

func GetMainDict

func GetMainDict(tData []byte) (map[string]interface{}, error)

Reads in the torrentfile f_name and assumes that the torrent just have one main dict item (altough the main dict can contain arbitrary many items). The dict itself is assumed to only have strings or ints as keys (Altough both are represented as strings) the value can be anything and is returned as an interface{}, type assertion is needed to properly access the value.

func GetStringListFromDict

func GetStringListFromDict(key string, dict map[string]interface{}) ([]string, error)

Gets a string list value from a dictionary (or map[string]Interface{}) that has the key value "key". These reflection things are subtle and recommended reading is

http://blog.golang.org/2011/09/laws-of-reflection.html, http://research.swtch.com/interfaces and the The "fmt" source code.

If there is diffrent list-values in a list you'll have to implement your own corresponding function. The string list value is so common that this function is included ;)

Types

This section is empty.

Jump to

Keyboard shortcuts

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