class QuartzTorrent::Extension
This class contains constants that represent our numbering of the Bittorrent peer-protocol extensions we support. It also has some utility methods related to extensions.
Constants
- MetadataExtensionId
The metadata extension (BEP 9)
Public Class Methods
createExtendedHandshake(info)
click to toggle source
Create an ExtendedHandshake
object based on the passed Torrent metadata info struct. @param info The torrent metadata info struct. It is used to determine the size to send
when negotiating the metadata extension.
# File lib/quartz_torrent/extension.rb, line 13 def self.createExtendedHandshake(info) msg = ExtendedHandshake.new extensionIds = { 'ut_metadata' => MetadataExtensionId } msg.dict['m'] = extensionIds if info msg.dict['metadata_size'] = info.bencode.length else msg.dict['metadata_size'] = 0 end msg end
peerMsgClassForExtensionName(info)
click to toggle source
Get the class to use to serialize and unserialize the specified Bittorent extension. Returns nil if we don’t support that extension. @param info The name of a bittorrent extension as specified in the BEP, for example ‘ut_metadata’.
# File lib/quartz_torrent/extension.rb, line 33 def self.peerMsgClassForExtensionName(info) if info == 'ut_metadata' ExtendedMetaInfo else nil end end