Commit Graph

121 Commits

Author SHA1 Message Date
Yat Ho
9dd9aab902 build: bump clang tools to 20 (#7573)
* build: bump to clang-format-20

* build: bump to clang-tidy-20

* chore: revert edc59ba5d8
2025-12-01 23:18:02 -06:00
Yat Ho
25d2ebf8fc refactor: overhaul tr_address special address checks (#7818)
* refactor: rewrite is_martian_addr() with tr_address methods

- Fix broken check for IPv4 multicast address in is_martian_address()

* refactor: rewrite is_global_unicast_address()

- Rewrite using new tr_address methods
- Add missing IPv4 loopback check
- Follow RFC 4291 IPv6 global unicast definition
- Fix and update existing tests

* chore: reorganise methods and add comments

* fix: check for teredo and 6to4

* test: tests for new methods
2025-11-21 18:09:38 -06:00
Dzmitry Neviadomski
40e1bd660d Fix unreachable in tr_make_listen_socket_ipv6only (#7825) 2025-11-19 23:55:09 -06:00
Yat Ho
ace36c922d refactor: replace all evutil_make_listen_socket_ipv6only usages (#7779) 2025-11-08 16:36:54 -06:00
Yat Ho
b3424ed260 feat: match IPv4-mapped addresses with IPv4 whitelist (#7523)
* feat: match IPv4-mapped addresses with IPv4 whitelist

* test: for converting IPv4-mapped to native IPv4

* perf: avoid copying in `tr_wildmat()`
2025-11-07 20:26:45 -06:00
Yat Ho
4bd9aa9b06 refactor: prioritise peers slots for downloading torrents (#7306)
* chore: housekeeping

* refactor: allow downloading torrents to steal connection slots

To be exact, the way it works is that downloading torrents will be allowed to start outgoing connections despite the session peer limit is reached. The periodic peer limit enforcements should keep the downloading connections and remove the idle connections in seeding torrents.

* refactor: prefer peers from downloading torrents when enforcing peer limit
2025-10-27 10:43:14 -05:00
Yat Ho
85301b16d5 fix: FTBFS for libevent <= 2.1.8 (#7640) 2025-10-14 11:28:35 -05:00
Yat Ho
08ec7fb7c7 build: lint header files with clang-tidy (#7527)
* 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
2025-05-07 22:10:16 +01:00
Yat Ho
c215de34d5 chore: move away from fmt/core.h (#7557) 2025-05-06 01:01:12 -05:00
Dzmitry Neviadomski
7e87adcd91 Fix building transmission with C++23 (#6832)
* fix: operator== should return bool in tr_strbuf

Fixes build error with C++20/C++23

error: return type 'auto' of selected 'operator==' function for rewritten '!=' comparison is not 'bool'

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* fix: explicitly specify Blocklist::size() return type as size_t

Fixes building with C++20/C++23
error: no matching function for call to 'size'
function 'size' with deduced return type cannot be used before it is defined

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* fix: wrap runtime format strings with fmt::runtime in library, daemon and cli

fmt::format_string ctor is consteval with C++20
See https://github.com/fmtlib/fmt/issues/2438

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* fix: wrap runtime format strings with fmt::runtime for GTK client

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* fix: allow to override C and CXX standard via cmdline or env

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* fix: add job to check if transmission compiles with C++23

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* Address code review by mikedld

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* fix new found fmt build errors

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* Address code review by tearfur

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* fix: make tr_net_init_mgr singleton buildable with C++23

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>

---------

Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-10 13:08:57 -05:00
Yat Ho
76ab7ba592 refactor: set peer io socket in constructor (#7355)
* refactor: `tr_netOpenPeerSocket()` returns `tr_socket_t`

* refactor: store preferred transport as array

* refactor: set peer io socket in constructor

* refactor: remove `log_peer_io_bandwidth()`

This partially reverts commit efec6505

* refactor: rename `tr_netOpenPeerSocket` to snake_case

* code review: remove redundant comment

* code review: add comment about array order
2025-03-03 23:47:37 -06:00
Yat Ho
efec65050e fix: don't call tr_logAddTraceIo before tr_peerIo::set_socket() (#6881)
* fix: add fallback for invalid address display name

* fix: only call tr_logAddTraceIo after `tr_peerIo::set_socket()` is called

* chore: housekeeping

* code review: handle `nullptr` from `inet_ntop()` instead

* code review: remove unclear comment

* code review: dedupe peerIo bandwidth log
2024-06-01 16:23:46 +01:00
Yat Ho
4657d210ba feat: dual stack udp tracker support (#6687)
* chore: housekeeping

* refactor: reduce copying when building payloads

* feat: dual-stack udp tracker support

* refactor: convert function names to snake_case

* fix: `readability-identifier-naming` warning

* fix: account for dual-stack in tests

* code review: add prefix to global names

* fix: don't resolve to IPv4-mapped address

* refactor: use `tr_address` method to check ip protocol

* fix: workaround MSVC x86 build failure

* fix: handle host components that has square brackets

* Partial Revert: "fix: account for dual-stack in tests"

Not needed anymore

* fix: store ipv6 peers in pex6

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-05-26 15:43:55 -05:00
Yat Ho
d6f5e60a35 feat: ipv6 lpd (#6700)
* feat: ipv6 lpd

* feat: find interface index from ip address

* refactor: use `tr_socket_address::from_string()`

* fix: enable multicast loop

* chore: housekeeping

* refactor: dedupe `if_nametoindex()` call

* refactor: rename `mcast_socket_` to `mcast_sockets_`

* code review: fix variable name typo

* code review: unify comment styles

* fixup! code review: unify comment styles

* code review: explain 15KB in Win32 interface index code
2024-05-26 00:04:50 -05:00
Yat Ho
2ff3ae07d1 fix: more misc net.cc fixes (#6735)
* feat: accept ipv6 string in square brackets for `tr_address::from_string()`

* test: add test case for ipv6 string in square brackets

* fix: include square brackets in host component

According to RFC3986:
  host       = IP-literal / IPv4address / reg-name
  IP-literal = "[" ( IPv6address / IPvFuture  ) "]"

* fix: set ipv6-only socket before binding UDP socket

Will return EINVAL on Linux otherwise

* refactor: simplify code using `evutil` when binding TCP socket

* fix: do not set SO_REUSEADDR for listening sockets on Windows systems

Reason: https://stackoverflow.com/a/14388707/11390656

* fix: do not enclose ipv4 address string in square brackets
2024-03-25 21:10:06 -05:00
Yat Ho
20aef2f79d fix: misc net.cc and blocklist.cc fixes (#6717)
* fix: `tr_address` should be invalid by default

* fix: allow loopback address for LPD and incoming connections

* fix: `parseCidrline()` should set address type

* code review: keep `memcmp`
2024-03-24 17:09:51 -05:00
Yat Ho
152f3e91a5 refactor: convert tr_peerMsgsImpl helper functions to class methods (#6580)
* refactor: update bep links

* chore: use more appropriate data types

* chore: checkpoint

* refactor: split `can_request()` into each of their own different signature

* chore: checkpoint

* refactor: convert tr_peerMsgsImpl functions to methods

* chore: checkpoint

* refactor: store peer info as reference

* refactor: convert all member variables to private

* chore: re-arrange methods

* refactor: optimise tmp vector default size in `send_ut_pex()`

* chore: housekeeping

* chore: housekeeping

* refactor: avoid `dynamic_cast` when sending cancel

* fix: restore `blocks_sent_to_peer` stat

regression e91af26923

* fix: choke first then reject

* refactor: convert `tr_peerMsgsNew()` to static factory function

* refactor: store `tr_torrent` reference instead of pointer

* Revert "refactor: store peer info as reference"

This reverts commit bb419bf2

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-03-15 19:52:09 -05:00
Cœur
564d813b41 fix crash on empty filedescriptor after accept (#6585) 2024-02-11 20:40:41 -06:00
Charles Kerr
646883174b chore: fix misc-use-anonymous-namespace warnings from clang-tidy (#6488) 2024-01-04 23:12:51 -06:00
Charles Kerr
64d9d57363 chore: fix minor clang-tidy warnings (#6275) 2023-11-21 09:02:03 -06:00
Yat Ho
a2b547fb50 chore: iwyu (#6201) 2023-11-03 12:03:26 -05:00
Julien
8ac323d5d6 chore: removed copyright timespans in headers (#4850) 2023-11-01 16:11:11 -05:00
Cœur
1722f00777 chore: apply clang-format version 17.0.1 (#6054) 2023-10-01 18:45:52 -05:00
Yat Ho
eea7d4d886 refactor: re-organise net.h member functions (#5878) 2023-08-17 22:13:01 -05:00
tearfur
f758cb3597 refactor: avoid code duplication (#5793) 2023-07-17 08:56:57 -05:00
Charles Kerr
a9a6e54858 refactor: make tr_socket_address a class (#5772) 2023-07-12 17:29:47 -05:00
Charles Kerr
fdf042d32c refactor: add tr_compare_3way() (#5742)
* refactor: add tr_compare_3way()

This is a small templated utility function to make libtransmission's
sorting / comparison code more consistent and easier to read.
2023-07-06 18:51:08 -05:00
Charles Kerr
c364abcb6f chore: misc-include-cleaner (partial) (#5738) 2023-07-06 10:00:07 -05:00
Charles Kerr
f83a60830a refactor: add tr_socket_address typedef (#5730) 2023-07-05 11:33:50 -05:00
tearfur
8543555584 refactor: use std::pair to store socket addresses (#5723) 2023-07-04 20:29:12 -05:00
tearfur
9c17463a80 fix: revert "perf: improve IPv4 tr_address comparison" (#5709)
* Revert "perf: improve IPv4 `tr_address` comparison (#5651)"

This reverts commit 70decc1d9d.

* added tests

* add ipv4 equal test and std header
2023-07-01 09:39:35 -05:00
Charles Kerr
8183d7fddf refactor: utils naming (#5696)
* chore: rename tr_strvContains to tr_strv_contains

* chore: rename tr_strvStartsWith to tr_strv_starts_with

* chore: rename tr_strvEndsWith to tr_strv_ends_with

* chore: rename tr_strvSep to tr_strv_sep

* chore: rename tr_strvStrip to tr_strv_strip

* chore: rename tr_strvToBuf to tr_strv_to_buf

* refactor: rename tr_saveFile() to tr_file_save()

rename tr_loadFile() to tr_file_read()

rename tr_moveFile() to tr_file_move()

* refactor: rename tr_parseNum() to tr_num_parse()

refactor: rename tr_parseNumRange() to tr_num_parse_range()

* chore: group related functions together in header
2023-06-30 09:49:58 -05:00
Charles Kerr
ce66e5c442 iwyu: remove, add std headers where used (#5694)
* chore: remove unused #include <array>

* chore: remove unused #include <chrono>

* chore: remove unused #include <set>

* chore: remove unused #include <algorithm>

* chore: remove unused #include "interned-string.h"

* chore: remove unused #include <list>

* chore: remove unused #include <optional>

* chore: iwyu <cstddef>

* chore: iwyu <ctime>

* chore: remove unused #include <cerrno>

* chore: remove unused #include <deque>

* chore: remove unused #include <vector>

* chore: remove unused #include <memory>

* chore: remove unused #include <unordered_set>

* chore: remove unused #include <array>

* chore: remove unused #include <mutex>

* chore: remove unused #include <functional>

* chore: remove unused #include <cmath>
2023-06-29 23:51:55 -05:00
tearfur
70decc1d9d perf: improve IPv4 tr_address comparison (#5651) 2023-06-26 21:17:32 -05:00
tearfur
280dea4e33 add support for sending the ipv4 parameter during ltep handshake (#5643) 2023-06-20 10:51:07 -05:00
tearfur
d65f9329cd refactor: followup/cleanup of tr_global_ip_cache PR (#5498)
* remove tr_session::bindAddress()

* replace tr_net_hasIPv6 with tr_session::has_ip_protocol()

* update comment
2023-05-05 22:05:28 -05:00
tearfur
474a30ab2d feat: add global IP cache, fix UDP connection failure warnings 2023-05-05 12:17:40 -05:00
Gary Elshaw
2f1d5a225c fix: comment typos in libtransmission (#5473) 2023-04-30 13:29:29 -05:00
Charles Kerr
3af9645615 refactor: add tr_address::is_any() (#5398)
As suggested by @tearfur

Xref: https://github.com/transmission/transmission/pull/5329#discussion_r1166236165
2023-04-15 19:30:20 -05:00
Charles Kerr
d72cb67cfb chore: include directory name in libtransmission #includes (#5308) 2023-04-14 14:33:23 -05:00
tearfur
e68c72daa4 fix: tr_net_hasIPv6() (#5312) 2023-03-28 13:41:07 -05:00
tearfur
85a00625dc fix: intermediate fix for HTTP announce behaviour affected by bind-address-ipv* (#5296) 2023-03-28 12:59:42 -05:00
Julien
4b8cfa2e57 chore: update copyrights to 2023 (#4834) 2023-02-11 14:49:42 -06:00
Charles Kerr
0e5f7f86d7 fix: coverity warnings (#4687)
* fix: minor tr_error leak warning in tests

* fix: socket leak in tr_globalIPv6()
2023-01-29 16:49:59 -06:00
Charles Kerr
93db8f088a fix: cppcoreguidelines-pro-type-cstyle-cast (#4685)
* fix: libtransmission cppcoreguidelines-pro-type-cstyle-cast

* fix: libtransmission cppcoreguidelines-avoid-do-while

* refactor: inline static class fields

* fix: libtransmission cppcoreguidelines-avoid-reference-coroutine-parameters

* fix: announcer.cc cppcoreguidelines-narrowing-conversions
2023-01-28 15:26:23 -06:00
Charles Kerr
c75f9a4a7a refactor: tidy libtransmission symbol visibility (#4680) 2023-01-27 14:25:08 -06:00
Charles Kerr
568b23374c chore: don't warn on ECONNREFUSED to peer sockets. (#4678)
Fixes #1031.
2023-01-27 00:00:00 -06:00
Charles Kerr
977a190646 fix: msvc warnings (#4651)
* fix: C4189 local variable is initialized but not referenced

* fix: C4706 assignment within conditional expression

* fix: C4018 signed/unsigned mismatch

* fix: warning C4996 High-DPI scaling is always enabled.

* fix: C4996: QApplication::fontMetrics() is deprecated

eed5514eaf
2023-01-23 19:24:52 -06:00
Charles Kerr
7367d465b5 style: use the new paragraph comment style everywhere (#4634) 2023-01-22 13:21:30 -06:00
Charles Kerr
9678b26984 refactor: misc-use-anonymous-namespace pt. 3 (#4539) 2023-01-07 08:27:54 -06:00