diff --git a/docs/udp_tracker_protocol.html b/docs/udp_tracker_protocol.html index 635b48f27..12057aa76 100644 --- a/docs/udp_tracker_protocol.html +++ b/docs/udp_tracker_protocol.html @@ -52,6 +52,37 @@ retrying.

+

optional part

+ +++++ + + + + + + + + + + + + + + + + + + + + +
sizenamedescription
int8_tflags1 = authentication
int8_t[8]username 
int8_t[8]password_hashsha1-hash of the tracker password
+

what is the point of having a fixed size username field instead of +a null-terminated string?

+

Why send the hash of the password instead of the password itself?

Server replies with packet:

diff --git a/docs/udp_tracker_protocol.rst b/docs/udp_tracker_protocol.rst index c9109d564..3f4e424d4 100755 --- a/docs/udp_tracker_protocol.rst +++ b/docs/udp_tracker_protocol.rst @@ -40,6 +40,24 @@ Client sends packet: | int32_t | transaction_id | Randomized by client. | +-------------+---------------------+----------------------------------------+ +optional part + ++-------------+---------------------+----------------------------------------+ +| size | name | description | ++=============+=====================+========================================+ +| int8_t | flags | 1 = authentication | ++-------------+---------------------+----------------------------------------+ +| int8_t[8] | username | | ++-------------+---------------------+----------------------------------------+ +| int8_t[8] | password_hash | sha1-hash of the tracker password | ++-------------+---------------------+----------------------------------------+ + +what is the point of having a fixed size username field instead of +a null-terminated string? + +Why send the hash of the password instead of the password itself? + + Server replies with packet: +-------------+---------------------+----------------------------------------+ diff --git a/src/file.cpp b/src/file.cpp index 3551057dd..2f500f0e5 100755 --- a/src/file.cpp +++ b/src/file.cpp @@ -38,12 +38,17 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include +#include +typedef int mode_t; #else #define _FILE_OFFSET_BITS 64 #include #include +#include +#include #endif @@ -57,9 +62,9 @@ namespace { enum { mode_in = 1, mode_out = 2 }; - int map_open_mode(int m) + mode_t map_open_mode(int m) { - if (m == (mode_in | mode_out)) return O_RDWR | O_BINARY; +// if (m == (mode_in | mode_out)) return O_RDWR | O_BINARY; if (m == mode_out) return O_WRONLY | O_CREAT | O_BINARY; if (m == mode_in) return O_RDONLY | O_BINARY; assert(false); @@ -97,8 +102,10 @@ namespace libtorrent void open(fs::path const& path, int mode) { close(); - m_fd = ::open(path.native_file_string().c_str(), map_open_mode(mode)); - m_open_mode = mode; + m_fd = ::open( + path.native_file_string().c_str() + , map_open_mode(mode) + , S_IREAD | S_IWRITE); if (m_fd == -1) { std::stringstream msg; @@ -106,6 +113,7 @@ namespace libtorrent << strerror(errno); throw file_error(msg.str()); } + m_open_mode = mode; } void close()