From 764e2ea2c3e7e099e463cdb705214efcb94c9f24 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 16 Apr 2005 10:20:50 +0000 Subject: [PATCH] *** empty log message *** --- docs/udp_tracker_protocol.html | 526 --------------------------------- src/file_win.cpp | 35 +-- 2 files changed, 18 insertions(+), 543 deletions(-) diff --git a/docs/udp_tracker_protocol.html b/docs/udp_tracker_protocol.html index 679a8428d..e69de29bb 100644 --- a/docs/udp_tracker_protocol.html +++ b/docs/udp_tracker_protocol.html @@ -1,526 +0,0 @@ - - - - - - -Bittorrent udp-tracker protocol extension - - - -
-

Bittorrent udp-tracker protocol extension

- -
-

introduction

-

A tracker with the protocol "udp://" in its URI -is supposed to be contacted using this protocol.

-

This protocol is supported by -xbt-tracker.

-

For additional information and descritptions of -the terminology used in this document, see -the protocol specification

-

All values are sent in network byte order (big endian). The sizes -are specified with ANSI-C standard types.

-

If no response to a request is received within 15 seconds, resend -the request. If no reply has been received after 60 seconds, stop -retrying.

-
-
-

connecting

-
-

Client sends packet:

- ----- - - - - - - - - - - - - - - - - - - - - -
sizenamedescription
int64_tconnection_idMust be initialized to 0x41727101980 -in network byte order. This will -identify the protocol.
int32_taction0 for a connection request
int32_ttransaction_idRandomized by client.
-
-
-

Server replies with packet:

- ----- - - - - - - - - - - - - - - - - - - - - -
sizenamedescription
int32_tactionDescribes the type of packet, in this -case it should be 0, for connect. -If 3 (for error) see errors.
int32_ttransaction_idMust match the transaction_id sent -from the client.
int64_tconnection_idA connection id, this is used when -further information is exchanged with -the tracker, to identify you. -This connection id can be reused for -multiple requests, but if it's cached -for too long, it will not be valid -anymore.
-
-
-
-

announcing

-
-

Client sends packet:

- ----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sizenamedescription
int64_tconnection_idThe connection id acquired from -establishing the connection.
int32_tactionAction. in this case, 1 for announce. -See actions.
int32_ttransaction_idRandomized by client.
int8_t[20]info_hashThe info-hash of the torrent you want -announce yourself in.
int8_t[20]peer_idYour peer id.
int64_tdownloadedThe number of byte you've downloaded -in this session.
int64_tleftThe number of bytes you have left to -download until you're finished.
int64_tuploadedThe number of bytes you have uploaded -in this session.
int32_tevent

The event, one of

-
-
    -
  • none = 0
  • -
  • completed = 1
  • -
  • started = 2
  • -
  • stopped = 3
  • -
-
-
uint32_tipYour ip address. Set to 0 if you want -the tracker to use the sender of -this udp packet.
uint32_tkeyA unique key that is randomized by the -client.
int32_tnum_wantThe maximum number of peers you want -in the reply. Use -1 for default.
uint16_tportThe port you're listening on.
uint16_textensionsSee extensions
-
-
-

Server replies with packet:

- ----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sizenamedescription
int32_tactionThe action this is a reply to. Should -in this case be 1 for announce. -If 3 (for error) see errors. -See actions.
int32_ttransaction_idMust match the transaction_id sent -in the announce request.
int32_tintervalthe number of seconds you should wait -until reannouncing yourself.
int32_tleechersThe number of peers in the swarm that -has not finished downloading.
int32_tseedersThe number of peers in the swarm that -has finished downloading and are -seeding.
-

The rest of the server reply is a variable number of the following structure:

- ----- - - - - - - - - - - - - - - - - -
sizenamedescription
int32_tipThe ip of a peer in the swarm.
uint16_tportThe peer's listen port.
-
-
-
-

scraping

-
-

Client sends packet:

