From 1331ed2be8072b6e779041044ceb7dda6e2a033a Mon Sep 17 00:00:00 2001 From: Jesper Louis Andersen Date: Sat, 2 Aug 2008 14:38:41 +0200 Subject: [PATCH] Add support for arbitrary protocol capabilities. --- lib/etorrent-1.0/src/etorrent_peer_communication.erl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/etorrent-1.0/src/etorrent_peer_communication.erl b/lib/etorrent-1.0/src/etorrent_peer_communication.erl index 945e244..6cd6b7f 100644 --- a/lib/etorrent-1.0/src/etorrent_peer_communication.erl +++ b/lib/etorrent-1.0/src/etorrent_peer_communication.erl @@ -18,7 +18,10 @@ -define(DEFAULT_HANDSHAKE_TIMEOUT, 120000). -define(HANDSHAKE_SIZE, 68). -define(PROTOCOL_STRING, "BitTorrent protocol"). --define(RESERVED_BYTES, 0:64/big). + +%% Extensions +-define(EXT_BASIS, 0). % The protocol basis +-define(EXT_FAST, 4). % The Fast Extension %% Packet types -define(CHOKE, 0:8). @@ -204,7 +207,13 @@ complete_handshake(Socket, InfoHash, LocalPeerId) -> %%-------------------------------------------------------------------- build_peer_protocol_header() -> PSSize = length(?PROTOCOL_STRING), - <>. + ReservedBytes = protocol_capabilities(), + <>. + +protocol_capabilities() -> + ProtoSpec = lists:sum([%?EXT_FAST, + ?EXT_BASIS]), + <>. %%-------------------------------------------------------------------- %% Function: receive_header(socket()) -> {ok, proto_version(), -- 2.11.4.GIT