Example #1
0
func (filemeta TorrentFileMeta) WriteBencodedTo(writer io.Writer) error {
	if _, present := filemeta["path"].(bencoding.List); !present {
		return errors.New("invalid path")
	}
	if _, present := filemeta["length"].(bencoding.Int); !present {
		return errors.New("invalid length")
	}

	return bencoding.Dict(filemeta).WriteBencodedTo(writer)
}
Example #2
0
func (metainfo TorrentMeta) WriteBencodedTo(writer io.Writer) error {
	if _, present := metainfo["name"].(bencoding.String); !present {
		return errors.New("invalid name")
	}
	if _, present := metainfo["piece length"].(bencoding.Int); !present {
		return errors.New("invalid piece length")
	}
	if _, present := metainfo["pieces"].(bencoding.String); !present {
		return errors.New("invalid pieces")
	}
	if _, present := metainfo["files"].(bencoding.List); !present {
		if _, present := metainfo["length"].(bencoding.Int); !present {
			return errors.New("invalid files or length")
		}
	}

	return bencoding.Dict(metainfo).WriteBencodedTo(writer)
}
Example #3
0
func (local *localNode) ToJsonable() (interface{}, error) {
	return bencoding.Dict(local.MarshalBencodingDict()).ToJsonable()
}
Example #4
0
func (filemeta TorrentFileMeta) ToJsonable() (interface{}, error) {
	return bencoding.Dict(filemeta).ToJsonable()
}
Example #5
0
func (metainfo TorrentMeta) ToJsonable() (interface{}, error) {
	return bencoding.Dict(metainfo).ToJsonable()
}