Advertisement
cooperlees

Add Libtorrent 0.16.16 ToS (Raw)

Aug 21st, 2014
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 31.26 KB | None | 0 0
  1. diff --git a/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/socket.hpp b/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/socket.hpp
  2. index 058a18b..229e3e5 100644
  3. --- a/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/socket.hpp
  4. +++ b/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/socket.hpp
  5. @@ -64,7 +64,7 @@ POSSIBILITY OF SUCH DAMAGE.
  6.  #include <boost/asio/read.hpp>
  7.  #endif
  8.  
  9. -#ifdef __OBJC__
  10. +#ifdef __OBJC__
  11.  #undef Protocol
  12.  #endif
  13.  
  14. @@ -114,7 +114,7 @@ namespace libtorrent
  15.     };
  16.  #endif
  17.  #endif
  18. -  
  19. +
  20.  #ifdef TORRENT_WINDOWS
  21.  
  22.  #ifndef IPV6_PROTECTION_LEVEL
  23. @@ -135,6 +135,20 @@ namespace libtorrent
  24.     };
  25.  #endif
  26.  
  27. +    struct traffic_class
  28. +    {
  29. +        traffic_class(char val): m_value(val) {}
  30. +        template<class Protocol>
  31. +        int level(Protocol const&) const { return IPPROTO_IPV6; }
  32. +        template<class Protocol>
  33. +        int name(Protocol const&) const { return IPV6_TCLASS; }
  34. +        template<class Protocol>
  35. +        int const* data(Protocol const&) const { return &m_value; }
  36. +        template<class Protocol>
  37. +        size_t size(Protocol const&) const { return sizeof(m_value); }
  38. +        int m_value;
  39. +    };
  40. +
  41.     struct type_of_service
  42.     {
  43.  #ifdef WIN32
  44. diff --git a/0.16.16/src/libtorrent-rasterbar-0.16.16/src/parse_url.cpp b/0.16.16/src/libtorrent-rasterbar-0.16.16/src/parse_url.cpp
  45. index ee7f1d3..13d37a8 100644
  46. --- a/0.16.16/src/libtorrent-rasterbar-0.16.16/src/parse_url.cpp
  47. +++ b/0.16.16/src/libtorrent-rasterbar-0.16.16/src/parse_url.cpp
  48. @@ -128,6 +128,10 @@ namespace libtorrent
  49.         }
  50.  
  51.         start = end;
  52. +
  53. +        if (hostname[0] == '[')
  54. +            hostname.assign(hostname.begin()+1, hostname.end()-1);
  55. +
  56.  exit:
  57.         return boost::make_tuple(protocol, auth, hostname, port
  58.             , std::string(start, url.end()));
  59. diff --git a/0.16.16/src/libtorrent-rasterbar-0.16.16/src/peer_connection.cpp b/0.16.16/src/libtorrent-rasterbar-0.16.16/src/peer_connection.cpp
  60. index 2a94e51..ab80ee9 100644
  61. --- a/0.16.16/src/libtorrent-rasterbar-0.16.16/src/peer_connection.cpp
  62. +++ b/0.16.16/src/libtorrent-rasterbar-0.16.16/src/peer_connection.cpp
  63. @@ -409,7 +409,7 @@ namespace libtorrent
  64.             , m_socket->type_name()
  65.             , print_endpoint(local_ep).c_str());
  66.  #endif
  67. -      
  68. +
  69.  #ifndef TORRENT_DISABLE_GEO_IP
  70.         m_inet_as_name = m_ses.as_name_for_ip(m_remote.address());
  71.  #endif
  72. @@ -424,7 +424,7 @@ namespace libtorrent
  73.     {
  74.         if (m_ses.m_disk_thread.is_disk_buffer(buffer))
  75.             m_ses.m_disk_thread.rename_buffer(buffer, label);
  76. -  
  77. +
  78.         m_ses.m_buffer_usage_logger << log_time() << " append_send_buffer: " << size << std::endl;
  79.         m_ses.log_buffer_usage();
  80.     }
  81. @@ -533,12 +533,12 @@ namespace libtorrent
  82.             // if the peers are still identical (say, they're both waiting to be unchoked)
  83.             // fall through and rely on the logic to prioritize peers who have waited
  84.             // the longest to be unchoked
  85. -       }  
  86. +       }
  87.         else if (m_ses.settings().seed_choking_algorithm == session_settings::fastest_upload)
  88.         {
  89.             c1 = uploaded_in_last_round();
  90.             c2 = rhs.uploaded_in_last_round();
  91. -      
  92. +
  93.             // take torrent priority into account
  94.             c1 *= 1 + t1->priority();
  95.             c2 *= 1 + t2->priority();
  96. @@ -577,7 +577,7 @@ namespace libtorrent
  97.             if (score1 > score2) return true;
  98.             if (score2 > score1) return false;
  99.         }
  100. -      
  101. +
  102.         // prioritize the one that has waited the longest to be unchoked
  103.         // the round-robin unchoker relies on this logic. Don't change it
  104.         // without moving this into that unchoker logic
  105. @@ -596,7 +596,7 @@ namespace libtorrent
  106.  
  107.         c1 = uploaded_in_last_round();
  108.         c2 = p->uploaded_in_last_round();
  109. -      
  110. +
  111.         // take torrent priority into account
  112.         c1 *= 1 + t1->priority();
  113.         c2 *= 1 + t2->priority();
  114. @@ -638,6 +638,10 @@ namespace libtorrent
  115.                 peer_log(">>> SET_TOS[ tos: %d e: %s ]", m_ses.settings().peer_tos, ec.message().c_str());
  116.  #endif
  117.             }
  118. +            else if (m_remote.address().is_v6())
  119. +            {
  120. +                m_socket->set_option(traffic_class(m_ses.settings().peer_tos), ec);
  121. +            }
  122.         }
  123.  
  124.         if (t && t->ready_for_connections())
  125. @@ -684,9 +688,9 @@ namespace libtorrent
  126.     {
  127.         if (!m_logger) return;
  128.  
  129. -       va_list v; 
  130. +       va_list v;
  131.         va_start(v, fmt);
  132. -  
  133. +
  134.         char usr[400];
  135.         vsnprintf(usr, sizeof(usr), fmt, v);
  136.         va_end(v);
  137. @@ -845,7 +849,7 @@ namespace libtorrent
  138.             }
  139.             i = m_suggested_pieces.erase(i);
  140.         }
  141. -      
  142. +
  143.         if (m_num_pieces == int(m_have_piece.size()))
  144.         {
  145.  #ifdef TORRENT_VERBOSE_LOGGING
  146. @@ -1005,7 +1009,7 @@ namespace libtorrent
  147.  
  148.     int peer_connection::picker_options() const
  149.     {
  150. -       int ret = 0;
  151. +       int ret = 0;
  152.         boost::shared_ptr<torrent> t = m_torrent.lock();
  153.         TORRENT_ASSERT(t);
  154.         if (!t) return 0;
  155. @@ -1119,12 +1123,12 @@ namespace libtorrent
  156.     {
  157.         return m_request_queue;
  158.     }
  159. -  
  160. +
  161.     std::vector<pending_block> const& peer_connection::download_queue() const
  162.     {
  163.         return m_download_queue;
  164.     }
  165. -  
  166. +
  167.     std::vector<peer_request> const& peer_connection::upload_queue() const
  168.     {
  169.         return m_requests;
  170. @@ -1182,7 +1186,7 @@ namespace libtorrent
  171.         }
  172.  #endif
  173.     }
  174. -  
  175. +
  176.     size_type peer_connection::total_free_upload() const
  177.     {
  178.         return m_free_upload;
  179. @@ -1406,7 +1410,7 @@ namespace libtorrent
  180.             m_download_queue.begin(), m_download_queue.end()
  181.             , boost::bind(match_request, boost::cref(r), boost::bind(&pending_block::block, _1)
  182.             , t->block_size()));
  183. -  
  184. +
  185.  #ifdef TORRENT_VERBOSE_LOGGING
  186.         peer_log("<== REJECT_PIECE [ piece: %d | s: %d | l: %d ]"
  187.             , r.piece, r.start, r.length);
  188. @@ -1420,7 +1424,7 @@ namespace libtorrent
  189.             TORRENT_ASSERT(m_outstanding_bytes >= r.length);
  190.             m_outstanding_bytes -= r.length;
  191.             if (m_outstanding_bytes < 0) m_outstanding_bytes = 0;
  192. -          
  193. +
  194.             // if the peer is in parole mode, keep the request
  195.             if (peer_info_struct() && peer_info_struct()->on_parole)
  196.             {
  197. @@ -1470,7 +1474,7 @@ namespace libtorrent
  198.             send_block_requests();
  199.         }
  200.     }
  201. -  
  202. +
  203.     // -----------------------------
  204.     // ------- SUGGEST PIECE -------
  205.     // -----------------------------
  206. @@ -1501,7 +1505,7 @@ namespace libtorrent
  207.  #endif
  208.             return;
  209.         }
  210. -      
  211. +
  212.         if (t->valid_metadata())
  213.         {
  214.             if (index >= int(m_have_piece.size()))
  215. @@ -1589,8 +1593,8 @@ namespace libtorrent
  216.  #endif
  217.         m_peer_interested = true;
  218.         if (is_disconnecting()) return;
  219. -  
  220. -       // if the peer is ready to download stuff, it must have metadata       
  221. +
  222. +       // if the peer is ready to download stuff, it must have metadata
  223.         m_has_metadata = true;
  224.  
  225.         disconnect_if_redundant();
  226. @@ -1792,7 +1796,7 @@ namespace libtorrent
  227.         m_have_piece.set_bit(index);
  228.         ++m_num_pieces;
  229.  
  230. -       // if the peer is downloading stuff, it must have metadata     
  231. +       // if the peer is downloading stuff, it must have metadata
  232.         m_has_metadata = true;
  233.  
  234.         // only update the piece_picker if
  235. @@ -1969,7 +1973,7 @@ namespace libtorrent
  236.         }
  237.  
  238.         TORRENT_ASSERT(t->valid_metadata());
  239. -      
  240. +
  241.         int num_pieces = bits.count();
  242.         if (num_pieces == int(m_have_piece.size()))
  243.         {
  244. @@ -2364,9 +2368,9 @@ namespace libtorrent
  245.     {
  246.         check_postcondition(boost::shared_ptr<torrent> const& t_
  247.             , bool init_check = true): t(t_) { if (init_check) check(); }
  248. -  
  249. +
  250.         ~check_postcondition() { check(); }
  251. -      
  252. +
  253.         void check()
  254.         {
  255.             if (!t->is_seed())
  256. @@ -2384,7 +2388,7 @@ namespace libtorrent
  257.                 }
  258.             }
  259.         }
  260. -      
  261. +
  262.         shared_ptr<torrent> t;
  263.     };
  264.  #endif
  265. @@ -2578,7 +2582,7 @@ namespace libtorrent
  266.         TORRENT_ASSERT(int(m_download_queue.size()) > block_index);
  267.         b = m_download_queue.begin() + block_index;
  268.         TORRENT_ASSERT(*b == pending_b);
  269. -      
  270. +
  271.  #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
  272.         TORRENT_ASSERT_VAL(m_received_in_piece == p.length, m_received_in_piece);
  273.         m_received_in_piece = 0;
  274. @@ -2607,7 +2611,7 @@ namespace libtorrent
  275.             send_block_requests();
  276.             return;
  277.         }
  278. -      
  279. +
  280.         if (total_seconds(now - m_requested)
  281.             < m_ses.settings().request_timeout
  282.             && m_snubbed)
  283. @@ -2754,7 +2758,7 @@ namespace libtorrent
  284.         picker.mark_as_finished(block_finished, peer_info_struct());
  285.         if (t->alerts().should_post<block_finished_alert>())
  286.         {
  287. -           t->alerts().post_alert(block_finished_alert(t->get_handle(),
  288. +           t->alerts().post_alert(block_finished_alert(t->get_handle(),
  289.                 remote(), pid(), block_finished.block_index, block_finished.piece_index));
  290.         }
  291.  
  292. @@ -2880,7 +2884,7 @@ namespace libtorrent
  293.         TORRENT_ASSERT(!m_have_piece.empty());
  294.         m_have_piece.set_all();
  295.         m_num_pieces = m_have_piece.size();
  296. -      
  297. +
  298.         t->peer_has_all();
  299.  
  300.         // if we're finished, we're not interested
  301. @@ -2889,7 +2893,7 @@ namespace libtorrent
  302.  
  303.         disconnect_if_redundant();
  304.     }
  305. -  
  306. +
  307.     // -----------------------------
  308.     // --------- HAVE NONE ---------
  309.     // -----------------------------
  310. @@ -2916,7 +2920,7 @@ namespace libtorrent
  311.         t->get_policy().set_seed(m_peer_info, false);
  312.         m_bitfield_received = true;
  313.  
  314. -       // if the peer is ready to download stuff, it must have metadata       
  315. +       // if the peer is ready to download stuff, it must have metadata
  316.         m_has_metadata = true;
  317.  
  318.         // we're never interested in a peer that doesn't have anything
  319. @@ -3004,7 +3008,7 @@ namespace libtorrent
  320.         if (has_peer_choked() || !is_interesting()) return false;
  321.         if ((int)m_download_queue.size() + (int)m_request_queue.size()
  322.             > m_desired_queue_size * 2) return false;
  323. -       if (on_parole()) return false;
  324. +       if (on_parole()) return false;
  325.         if (m_disconnecting) return false;
  326.         boost::shared_ptr<torrent> t = m_torrent.lock();
  327.         TORRENT_ASSERT(t);
  328. @@ -3100,7 +3104,7 @@ namespace libtorrent
  329.  
  330.         if (t->alerts().should_post<block_downloading_alert>())
  331.         {
  332. -           t->alerts().post_alert(block_downloading_alert(t->get_handle(),
  333. +           t->alerts().post_alert(block_downloading_alert(t->get_handle(),
  334.                 remote(), pid(), speedmsg, block.block_index, block.piece_index));
  335.         }
  336.  
  337. @@ -3363,7 +3367,7 @@ namespace libtorrent
  338.         if (has_piece(piece)
  339.             || !m_peer_interested)
  340.             return;
  341. -  
  342. +
  343.  #ifdef TORRENT_VERBOSE_LOGGING
  344.         peer_log("==> SUGGEST [ %d ]", piece);
  345.  #endif
  346. @@ -3373,7 +3377,7 @@ namespace libtorrent
  347.     void peer_connection::send_block_requests()
  348.     {
  349.         INVARIANT_CHECK;
  350. -      
  351. +
  352.         boost::shared_ptr<torrent> t = m_torrent.lock();
  353.         TORRENT_ASSERT(t);
  354.  
  355. @@ -3448,7 +3452,7 @@ namespace libtorrent
  356.                 "piece: " << block.piece_index << " | "
  357.                 "block: " << block.block_index << " ]\n";
  358.  #endif
  359. -*/        
  360. +*/
  361.             // if we are requesting large blocks, merge the smaller
  362.             // blocks that are in the same piece into larger requests
  363.             if (m_request_large_blocks)
  364. @@ -3490,7 +3494,7 @@ namespace libtorrent
  365.  
  366.             // the verification will fail for coalesced blocks
  367.             TORRENT_ASSERT(verify_piece(r) || m_request_large_blocks);
  368. -          
  369. +
  370.  #ifndef TORRENT_DISABLE_EXTENSIONS
  371.             bool handled = false;
  372.             for (extension_list_t::iterator i = m_extensions.begin()
  373. @@ -3530,7 +3534,7 @@ namespace libtorrent
  374.  
  375.         connect_failed(errors::timed_out);
  376.     }
  377. -  
  378. +
  379.     void peer_connection::connect_failed(error_code const& e)
  380.     {
  381.         TORRENT_ASSERT(e);
  382. @@ -3657,7 +3661,7 @@ namespace libtorrent
  383.         if (ec == error_code(errors::timed_out)
  384.             || ec == error::timed_out)
  385.             ++m_ses.m_transport_timeout_peers;
  386. -      
  387. +
  388.         if (ec == error_code(errors::timed_out_inactivity)
  389.             || ec == error_code(errors::timed_out_no_request)
  390.             || ec == error_code(errors::timed_out_no_interest))
  391. @@ -3914,8 +3918,8 @@ namespace libtorrent
  392.  
  393.         p.download_queue_time = download_queue_time();
  394.         p.queue_bytes = m_outstanding_bytes;
  395. -      
  396. -#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES 
  397. +
  398. +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
  399.         p.country[0] = m_country[0];
  400.         p.country[1] = m_country[1];
  401.  #endif
  402. @@ -4006,7 +4010,7 @@ namespace libtorrent
  403.         p.used_receive_buffer = m_recv_pos;
  404.         p.write_state = m_channel_state[upload_channel];
  405.         p.read_state = m_channel_state[download_channel];
  406. -      
  407. +
  408.         // pieces may be empty if we don't have metadata yet
  409.         if (p.pieces.size() == 0)
  410.         {
  411. @@ -4038,7 +4042,7 @@ namespace libtorrent
  412.     bool peer_connection::allocate_disk_receive_buffer(int disk_buffer_size)
  413.     {
  414.         INVARIANT_CHECK;
  415. -      
  416. +
  417.         TORRENT_ASSERT(m_packet_size > 0);
  418.         TORRENT_ASSERT(m_recv_pos <= m_packet_size - disk_buffer_size);
  419.         TORRENT_ASSERT(!m_disk_recv_buffer);
  420. @@ -4071,7 +4075,7 @@ namespace libtorrent
  421.         m_disk_recv_buffer_size = 0;
  422.         return m_disk_recv_buffer.release();
  423.     }
  424. -  
  425. +
  426.     // size = the packet size to remove from the receive buffer
  427.     // packet_size = the next packet size to receive in the buffer
  428.     void peer_connection::cut_receive_buffer(int size, int packet_size, int offset)
  429. @@ -4085,7 +4089,7 @@ namespace libtorrent
  430.         TORRENT_ASSERT(offset >= 0);
  431.         TORRENT_ASSERT(size >= 0);
  432.  
  433. -       if (size > 0)      
  434. +       if (size > 0)
  435.         {
  436.             if (m_recv_pos - size - offset > 0)
  437.                 std::memmove(&m_recv_buffer[0] + offset, &m_recv_buffer[0]
  438. @@ -4111,7 +4115,7 @@ namespace libtorrent
  439.         {
  440.             if (m_superseed_piece == -1) return;
  441.             m_superseed_piece = -1;
  442. -          
  443. +
  444.  #ifdef TORRENT_VERBOSE_LOGGING
  445.             peer_log("*** ending super seed mode");
  446.  #endif
  447. @@ -4126,12 +4130,12 @@ namespace libtorrent
  448.  #endif
  449.                 write_have(i);
  450.             }
  451. -          
  452. +
  453.             return;
  454.         }
  455.  
  456.         assert(!has_piece(index));
  457. -      
  458. +
  459.  #ifdef TORRENT_VERBOSE_LOGGING
  460.         peer_log("==> HAVE    [ piece: %d ] (super seed)", index);
  461.  #endif
  462. @@ -4146,7 +4150,7 @@ namespace libtorrent
  463.             m_desired_queue_size = 1;
  464.             return;
  465.         }
  466. -  
  467. +
  468.         int download_rate = statistics().download_rate();
  469.  
  470.         // calculate the desired download queue size
  471. @@ -4161,7 +4165,7 @@ namespace libtorrent
  472.         const int block_size = t->block_size();
  473.  
  474.         TORRENT_ASSERT(block_size > 0);
  475. -      
  476. +
  477.         m_desired_queue_size = queue_time * download_rate / block_size;
  478.  
  479.         if (m_desired_queue_size > m_max_out_request_queue)
  480. @@ -4201,7 +4205,7 @@ namespace libtorrent
  481.                 upc = &m_ses.m_upload_channel;
  482.                 downc = &m_ses.m_download_channel;
  483.             }
  484. -  
  485. +
  486.             int up_limit = m_bandwidth_channel[upload_channel].throttle();
  487.             int down_limit = m_bandwidth_channel[download_channel].throttle();
  488.  
  489. @@ -4400,7 +4404,7 @@ namespace libtorrent
  490.  
  491.         update_desired_queue_size();
  492.  
  493. -       if (m_desired_queue_size == m_max_out_request_queue
  494. +       if (m_desired_queue_size == m_max_out_request_queue
  495.                 && t->alerts().should_post<performance_alert>())
  496.         {
  497.             t->alerts().post_alert(performance_alert(t->get_handle()
  498. @@ -4488,11 +4492,11 @@ namespace libtorrent
  499.         if (now - m_remote_dl_update >= seconds(60))
  500.         {
  501.             if (m_remote_dl_rate > 0)
  502. -               m_remote_dl_rate = (m_remote_dl_rate * 2 / 3) +
  503. +               m_remote_dl_rate = (m_remote_dl_rate * 2 / 3) +
  504.                     ((m_remote_bytes_dled / 3) / 60);
  505.             else
  506.                 m_remote_dl_rate = m_remote_bytes_dled / 60;
  507. -          
  508. +
  509.             m_remote_bytes_dled = 0;
  510.             m_remote_dl_update = now;
  511.         }
  512. @@ -4636,7 +4640,7 @@ namespace libtorrent
  513.  
  514.         // only add new piece-chunks if the send buffer is small enough
  515.         // otherwise there will be no end to how large it will be!
  516. -      
  517. +
  518.         boost::uint64_t upload_rate = int(m_statistics.upload_rate());
  519.  
  520.         int buffer_size_watermark = upload_rate
  521. @@ -4656,7 +4660,7 @@ namespace libtorrent
  522.         {
  523.             TORRENT_ASSERT(t->ready_for_connections());
  524.             peer_request& r = m_requests.front();
  525. -          
  526. +
  527.             TORRENT_ASSERT(r.piece >= 0);
  528.             TORRENT_ASSERT(r.piece < (int)m_have_piece.size());
  529.             TORRENT_ASSERT(t->have_piece(r.piece));
  530. @@ -4714,7 +4718,7 @@ namespace libtorrent
  531.             disconnect(j.error);
  532.             return;
  533.         }
  534. -      
  535. +
  536.         if (ret != r.length)
  537.         {
  538.             if (ret == -3)
  539. @@ -4875,7 +4879,7 @@ namespace libtorrent
  540.         if (m_disconnecting) return;
  541.  
  542.         if (m_channel_state[upload_channel] & (peer_info::bw_network | peer_info::bw_limit)) return;
  543. -      
  544. +
  545.         shared_ptr<torrent> t = m_torrent.lock();
  546.  
  547.         if (m_quota[upload_channel] == 0
  548. @@ -4995,7 +4999,7 @@ namespace libtorrent
  549.  #ifdef TORRENT_VERBOSE_LOGGING
  550.             peer_log(">>> CORKED WRITE [ bytes: %d ]", amount_to_send);
  551.  #endif
  552. -           return;    
  553. +           return;
  554.         }
  555.  
  556.         TORRENT_ASSERT((m_channel_state[upload_channel] & peer_info::bw_network) == 0);
  557. @@ -5017,7 +5021,7 @@ namespace libtorrent
  558.     {
  559.         if ((m_channel_state[download_channel] & peer_info::bw_disk) == 0) return;
  560.         boost::intrusive_ptr<peer_connection> me(this);
  561. -  
  562. +
  563.         m_ses.dec_disk_queue(download_channel);
  564.         m_channel_state[download_channel] &= ~peer_info::bw_disk;
  565.         setup_receive(read_async);
  566. @@ -5031,7 +5035,7 @@ namespace libtorrent
  567.         if (m_channel_state[download_channel] & (peer_info::bw_network | peer_info::bw_limit)) return;
  568.  
  569.         shared_ptr<torrent> t = m_torrent.lock();
  570. -      
  571. +
  572.         if (m_quota[download_channel] == 0
  573.             && !m_connecting)
  574.         {
  575. @@ -5074,7 +5078,7 @@ namespace libtorrent
  576.             peer_log(">>> ASSIGN BANDWIDTH [ bytes: %d ]", ret);
  577.  #endif
  578.         }
  579. -      
  580. +
  581.         if (!can_read(&m_channel_state[download_channel]))
  582.         {
  583.  #ifdef TORRENT_VERBOSE_LOGGING
  584. @@ -5397,7 +5401,7 @@ namespace libtorrent
  585.                 m_statistics.trancieve_ip_packet(bytes_in_loop, m_remote.address().is_v6());
  586.                 return;
  587.             }
  588. -  
  589. +
  590.             TORRENT_ASSERT(m_packet_size > 0);
  591.             TORRENT_ASSERT(bytes_transferred > 0);
  592.  
  593. @@ -5523,7 +5527,7 @@ namespace libtorrent
  594.         if (ticket == -1)
  595.         {
  596.             disconnect(asio::error::operation_aborted);
  597. -           return;    
  598. +           return;
  599.         }
  600.  
  601.         m_connection_ticket = ticket;
  602. @@ -5551,7 +5555,7 @@ namespace libtorrent
  603.         }
  604.  
  605.         tcp::endpoint bind_interface = t->get_interface();
  606. -  
  607. +
  608.         std::pair<int, int> const& out_ports = m_ses.settings().outgoing_ports;
  609.         if (out_ports.first > 0 && out_ports.second >= out_ports.first)
  610.         {
  611. @@ -5611,7 +5615,7 @@ namespace libtorrent
  612.         peer_log("*** LOCAL ENDPOINT[ e: %s ]", print_endpoint(m_socket->local_endpoint(ec)).c_str());
  613.  #endif
  614.     }
  615. -  
  616. +
  617.     void peer_connection::on_connection_complete(error_code const& e)
  618.     {
  619.  #if defined TORRENT_ASIO_DEBUGGING
  620. @@ -5631,7 +5635,7 @@ namespace libtorrent
  621.         // assume 12 bits of entropy (i.e. about 8 milliseconds)
  622.         RAND_add(&now, 8, 1.5);
  623.  #endif
  624. -      
  625. +
  626.         if (m_disconnecting) return;
  627.  
  628.         error_code ec;
  629. @@ -5700,12 +5704,16 @@ namespace libtorrent
  630.             peer_log(">>> SET_TOS[ tos: %d e: %s ]", m_ses.settings().peer_tos, ec.message().c_str());
  631.  #endif
  632.         }
  633. +        else if (m_remote.address().is_v6())
  634. +        {
  635. +            m_socket->set_option(traffic_class(m_ses.settings().peer_tos), ec);
  636. +        }
  637.  
  638.         on_connected();
  639.         setup_send();
  640.         setup_receive();
  641.     }
  642. -  
  643. +
  644.     // --------------------------
  645.     // SEND DATA
  646.     // --------------------------
  647. @@ -5724,7 +5732,7 @@ namespace libtorrent
  648.  #endif
  649.         TORRENT_ASSERT(m_ses.is_network_thread());
  650.  
  651. -#if defined TORRENT_VERBOSE_LOGGING
  652. +#if defined TORRENT_VERBOSE_LOGGING
  653.         peer_log("*** ON_SEND_DATA [ bytes: %d error: %s ]"
  654.             , int(bytes_transferred), error.message().c_str());
  655.  #endif
  656. @@ -5749,7 +5757,7 @@ namespace libtorrent
  657.         while (!m_requests_in_buffer.empty()
  658.             && m_requests_in_buffer.front() <= 0)
  659.             m_requests_in_buffer.erase(m_requests_in_buffer.begin());
  660. -      
  661. +
  662.         m_channel_state[upload_channel] &= ~peer_info::bw_network;
  663.  
  664.         TORRENT_ASSERT(int(bytes_transferred) <= m_quota[upload_channel]);
  665. @@ -6102,7 +6110,7 @@ namespace libtorrent
  666.         time_duration d;
  667.         d = time_now() - m_last_sent;
  668.         if (total_seconds(d) < m_timeout / 2) return;
  669. -      
  670. +
  671.         if (m_connecting) return;
  672.         if (in_handshake()) return;
  673.  
  674. diff --git a/0.16.16/src/libtorrent-rasterbar-0.16.16/src/session_impl.cpp b/0.16.16/src/libtorrent-rasterbar-0.16.16/src/session_impl.cpp
  675. index 79cc500..6ec84ce 100644
  676. --- a/0.16.16/src/libtorrent-rasterbar-0.16.16/src/session_impl.cpp
  677. +++ b/0.16.16/src/libtorrent-rasterbar-0.16.16/src/session_impl.cpp
  678. @@ -481,7 +481,7 @@ namespace aux {
  679.  
  680.  #ifndef TORRENT_DISABLE_ENCRYPTION
  681.  #define TORRENT_SETTING(t, x) {#x, offsetof(pe_settings,x), t},
  682. -   bencode_map_entry pe_settings_map[] =
  683. +   bencode_map_entry pe_settings_map[] =
  684.     {
  685.         TORRENT_SETTING(integer, out_enc_policy)
  686.         TORRENT_SETTING(integer, in_enc_policy)
  687. @@ -554,7 +554,7 @@ namespace aux {
  688.     {
  689.         session_impl* ses = (session_impl*)arg;
  690.         const char* servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
  691. -  
  692. +
  693.         if (!servername || strlen(servername) < 40)
  694.             return SSL_TLSEXT_ERR_ALERT_FATAL;
  695.  
  696. @@ -793,7 +793,7 @@ namespace aux {
  697.         }
  698.         else if (windows_version >= 0x050102)
  699.         {
  700. -           // on XP SP2 the limit is 10   
  701. +           // on XP SP2 the limit is 10
  702.             m_half_open.limit(9);
  703.         }
  704.         else
  705. @@ -1141,7 +1141,7 @@ namespace aux {
  706.             return;
  707.         }
  708.         m_last_log_rotation = time_now();
  709. -          
  710. +
  711.         fputs("second:uploaded bytes:downloaded bytes:downloading torrents:seeding torrents"
  712.             ":peers:connecting peers:disk block buffers:num list peers"
  713.             ":peer allocations:peer storage bytes"
  714. @@ -1439,7 +1439,7 @@ namespace aux {
  715.         }
  716.  #endif
  717.     }
  718. -  
  719. +
  720.     void session_impl::set_proxy(proxy_settings const& s)
  721.     {
  722.         TORRENT_ASSERT(is_network_thread());
  723. @@ -1456,7 +1456,7 @@ namespace aux {
  724.         TORRENT_ASSERT(is_network_thread());
  725.  
  726.         lazy_entry const* settings;
  727. -    
  728. +
  729.         if (e->type() != lazy_entry::dict_t) return;
  730.  
  731.         for (int i = 0; i < int(sizeof(all_settings)/sizeof(all_settings[0])); ++i)
  732. @@ -1466,7 +1466,7 @@ namespace aux {
  733.             if (!settings) continue;
  734.             load_struct(*settings, reinterpret_cast<char*>(this) + c.offset, c.map, c.num_entries);
  735.         }
  736. -      
  737. +
  738.         update_rate_settings();
  739.         update_connections_limit();
  740.         update_unchoke_limit();
  741. @@ -1759,7 +1759,7 @@ namespace aux {
  742.             if (t.should_check_files()) t.queue_torrent_check();
  743.         }
  744.     }
  745. -  
  746. +
  747.     void session_impl::abort()
  748.     {
  749.         TORRENT_ASSERT(is_network_thread());
  750. @@ -2052,7 +2052,10 @@ namespace aux {
  751.         if (m_settings.peer_tos != s.peer_tos)
  752.         {
  753.             error_code ec;
  754. -           m_udp_socket.set_option(type_of_service(s.peer_tos), ec);
  755. +            if (m_udp_socket.local_endpoint(ec).address().is_v6())
  756. +                m_udp_socket.set_option(traffic_class(s.peer_tos), ec);
  757. +            else
  758. +               m_udp_socket.set_option(type_of_service(s.peer_tos), ec);
  759.  #if defined TORRENT_VERBOSE_LOGGING
  760.             (*m_logger) << ">>> SET_TOS[ udp_socket tos: " << s.peer_tos << " e: " << ec.message() << " ]\n";
  761.  #endif
  762. @@ -2071,7 +2074,7 @@ namespace aux {
  763.  
  764.         if (connections_limit_changed) update_connections_limit();
  765.         if (unchoke_limit_changed) update_unchoke_limit();
  766. -  
  767. +
  768.         // enable anonymous mode. We don't want to accept any incoming
  769.         // connections, except through a proxy.
  770.         if (anonymous)
  771. @@ -2092,7 +2095,7 @@ namespace aux {
  772.             m_listen_sockets.clear();
  773.         }
  774.         if (m_settings.connection_speed < 0) m_settings.connection_speed = 200;
  775. -
  776. +
  777.         if (update_disk_io_thread)
  778.             update_disk_thread_settings();
  779.  
  780. @@ -2239,7 +2242,7 @@ namespace aux {
  781.             << " external port: " << s->external_port << "\n";
  782.  #endif
  783.     }
  784. -  
  785. +
  786.     void session_impl::open_listen_port(int flags, error_code& ec)
  787.     {
  788.         TORRENT_ASSERT(is_network_thread());
  789. @@ -2265,12 +2268,12 @@ retry:
  790.         tcp::endpoint ssl_interface = m_listen_interface;
  791.         ssl_interface.port(m_settings.ssl_listen);
  792.  #endif
  793. -  
  794. +
  795.         if (is_any(m_listen_interface.address()))
  796.         {
  797.             // this means we should open two listen sockets
  798.             // one for IPv4 and one for IPv6
  799. -      
  800. +
  801.             listen_socket_t s;
  802.             setup_listener(&s, tcp::endpoint(address_v4::any(), m_listen_interface.port())
  803.                 , m_listen_port_retries, false, flags, ec);
  804. @@ -2408,7 +2411,11 @@ retry:
  805.             maybe_update_udp_mapping(1, m_listen_interface.port(), m_listen_interface.port());
  806.         }
  807.  
  808. -       m_udp_socket.set_option(type_of_service(m_settings.peer_tos), ec);
  809. +
  810. +        if (m_udp_socket.local_endpoint(ec).address().is_v6())
  811. +            m_udp_socket.set_option(traffic_class(m_settings.peer_tos), ec);
  812. +        else
  813. +           m_udp_socket.set_option(type_of_service(m_settings.peer_tos), ec);
  814.  #if defined TORRENT_VERBOSE_LOGGING
  815.         (*m_logger) << ">>> SET_TOS[ udp_socket tos: " << m_settings.peer_tos << " e: " << ec.message() << " ]\n";
  816.  #endif
  817. @@ -2463,7 +2470,7 @@ retry:
  818.             && m_proxy.type != proxy_settings::socks5_pw
  819.             && m_proxy.type != proxy_settings::socks4)
  820.             return;
  821. -      
  822. +
  823.         if (m_socks_listen_socket) return;
  824.  
  825.         m_socks_listen_socket = boost::shared_ptr<socket_type>(new socket_type(m_io_service));
  826. @@ -2610,7 +2617,7 @@ retry:
  827.             return;
  828.         }
  829.  #endif
  830. -      
  831. +
  832.         if (m_utp_socket_manager.incoming_packet(buf, len, ep))
  833.             return;
  834.  
  835. @@ -2673,7 +2680,7 @@ retry:
  836.         TORRENT_ASSERT(is_network_thread());
  837.         boost::shared_ptr<socket_acceptor> listener = listen_socket.lock();
  838.         if (!listener) return;
  839. -      
  840. +
  841.         if (e == asio::error::operation_aborted) return;
  842.  
  843.         if (m_abort) return;
  844. @@ -2756,9 +2763,9 @@ retry:
  845.  #ifdef TORRENT_USE_OPENSSL
  846.  
  847.     // to test SSL connections, one can use this openssl command template:
  848. -   //
  849. -   // openssl s_client -cert <client-cert>.pem -key <client-private-key>.pem \
  850. -   //   -CAfile <torrent-cert>.pem  -debug -connect 127.0.0.1:4433 -tls1 \
  851. +   //
  852. +   // openssl s_client -cert <client-cert>.pem -key <client-private-key>.pem \
  853. +   //   -CAfile <torrent-cert>.pem  -debug -connect 127.0.0.1:4433 -tls1 \
  854.     //   -servername <hex-encoded-info-hash>
  855.  
  856.     void session_impl::ssl_handshake(error_code const& ec, boost::shared_ptr<socket_type> s)
  857. @@ -3050,7 +3057,7 @@ retry:
  858.         std::pair<int, int> const& out_ports = m_settings.outgoing_ports;
  859.         if (m_next_port < out_ports.first || m_next_port > out_ports.second)
  860.             m_next_port = out_ports.first;
  861. -  
  862. +
  863.         int port = m_next_port;
  864.         ++m_next_port;
  865.         if (m_next_port > out_ports.second) m_next_port = out_ports.first;
  866. @@ -3357,7 +3364,7 @@ retry:
  867.  
  868.         // some people claim that there sometimes can be cases where
  869.         // there is no torrent being checked, but there are torrents
  870. -       // waiting to be checked. I have never seen this, and I can't
  871. +       // waiting to be checked. I have never seen this, and I can't
  872.         // see a way for it to happen. But, if it does, start one of
  873.         // the queued torrents
  874.         if (num_checking == 0 && num_queued > 0 && !m_paused)
  875. @@ -3419,7 +3426,7 @@ retry:
  876.  
  877.         m_peak_up_rate = (std::max)(m_stat.upload_rate(), m_peak_up_rate);
  878.         m_peak_down_rate = (std::max)(m_stat.download_rate(), m_peak_down_rate);
  879. -  
  880. +
  881.         m_stat.second_tick(tick_interval_ms);
  882.  
  883.         TORRENT_ASSERT(least_recently_scraped == m_torrents.end()
  884. @@ -3647,7 +3654,7 @@ retry:
  885.                 torrent_map::iterator i = std::max_element(m_torrents.begin(), m_torrents.end()
  886.                     , boost::bind(&torrent::num_peers, boost::bind(&torrent_map::value_type::second, _1))
  887.                     < boost::bind(&torrent::num_peers, boost::bind(&torrent_map::value_type::second, _2)));
  888. -          
  889. +
  890.                 TORRENT_ASSERT(i != m_torrents.end());
  891.                 int peers_to_disconnect = (std::min)((std::max)(
  892.                     int(i->second->num_peers() * m_settings.peer_turnover), 1)
  893. @@ -3680,7 +3687,7 @@ retry:
  894.     }
  895.  
  896.  #ifdef TORRENT_STATS
  897. -      
  898. +
  899.     void session_impl::enable_stats_logging(bool s)
  900.     {
  901.         if (m_stats_logging_enabled == s) return;
  902. @@ -3868,7 +3875,7 @@ retry:
  903.                 ++peers_up_requests;
  904.             if (p->endgame()) ++num_end_game_peers;
  905.             reading_bytes += p->num_reading_bytes();
  906. -      
  907. +
  908.             pending_incoming_reqs += int(p->upload_queue().size());
  909.  
  910.             int dl_bucket = 0;
  911. @@ -4277,7 +4284,7 @@ retry:
  912.             // if we count slow torrents, every torrent
  913.             // is considered active
  914.             if (!s.dont_count_slow_torrents) return true;
  915. -          
  916. +
  917.             // if the torrent started less than 2 minutes
  918.             // ago (default), let it count as active since
  919.             // the rates are probably not accurate yet
  920. @@ -4287,7 +4294,7 @@ retry:
  921.                 || t->statistics().download_payload_rate() != 0.f;
  922.         }
  923.     }
  924. -  
  925. +
  926.     void session_impl::auto_manage_torrents(std::vector<torrent*>& list
  927.         , int& dht_limit, int& tracker_limit, int& lsd_limit
  928.         , int& hard_limit, int type_limit)
  929. @@ -4364,7 +4371,7 @@ retry:
  930.             lsd_limit = (std::numeric_limits<int>::max)();
  931.         if (tracker_limit == -1)
  932.             tracker_limit = (std::numeric_limits<int>::max)();
  933. -            
  934. +
  935.         for (torrent_map::iterator i = m_torrents.begin()
  936.             , end(m_torrents.end()); i != end; ++i)
  937.         {
  938. @@ -4435,14 +4442,14 @@ retry:
  939.             auto_manage_torrents(seeds, dht_limit, tracker_limit, lsd_limit
  940.                 , hard_limit, num_seeds);
  941.         }
  942. -            
  943. +
  944.     }
  945.  
  946.     void session_impl::recalculate_optimistic_unchoke_slots()
  947.     {
  948.         TORRENT_ASSERT(is_network_thread());
  949.         if (m_allowed_upload_slots == 0) return;
  950. -  
  951. +
  952.         std::vector<policy::peer*> opt_unchoke;
  953.  
  954.         for (connection_map::iterator i = m_connections.begin()
  955. @@ -4524,7 +4531,7 @@ retry:
  956.                     pi->optimistically_unchoked = false;
  957.                     t->choke_peer(*pi->connection);
  958.                     --m_num_unchoked;
  959. -               }  
  960. +               }
  961.             }
  962.         }
  963.     }
  964. @@ -4662,7 +4669,7 @@ retry:
  965.         if (m_settings.choking_algorithm == session_settings::auto_expand_choker
  966.             && upload_limit > 0)
  967.         {
  968. -           // if our current upload rate is less than 90% of our
  969. +           // if our current upload rate is less than 90% of our
  970.             // limit AND most torrents are not "congested", i.e.
  971.             // they are not holding back because of a per-torrent
  972.             // limit
  973. @@ -4889,7 +4896,7 @@ retry:
  974.             t->status(&*i, flags);
  975.         }
  976.     }
  977. -  
  978. +
  979.     void session_impl::post_torrent_updates()
  980.     {
  981.         INVARIANT_CHECK;
  982. @@ -4968,7 +4975,7 @@ retry:
  983.             return torrent_handle();
  984.         }
  985.  
  986. -#ifndef TORRENT_DISABLE_DHT   
  987. +#ifndef TORRENT_DISABLE_DHT
  988.         // add p.dht_nodes to the DHT, if enabled
  989.         if (m_dht && !p.dht_nodes.empty())
  990.         {
  991. @@ -4985,7 +4992,7 @@ retry:
  992.             ec = errors::session_is_closing;
  993.             return torrent_handle();
  994.         }
  995. -      
  996. +
  997.         // figure out the info hash of the torrent
  998.         sha1_hash const* ih = 0;
  999.         sha1_hash tmp;
  1000. @@ -5828,10 +5835,10 @@ retry:
  1001.  
  1002.             int last_average = 0;
  1003.             int average = m_settings.connections_limit / m_torrents.size();
  1004. -  
  1005. +
  1006.             // the number of slots that are unused by torrents
  1007.             int extra = m_settings.connections_limit % m_torrents.size();
  1008. -  
  1009. +
  1010.             // run 3 iterations of this, then we're probably close enough
  1011.             for (int iter = 0; iter < 4; ++iter)
  1012.             {
  1013. @@ -5886,7 +5893,7 @@ retry:
  1014.     {
  1015.         return m_alerts.get();
  1016.     }
  1017. -  
  1018. +
  1019.     void session_impl::pop_alerts(std::deque<alert*>* alerts)
  1020.     {
  1021.         m_alerts.get_all(alerts);
  1022. @@ -5920,7 +5927,7 @@ retry:
  1023.             , m_listen_interface.address()
  1024.             , boost::bind(&session_impl::on_lsd_peer, this, _1, _2));
  1025.     }
  1026. -  
  1027. +
  1028.     natpmp* session_impl::start_natpmp()
  1029.     {
  1030.         INVARIANT_CHECK;
  1031. @@ -5991,14 +5998,14 @@ retry:
  1032.             m_lsd->close();
  1033.         m_lsd = 0;
  1034.     }
  1035. -  
  1036. +
  1037.     void session_impl::stop_natpmp()
  1038.     {
  1039.         if (m_natpmp.get())
  1040.             m_natpmp->close();
  1041.         m_natpmp = 0;
  1042.     }
  1043. -  
  1044. +
  1045.     void session_impl::stop_upnp()
  1046.     {
  1047.         if (m_upnp.get())
  1048. @@ -6012,7 +6019,7 @@ retry:
  1049.         }
  1050.         m_upnp = 0;
  1051.     }
  1052. -  
  1053. +
  1054.     bool session_impl::external_ip_t::add_vote(sha1_hash const& k, int type)
  1055.     {
  1056.         sources |= type;
  1057. @@ -6046,7 +6053,7 @@ retry:
  1058.         {
  1059.             // each IP only gets to add a new IP once
  1060.             if (m_external_address_voters.find(k)) return;
  1061. -      
  1062. +
  1063.             if (m_external_addresses.size() > 20)
  1064.             {
  1065.                 if (random() < UINT_MAX / 2)
  1066. @@ -6080,7 +6087,7 @@ retry:
  1067.         }
  1068.         // add one more vote to this external IP
  1069.         if (!i->add_vote(k, source_type)) return;
  1070. -      
  1071. +
  1072.         i = std::max_element(m_external_addresses.begin(), m_external_addresses.end());
  1073.         TORRENT_ASSERT(i != m_external_addresses.end());
  1074.  
  1075. @@ -6131,7 +6138,7 @@ retry:
  1076.     {
  1077.         return m_disk_thread.allocate_buffer(category);
  1078.     }
  1079. -  
  1080. +
  1081.     char* session_impl::allocate_buffer()
  1082.     {
  1083.         TORRENT_ASSERT(is_network_thread());
  1084. @@ -6186,7 +6193,7 @@ retry:
  1085.  #else
  1086.         m_send_buffers.free(buf);
  1087.  #endif
  1088. -   }  
  1089. +   }
  1090.  
  1091.  #ifdef TORRENT_DEBUG
  1092.     void session_impl::check_invariant() const
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement