From faa53d7657636f01ac371d6bda592c2d380380bd Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 2 Dec 2013 04:24:10 +0000 Subject: [PATCH] member re-order and struct packing --- include/libtorrent/bt_peer_connection.hpp | 101 +++++------ include/libtorrent/config.hpp | 6 +- include/libtorrent/peer_connection.hpp | 198 +++++++++++----------- include/libtorrent/session_settings.hpp | 17 +- src/bt_peer_connection.cpp | 24 ++- src/peer_connection.cpp | 36 ++-- test/test_pe_crypto.cpp | 2 +- 7 files changed, 199 insertions(+), 185 deletions(-) diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index f85490b26..1ea3bbd4d 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -344,10 +344,44 @@ private: }; #endif - std::string m_client_version; - // state of on_receive - state m_state; + boost::uint8_t m_state; + + // this is set to true if the handshake from + // the peer indicated that it supports the + // extension protocol + bool m_supports_extensions:1; + bool m_supports_dht_port:1; + bool m_supports_fast:1; + +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS + // this is set to true when the client's + // bitfield is sent to this peer + bool m_sent_bitfield:1; + + bool m_in_constructor:1; + + bool m_sent_handshake:1; +#endif + +#ifndef TORRENT_DISABLE_ENCRYPTION + // this is set to true after the encryption method has been + // succesfully negotiated (either plaintext or rc4), to signal + // automatic encryption/decryption. + bool m_encrypted:1; + + // true if rc4, false if plaintext + bool m_rc4_encrypted:1; + + // the message ID for upload only message + // 0 if not supported + boost::uint8_t m_upload_only_id; + + // the message ID for holepunch messages + boost::uint8_t m_holepunch_id; +#endif + + std::string m_client_version; static const message_handler m_message_handler[num_supported_messages]; @@ -376,43 +410,7 @@ private: // don't suggest it again bitfield m_sent_suggested_pieces; -#ifndef TORRENT_DISABLE_EXTENSIONS - // the message ID for upload only message - // 0 if not supported - boost::uint8_t m_upload_only_id; - - // the message ID for holepunch messages - boost::uint8_t m_holepunch_id; - - // the message ID for don't-have message - boost::uint8_t m_dont_have_id; - - // the message ID for share mode message - // 0 if not supported - boost::uint8_t m_share_mode_id; - - char m_reserved_bits[8]; -#endif - // this is set to true if the handshake from - // the peer indicated that it supports the - // extension protocol - bool m_supports_extensions:1; - bool m_supports_dht_port:1; - bool m_supports_fast:1; - #ifndef TORRENT_DISABLE_ENCRYPTION - // this is set to true after the encryption method has been - // succesfully negotiated (either plaintext or rc4), to signal - // automatic encryption/decryption. - bool m_encrypted; - - // true if rc4, false if plaintext - bool m_rc4_encrypted; - - // used to disconnect peer if sync points are not found within - // the maximum number of bytes - int m_sync_bytes_read; - // initialized during write_pe1_2_dhkey, and destroyed on // creation of m_enc_handler. Cannot reinitialize once // initialized. @@ -432,18 +430,23 @@ private: // the sync hash (hash("req1",secret)). Destroyed after the // sync step. boost::scoped_ptr m_sync_hash; + + // used to disconnect peer if sync points are not found within + // theHTTP/1.1 200 OK Date: Wed, 23 Jul 2025 04:24:29 GMT Content-Type: text/plain; charset=utf-8 Connection: close Transfer-Encoding: chunked Cache-Control: max-age=0, private, must-revalidate, no-transform Set-Cookie: i_like_gitea=f96e3f0611057ce6; Path=/; HttpOnly; Secure; SameSite=Lax Set-Cookie: _csrf=8XNiU6b2hAxPnH-XfE5J71kwiFY6MTc1MzI0NDY2OTQ3OTExMzk3Ng; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax X-Frame-Options: SAMEORIGIN X-Cache-Status: HIT X-Cache-Age: 0 513d From faa53d7657636f01ac371d6bda592c2d380380bd Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 2 Dec 2013 04:24:10 +0000 Subject: [PATCH] member re-order and struct packing --- include/libtorrent/bt_peer_connection.hpp | 101 +++++------ include/libtorrent/config.hpp | 6 +- include/libtorrent/peer_connection.hpp | 198 +++++++++++----------- include/libtorrent/session_settings.hpp | 17 +- src/bt_peer_connection.cpp | 24 ++- src/peer_connection.cpp | 36 ++-- test/test_pe_crypto.cpp | 2 +- 7 files changed, 199 insertions(+), 185 deletions(-) diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index f85490b26..1ea3bbd4d 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -344,10 +344,44 @@ private: }; #endif - std::string m_client_version; - // state of on_receive - state m_state; + boost::uint8_t m_state; + + // this is set to true if the handshake from + // the peer indicated that it supports the + // extension protocol + bool m_supports_extensions:1; + bool m_supports_dht_port:1; + bool m_supports_fast:1; + +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS + // this is set to true when the client's + // bitfield is sent to this peer + bool m_sent_bitfield:1; + + bool m_in_constructor:1; + + bool m_sent_handshake:1; +#endif + +#ifndef TORRENT_DISABLE_ENCRYPTION + // this is set to true after the encryption method has been + // succesfully negotiated (either plaintext or rc4), to signal + // automatic encryption/decryption. + bool m_encrypted:1; + + // true if rc4, false if plaintext + bool m_rc4_encrypted:1; + + // the message ID for upload only message + // 0 if not supported + boost::uint8_t m_upload_only_id; + + // the message ID for holepunch messages + boost::uint8_t m_holepunch_id; +#endif + + std::string m_client_version; static const message_handler m_message_handler[num_supported_messages]; @@ -376,43 +410,7 @@ private: // don't suggest it again bitfield m_sent_suggested_pieces; -#ifndef TORRENT_DISABLE_EXTENSIONS - // the message ID for upload only message - // 0 if not supported - boost::uint8_t m_upload_only_id; - - // the message ID for holepunch messages - boost::uint8_t m_holepunch_id; - - // the message ID for don't-have message - boost::uint8_t m_dont_have_id; - - // the message ID for share mode message - // 0 if not supported - boost::uint8_t m_share_mode_id; - - char m_reserved_bits[8]; -#endif - // this is set to true if the handshake from - // the peer indicated that it supports the - // extension protocol - bool m_supports_extensions:1; - bool m_supports_dht_port:1; - bool m_supports_fast:1; - #ifndef TORRENT_DISABLE_ENCRYPTION - // this is set to true after the encryption method has been - // succesfully negotiated (either plaintext or rc4), to signal - // automatic encryption/decryption. - bool m_encrypted; - - // true if rc4, false if plaintext - bool m_rc4_encrypted; - - // used to disconnect peer if sync points are not found within - // the maximum number of bytes - int m_sync_bytes_read; - // initialized during write_pe1_2_dhkey, and destroyed on // creation of m_enc_handler. Cannot reinitialize once // initialized. @@ -432,18 +430,23 @@ private: // the sync hash (hash("req1",secret)). Destroyed after the // sync step. boost::scoped_ptr m_sync_hash; + + // used to disconnect peer if sync points are not found within + // the 0