Skip to content

Commit

Permalink
Move UDP tracker support into separate class
Browse files Browse the repository at this point in the history
  • Loading branch information
Zitrax committed Oct 1, 2023
1 parent 0fcc663 commit ebc11c3
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 181 deletions.
3 changes: 3 additions & 0 deletions src/net.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class Url {
m_path(std::move(path)),
m_port(port) {}

/** Provide default ordering */
auto operator<=>(const Url&) const = default;

/**
* Add http query params to existing Url object.
*/
Expand Down
5 changes: 3 additions & 2 deletions src/peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ void Peer::report_bitfield() const {
if (bf.next(true)) {
// Send BITFIELD
bytes msg;
auto len = to_big_endian<uint32_t>(numeric_cast<uint32_t>(1 + bf.size_bytes()));
auto len =
to_big_endian<uint32_t>(numeric_cast<uint32_t>(1 + bf.size_bytes()));
msg.insert(msg.cend(), len.begin(), len.end());
msg.push_back(static_cast<byte>(peer_wire_id::BITFIELD));
msg.insert(msg.cend(), bf.data().begin(), bf.data().end());
Expand Down Expand Up @@ -524,7 +525,7 @@ void Peer::init_io_service() {
m_work = make_unique<asio::io_service::work>(*m_io_service);
try {
m_connection = make_unique<PeerConnection>(*this, *m_io_service,
m_torrent.listning_port(),
m_torrent.listening_port(),
m_torrent.connection_port());
} catch (const asio::system_error& err) {
throw_with_nested(
Expand Down
Loading

0 comments on commit ebc11c3

Please sign in to comment.