* build: clang-tidy headers when building libtransmission
* chore: revert `= default` workaround
It was introduced in 6909ec0bad to fix build issues with macOS 10.14. We
no longer support that version.
* fix: clang-tidy warnings for libtransmission
* build: clang-tidy headers when building tests
* fix: clang-tidy warnings for tests
* build: clang-tidy headers when building qt
* code review: don't manually edit mime-types.h
* code review: unify variable naming for static private members
* refactor: save length of PadA and PadB sent
* refactor: log outgoing `len(PadA)` and `len(PadB)`
* refactor: set `ia_len_` as the MSE handshake initiator
* fix: abort handshake if torrent isn't running
* fix: check if torrent is running in all cases
* fix: don't penalise peer if handshake failed because of us
* fix: tests
* perf: ensure copy-elision in `HandshakeMediator::torrent()`
* code review: more accurate log wording
* properly consume PadA in MSE handshake, check for invalid Ya+PadA
* refactor: make handshake constants public (needed for test coverage)
* test: split test MSE handshakes by blocking steps
* test: use `ASSERT_TRUE` instead of `assert`
* test: fix windows crash by using `recv` and `send`
Co-authored-by: Yat Ho <46261767+tearfur@users.noreply.github.com>
* refactor: use `TR_IF_WIN32` for `LOCAL_SOCKETPAIR_AF`
Co-authored-by: Yat Ho <46261767+tearfur@users.noreply.github.com>
---------
Co-authored-by: Yat Ho <lagoho7@gmail.com>
Co-authored-by: reardonia <reardonia@github.com>
Co-authored-by: Yat Ho <46261767+tearfur@users.noreply.github.com>
* fix: warning: deleted member function should be public [modernize-use-equals-delete]
* fix: warning: variable has inline specifier but is implicitly inlined [readability-redundant-inline-specifier]
* fix: warning: enum uses a larger base type than necessary for its value set [performance-enum-size]
* fix: warning: initializer for member is redundant [readability-redundant-member-init]
* warning: parameter is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
* refactor: don't loop in `tr_handshake::can_read()`
* fix: return `READ_NOW` after handshake success
* code review: more accurate comment wording
* Revert "refactor: don't loop in `tr_handshake::can_read()`"
This reverts commit 4f33520cba6a38171ed203a071158aa37ddcd325.
* refactor: convert `ReadState` to enum class
* refactor: use new `ReadState` value to break out of loop
* refactor: add a Mediator class to decouple tr_session and tr_port_forwarding
* refactor: add tr_port_forwarding::Mediator::privatePeerPort()
* refactor: add tr_port_forwarding::Mediator::onPortForwarded()
* chore: avoid unnecessary include of timer.h in other headers
* refactor: use a uniform timerMaker() API in mediators
Add a shim between the handshake code and the rest of the codebase to
improve decoupling so that a followup PR can add handshake unit tests.
The handshake code no longer directly relies on tr_torrent, tr_session,
tr_dht, or tr_peerMgr.
* refactor: move handshake_done args into a convenience struct
* refactor: move peer_id from peerIo to tr_handshake
tr_handshake is a short-term object and tr_peerIo is long-term, so this
effectively narrows the scope of this field.
* chore: remove unused field tr_peerIo.isEncrypted
* refactor: add tr_peer_id_t type to hold peer ids.
this is a 'using' alias to a std::array<> so that code passing peer-ids
around doesn't have to memcmp / memcpy PEER_ID_LEN anymore. Also removes
the now-unused PEER_ID_LEN macro.
* refactor: make tr_peerIo a class
No behavioral changes.
Use `new` and `delete` and change `struct` references to `class`.
* refactor: make some tr_peerIo fields const
* refactor: reorganize tr_peerIo fields to remove padding holes
* refactor: remove redundant field tr_peerIo.isIncoming
* refactor: make tr_peerIo.inbuf, .outbuf fields const*
This way all the qualifiers (`const`, `volatile`, `mutable`) are grouped
together, e.g. `T const* const x` vs. `const T* const x`. Also helps reading
types right-to-left, e.g. "constant pointer to constant T" vs. "constant
pointer to T which is constant".
There're places where manual intervention is still required as uncrustify
is not ideal (unfortunately), but at least one may rely on it to do the
right thing most of the time (e.g. when sending in a patch).
The style itself is quite different from what we had before but making it
uniform across all the codebase is the key. I also hope that it'll make the
code more readable (YMMV) and less sensitive to further changes.