- ----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sizenamedescription
int64_tconnection_idThe connection id retreived from the -establishing of the connection.
int32_tactionThe action, in this case, 2 for -scrape. See actions.
int32_ttransaction_idRandomized by client.
int16_tnum_info_hashesThe number of info-hashes that will -follow.
uint16_textensionsSee extensions.
-

The following structure is repeated num_info_hashes times:

- ----- - - - - - - - - - - - - -
sizenamedescription
int8_t[20]info_hashThe info hash that is to be scraped.
-
-
-

Server replies with packet:

- ----- - - - - - - - - - - - - - - - - -
sizenamedescription
int32_tactionThe action, should in this case be -2 for scrape. -If 3 (for error) see errors.
int32_ttransaction_idMust match the sent transaction id.
-

The rest of the packet contains the following structures once for each info-hash -you asked in the scrape request.

- ----- - - - - - - - - - - - - - - - - - - - - -
sizenamedescription
int32_tcompleteThe total number of completed -downloads.
int32_tdownloadedThe current number of connected seeds.
int32_tincompleteThe current number of connected -leechers.
-
-
-
-

errors

-

In case of a tracker error,

-
-

server replies packet:

- ----- - - - - - - - - - - - - - - - - - - - - -
sizenamedescription
int32_tactionThe action, in this case 3, for error. -See actions.
int32_ttransaction_idMust match the transaction_id sent -from the client.
int8_t[]error_stringThe rest of the packet is a string -describing the error.
-
-
-
-

actions

-

The action fields has the following encoding:

-
-
    -
  • connect = 0
  • -
  • announce = 1
  • -
  • scrape = 2
  • -
  • error = 3 (only in server replies)
  • -
-
-
-
-

extensions

-

The extensions field is a bitmask. The following -bits are assigned:

-
- -
-
-

authentication

-

The packet will have an authentication part -appended to it. It has the following format:

- ----- - - - - - - - - - - - - - - - - - - - - -
sizenamedescription
int8_tusername_lengthThe number of characters in the -username.
int8_t[]usernameThe username, the number of characters -as specified in the previous field.
uint8_t[8]passwd_hashsha1(packet + sha1(password)) -The packet in this case means the -entire packet except these 8 bytes -that are the password hash. These are -the 8 first bytes (most significant) -from the 20 bytes hash calculated.
-
-
-
-

credits

-

Protocol designed by Olaf van der Spek

-
-
- - diff --git a/src/file_win.cpp b/src/file_win.cpp index 5f0d2da30..ee769b67c 100644 --- a/src/file_win.cpp +++ b/src/file_win.cpp @@ -59,24 +59,25 @@ namespace { int err = GetLastError(); - #ifdef UNICODE - wchar_t *wbuffer = 0; - FormatMessage( - FORMAT_MESSAGE_FROM_SYSTEM - |FORMAT_MESSAGE_ALLOCATE_BUFFER - , 0, err, 0, (LPWCSTR)&wbuffer, 0, 0); - std::string tmp_utf8; - wchar_utf8(wbuffer, tmp_utf8); - char* buffer = tmp_utf8.c_str(); - #else - char* buffer = 0; - FormatMessage( - FORMAT_MESSAGE_FROM_SYSTEM - |FORMAT_MESSAGE_ALLOCATE_BUFFER - , 0, err, 0, (LPSTR)&buffer, 0, 0); - #endif +#ifdef UNICODE + wchar_t *wbuffer = 0; + FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM + |FORMAT_MESSAGE_ALLOCATE_BUFFER + , 0, err, 0, (LPWCSTR)&wbuffer, 0, 0); + auto_localfree auto_free(wbuffer); + std::string tmp_utf8; + wchar_utf8(wbuffer, tmp_utf8); + char* buffer = tmp_utf8.c_str(); +#else + char* buffer = 0; + FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM + |FORMAT_MESSAGE_ALLOCATE_BUFFER + , 0, err, 0, (LPSTR)&buffer, 0, 0); + auto_localfree auto_free(buffer); +#endif - auto_localfree auto_free(buffer); // needed for exception safety std::stringstream s; s << (thrower ? thrower : "NULL") << ": " << (buffer ? buffer : "NULL");