Commit Graph

5774 Commits

Author SHA1 Message Date
Charles Kerr 5743758edd Revert "perf: recycle Diffie-Hellman keys iff peer was unreachable (#4408)"
This reverts commit 35a0211118.
2022-12-19 15:12:33 -06:00
Charles Kerr 35a0211118
perf: recycle Diffie-Hellman keys iff peer was unreachable (#4408) 2022-12-19 14:45:01 -06:00
Charles Kerr 76db72bc4b
perf: lazy-calculate torrent seconds-seeding stat (#4393) 2022-12-18 22:59:58 -06:00
Charles Kerr 9e6ffa351c
perf: reduce excess rand() calls in tr_bandwidth::phaseOne() (#4404) 2022-12-18 13:24:46 -06:00
Mike Gelfand 128cf34123
Move jsonsl and wildmat to third-party (#4402)
* Move jsonsl to third-party

This treats it as proper 3rd-party code to which our warning and style
settings don't extend.

* Move wildmat to third-party

This treats it as proper 3rd-party code to which our warning and style
settings don't extend.

* Fixup Xcode project to match new project structure
2022-12-18 19:19:07 +00:00
Charles Kerr 28b12f091f
perf: remove libtransmission::Buffer.vecs() (#4401)
Its two calls to evbuffer_peek() used 3.5% of CPU use (measured with perf
when built with RelWithDebInfo). I added vecs() so that libtransmsision
could send noncontiguous buffers via utp_writev(); but in my testing, all
the buffers being sent are contiguous and so this is unnecessary work.
2022-12-18 12:09:02 -06:00
Charles Kerr cc4141c619
fixup: 3899255 (#4394) 2022-12-18 11:18:25 -06:00
Cœur 4ff59b715d
Fixed implicit conversion warning: __LINE__ is a long (#4397) 2022-12-18 10:23:44 -06:00
Mike Gelfand e694c3e3a0
Use C++ (not C) warning flags for GTK client (#4395)
Use the opportunity to reduce duplication.
2022-12-18 01:02:03 +00:00
Charles Kerr 3899255f1c
fix: tear down utp _after_ peer-mgr (#4383) 2022-12-17 14:10:10 -06:00
Charles Kerr 616e79c0a8
refactor: group related tr_peerIo methods together (#4380)
* refactor: group related functions together in the source

* refactor: make tr_peerIo::decrypt() private

* refactor: make tr_peerIo::is_seed() private

* refactor: remove unused tr_isPeerIo()
2022-12-16 17:21:01 -06:00
Charles Kerr e6d75a4b77
refactor: tr_peerIo (#4372) 2022-12-16 01:23:12 -06:00
Cœur 669faf7474
Dropped tr_rand_int_weak where possible. (#4271) 2022-12-14 12:21:56 -06:00
Ștefan Talpalaru b0eaec47cd
fix: re-enable port forwarding (#4343) 2022-12-14 01:31:48 -06:00
Charles Kerr 6f1153cae4
refactor: tr_handshake (#4362) 2022-12-13 19:58:39 -06:00
Cœur 4a80f800a6
Fixed crash on exit in tr_utpPacket (#4348) 2022-12-13 16:51:54 -06:00
Charles Kerr 2f6315b649
refactor: tr_handshake lifecycle (#4358) 2022-12-13 11:59:21 -06:00
Cœur 9e0b42a61d
Fixed logic in tr_wildmat (#4353) 2022-12-12 16:35:40 -06:00
Cœur 7814e0736e
Fixed tr_bitfield::operator|= range (#4351) 2022-12-12 02:23:59 +00:00
Charles Kerr 5bd4f007ac
fix: remove invalid assertion from bitfield code (#4346) 2022-12-10 14:54:22 -06:00
Charles Kerr 0a69685a4e
refactor: tr_address cleanup (#4338)
* refactor: move tr_tracker_http_announce() helper funcs into their own namespace

* refactor: move tr_globalIPv6() helper funcs into their own namespace

* refactor: move tr_address_is_valid_for_peers() helper funcs into their own namespace

* refactor: make tr_address_compare() a private method

* refactor: rename tr_address::isIPv4() to is_ipv4()

* refactor: use snake_case for tr_address methods

* refactor: make tr_address_is_valid_for_peers() a member function
2022-12-08 20:27:52 -06:00
Charles Kerr 0061e4f9a9
refactor: tr_address::display_name() (#4335) 2022-12-08 16:44:19 -06:00
Charles Kerr f176bb299a
fix: broken detection of peer udp port (#4334) 2022-12-08 14:44:39 -06:00
Charles Kerr e06e304cc8
refactor: fix shutdown order of utp (#4331) 2022-12-06 14:28:48 -06:00
Charles Kerr 22a3a5db25
refactor: peer-socket pt 2 (#4326)
* refactor: tr_netOpenPeerSocket() now takes a tr_address reference

* refactor: disable copy assignment, copy constructor

* refactor: move log statements to peer_socket constructor
2022-12-06 10:28:28 -06:00
Charles Kerr 9a5d9a0ba2
refactor: tr_peer_socket (#4325)
* refactor: make tr_peer_socket.type private

* refactor: reimplement tr_peerIo::address() as a wrapper around tr_peer_socket::address()

* refactor: remove tr_address, tr_port from tr_peerIo

* refactor: replace tr_netClosePeerSocket() with tr_peer_socket::close()
2022-12-05 18:53:31 -06:00
Charles Kerr 468310300c
refactor: only need a single handshake mediator (#4322) 2022-12-05 11:47:11 -06:00
Charles Kerr 728e5b8350
refactor: stop tracking peerIo creation time (#4300) 2022-12-02 10:39:46 -06:00
Dmitry Antipov bf6c80ae35
refactor, ci: switch clang-format to LLVM 15 (#4297)
Bump required clang-format version to 15
2022-12-02 09:57:50 -06:00
A Cœur a656b3b8c9
fix: tr_rand_int modulo bias and fixed tr_rand_int for values larger than INT_MAX. (#4235) 2022-11-30 22:58:14 -06:00
Charles Kerr a7261526ac
fix: shut down utp sooner during session shutdown (#4287) 2022-11-30 16:35:10 -06:00
A Cœur e038121857
refactor: second log of UTP errors as 'trace' messages (#4283) 2022-11-30 14:06:08 -06:00
Charles Kerr f03fc9270b
Fix/long shutdown crash on shutdown (#4285) 2022-11-30 13:00:34 -06:00
Charles Kerr 595d0ac14a
refactor: add tr_announcer.startShutdown() (#4280) 2022-11-29 21:05:11 -06:00
Charles Kerr eeaefca6f3
refactor: UDP and TCP announces use same timeout interval (#4279)
* refactor: move announce, scrape timeout intervals into announcer-common.h

* refactor: udp and http announces, scrapes use same timeout vals
2022-11-29 19:38:53 -06:00
Charles Kerr 22d12aedc5
refactor: GTK favicon lookup improvements (#4278) 2022-11-29 18:09:32 -06:00
Charles Kerr 8900a1646e
refactor: do not report peer EOF as an error (#4275) 2022-11-29 10:48:20 -06:00
Charles Kerr 59335eac03
fix: sonarcloud cpp:S6004 (#4270)
reduce scope of variables by using if-based initializer
2022-11-28 21:03:28 -06:00
Charles Kerr 4adda4dc1e
fix: sonarcloud cpp:S6005 (#4268) 2022-11-28 18:26:03 -06:00
Charles Kerr af9f1b4e42
fix: potentially incorrect error message in rpc-server whitelist (#4264)
Fixes #928.
2022-11-28 15:46:30 -06:00
Charles Kerr f27c5fa0fa
refactor: make some local pointer vars pointer-to-const (#4262) 2022-11-28 09:45:39 -06:00
Charles Kerr 14dfafde32
refactor: add std::unique_ptr<evhttp> handler to utils-ev (#4261) 2022-11-28 08:07:04 -06:00
Charles Kerr 0ee93068bb
fix: TR_TORRENT_LABELS env var in scripts (#4260) 2022-11-27 21:59:45 -06:00
Charles Kerr 0efb96124b
perf: remove cpu bottleneck in tr_peerIo::write() (#4258) 2022-11-27 20:46:03 -06:00
Charles Kerr 49393daf01
refactor: use std::optional.value_or() (#4255) 2022-11-27 14:56:34 -06:00
Charles Kerr 33c1098ea0
refactor: reduce scope of TR_NATIVE_EOL_STR, TR_NATIVE_EOL_STR_SIZE (#4254) 2022-11-27 12:11:25 -06:00
Charles Kerr 3dd5cb439d
chore: updsate mime-types (#4246)
just running mime-types.js
2022-11-26 09:03:39 -06:00
Charles Kerr ec6cb67c5c
fix GTK client message log window does not restore level selection (#4242)
* fix: save log level, encryption mod, preallocation mode as ints

* fix: ensure log level is saved in tr_sessionGetSettings()

* fix: ensure the right verbosity row is selected
2022-11-26 07:32:51 -06:00
Charles Kerr feeea2649e
refactor: make tr_announcer.key a uint32_t (#4241) 2022-11-25 19:11:55 -06:00
Charles Kerr 8a35aa0903
refactor: add tr_rand_obj() (#4238)
* refactor: add tr_rand_obj()

There are a lot of places in the codebase where we need to populate
an integral type or a fixed-size array with random data. To do this,
we instantiate a local on the stack, fill it with tr_rand_buffer(),
and then use it.

This PR creates a helper function to make this a one-liner.
2022-11-25 15:04:37 -06:00
A Cœur 342484d14a
refactor: log UTP_ETIMEDOUT errors to 'trace' messages (#4237) 2022-11-25 14:44:49 -06:00
Charles Kerr 554ba06ae2
fix: coverity warnings, sonarcloud code smells (#4232) 2022-11-24 10:17:02 -06:00
Charles Kerr 19bc15523f
fix: new sonarcloud, coverity, gcc warnings (#4229) 2022-11-23 13:47:04 -06:00
Charles Kerr 046ba32d33
fixup: heap-use-after-free in announce, scrape response on shutdown (#4228)
fixes #4222.
2022-11-23 01:38:31 -06:00
Charles Kerr a8f2b840f7
perf: improve tr_peerMgrGetDesiredAvailable() (#4226) 2022-11-22 23:26:10 -06:00
Charles Kerr 40c7f5bceb
perf: constexpr and move work outside of loops (#4224) 2022-11-22 14:00:09 -06:00
Charles Kerr 43c57fb02a
perf: buffer iterators (#4220) 2022-11-21 23:54:28 -06:00
Charles Kerr a3772dc1fa
refactor: aggregate dh in peer io (#4218) 2022-11-21 18:08:06 -06:00
A Cœur d26db72d7e
Fix "Implicit conversion loses integer precision" (#4194) 2022-11-21 10:19:45 -06:00
Charles Kerr 76bea25f6e
perf: minor perf wins (#4216)
* perf: faster tr_buffer::toString()

* perf: faster tr_buffer::Iterator

* perf: get mutex lock in reconnectPulse() instead of closeBadPeers()
2022-11-21 09:28:46 -06:00
Herman Semenov ffd5e6bf50
refactor: remove unused vars, code simplify and minor optimize (#4172) 2022-11-19 09:46:03 -06:00
Charles Kerr d27c4c59ce
refactor: incremental announcer refactor pt. 2 (#4214) 2022-11-18 23:00:25 -06:00
A Cœur a187529f93
typo ICP -> TCP (#4213) 2022-11-18 21:53:16 -06:00
Charles Kerr 4cc0b77eec
refactor: incremental announcer improvements (#4211) 2022-11-17 20:23:54 -06:00
Charles Kerr f17cee97e5
fix: nullptr crash in peer-io (#4210) 2022-11-17 14:53:08 -06:00
Charles Kerr 42f26aad0b
fix: ftbfs on Windows (#4204) 2022-11-16 18:03:48 -06:00
Charles Kerr a45cc2a79d
refactor: try again to use getaddrinfo in announcer_udp (#4201) 2022-11-16 15:13:31 -06:00
Charles Kerr d2125ee965
perf: revert e065565cd to restore async dns lookups (#4182) 2022-11-15 11:16:49 -06:00
Charles Kerr d0639b5f0c
perf: tr_sys_path_basename() returns a std::string_view (#4176) 2022-11-15 08:29:00 -06:00
Charles Kerr 134363d83d
fixup! refactor: decouple session settings from the session class (#4053) (#4175)
fixes #4134
2022-11-14 19:10:19 -06:00
Charles Kerr 6bec2f22c8
fix: 4.0.0-beta.1 wrong RPC response for group-get (#4171) 2022-11-14 16:31:41 -06:00
Charles Kerr f9a6df6f41
refactor: use a condition_variable when removing a torrent from the verifier thread (#4166) 2022-11-13 23:11:48 -06:00
Charles Kerr 67e992ddf0
refactor: better TR_CURL_SSL_NO_VERIFY (#4159)
clear CURLOPT_CAINFO, CURLOPT_CAPATH iff verification is disabled
2022-11-13 17:17:16 -06:00
Charles Kerr 250e055c1d
fix: warnings from clang tidy sonarcloud coverity (#4143) 2022-11-12 09:53:09 -06:00
A Cœur 2aa46f840c
Remove std::enable_if<std::is_member_function_pointer> (#4139) 2022-11-11 11:18:17 -06:00
Charles Kerr 9e06cf8f2e
refactor: make DHT unblocking (#4122) 2022-11-11 10:09:24 -06:00
Charles Kerr d61e31c419
fix: more thread safety updates (#4136)
* fix: thread safety in tr_sessionLoadTorrents()

* refactor: use std::future in tr_sessionSet()

* refactor: use std::future in tr_sessionClose()
2022-11-10 12:04:49 -06:00
Charles Kerr 7e817b5a43
refactor: fix thread sanitizer warnings in tr_sessionClose() (#4130) 2022-11-09 20:30:34 -06:00
A Cœur 3e0ca88f7d
Fix "Forwarding reference passed to std::move" (#4114)
* Fix "Forwarding reference passed to std::move"

* Missing quotes in file references
2022-11-08 22:33:28 -06:00
Charles Kerr ab78759233
test: add libtransmission::Timer tests (#4121) 2022-11-08 16:20:21 -06:00
Charles Kerr 00cc28cf0b
perf: reuse existing evtimers instead of creating new ones (#4116) 2022-11-07 22:42:42 -06:00
Charles Kerr 162035a653
fix: minor recent clang warnings (#4111)
* refactor: fix modernize-use-default-member-init warning in session-thread.cc

* refactor: fix readability-named-parameter warning in session-thread.cc

* refactor: fix clang-diagnostic-unused-function warning for isSupportedSocket()

* refactor: fix clang-analyzer-deadcode.DeadStores warning in buildHandshakeMessage()

* chore: fix readability-identifier-naming warning for tr_session::session_mutex_

* chore: fix readability-identifier-naming warning for Watchdir::generic_rescan_interval_

* chore: fix readability-identifier-naming warning for __tr_current_time
2022-11-07 11:48:26 -06:00
A Cœur fd7bb4a287
Fix "upload/download connectivity is broken" (#4107) 2022-11-07 00:15:35 -06:00
Charles Kerr 4d8509c180
refactor: add libtransmission::evhelpers (#4104) 2022-11-06 15:11:30 -06:00
Charles Kerr 36edd516aa
refactor: replace tr_boundinfo with tr_session::BoundSocket (#4103) 2022-11-06 10:35:48 -06:00
Mike Gelfand bf17a3baf1
Fix web client directory name on Windows (#4099) 2022-11-05 08:45:34 +00:00
Charles Kerr 831eb8d40f
refactor: make `tr_session_thread` a unique_ptr owned by tr_session (#4069) 2022-11-04 16:20:27 -05:00
Charles Kerr e065565cd4
reafctor: use getaddrinfo() instead of evdns (#4094) 2022-11-04 13:29:56 -05:00
Charles Kerr 09bb1a60f0
refactor: add more nodiscard, constexpr, and noexcept (#4089) 2022-11-03 18:08:02 -05:00
Charles Kerr ee8a6bd130
refactor: simplify blocklist code (#4086) 2022-11-03 15:46:27 -05:00
A Cœur 8857e8c1a4
Declare TR_ETA_NOT_AVAIL as time_t (#4065) 2022-11-03 11:42:42 -05:00
A Cœur 84badfc66f
removing unreachable code (#4083) 2022-11-03 09:47:43 -05:00
SweetPPro 94eeae203b
fix: 4.0.0-beta.1 crash when updating blocklist (#4011) 2022-11-02 09:41:05 -05:00
A Cœur 64b5fde8b2
fixup: silence "empty expression statement has no effect" warning (#4074) 2022-11-02 09:04:22 -05:00
Charles Kerr 611d36ac84
refactor: decouple session settings from the session class (#4053) 2022-11-01 19:32:26 -05:00
Charles Kerr d5ef1ea80a
fix: test for tr_peerIo.gotError function pointer before use (#4051) 2022-10-29 16:59:24 -05:00
Charles Kerr cdf817f2e7
fix: FTBFS on Windows (#4036)
* refactor: getPiececLength() now returns size_t

* refactor: tr_torrentSetMetadataPiece() length arg is now size_t

* refactor: tr_peerIo::flushOutgoingProtocolMsgs() returns size_t, takes a tr_error** for reporting errors

* refactor: define tr_mode_t for convenience

* fix: suseconds_t portability fix
2022-10-28 19:12:37 -05:00
Charles Kerr 210bb03f2f
fix: recent signed-unsigned comparison warnings (#4034) 2022-10-26 11:20:10 -05:00
A Cœur 12e564096b
fix: "Implicit conversion loses integer precision" warnings (#3960) 2022-10-25 11:14:42 -05:00
A Cœur 14f2698cdc
Remove tr_generateAllowedSet declaration (#4029) 2022-10-25 08:50:53 -05:00
Charles Kerr 798e873b87
fix: sonarcloud warnings (#4023) 2022-10-24 22:13:09 -05:00
Charles Kerr 088e146cee
fix: crash on large udp announce response (#4022)
Fixes #4006.
2022-10-24 17:58:19 -05:00
Charles Kerr e8079835d3
fix: crash when a torrent autopauses after encountering an error (#4021) 2022-10-24 16:57:07 -05:00
Charles Kerr 2262efdb7f
fix: ignore unrecognized torrent-get fields (#4018)
Fixes #2916.

Not actually a Transmission bug, but restores undefined behavior to be
consistent with 3.00's undefined behavior in the RPC spec.
2022-10-24 15:02:48 -05:00
Charles Kerr b32f3e0a24
refactor: add tr_address::toCompact() (#4014)
* refactor: add tr_address::toCompact()

* test: use the theory.org compact ipv4/6 examples in NetTest.compact4, NetTest.compact6

* refactor: add tr_address::toCompact()

* test: add toCompact, fromCompact tests

* refactor: add compact <--> sockaddr_storage conversion
2022-10-24 13:40:12 -05:00
Mike Gelfand 70f623f32b
Add user data parameter for torrent removal callback (#4009) 2022-10-23 11:51:35 -05:00
Charles Kerr d191a04228
refactor: decouple tr_announcer_udp (#4002) 2022-10-21 13:15:14 -05:00
Derek Reiff 6187cfd67b
Refresh web interface across desktop and mobile (#3985)
* Add macOS section to Web-Interface docs

- Add minimal steps to enable web interface on macOS
- Clean up README.md with some markdown linting.

* Updating and modernizing web interface, colors, icons

In general:

- increase spacing and decrease font sizes in most inspectors (so far)
- replace icons  with emoji. may not be the way to go in the end

* update toolbar icon sizes to adjust for differences

* Switch from icons to buttons, other minor color changes

1. Add 'warn' class to dangerous actions
2. Add 'table-row' helper to overflow menu
3. Use text instead of icons for this new tab style

* Update icons using feathericons.com

* Rename files, replace some SVG and optimize PNG

* Remove more unused variables

* Update index.html to reflect new icons

* More minor svg changes; delete old images

* Updated build output

* Remove icons, add new feather svg icons

Build is now sub-200 KB
2022-10-21 12:22:59 -05:00
Charles Kerr 450f1dcadc
refactor: extract `tr_buffer` class from `tr_peerIo` (#3986) 2022-10-19 11:42:08 -05:00
Charles Kerr 7ee76a604d
feat: add libtransmission::Dns.cached() (#3984) 2022-10-17 20:17:01 -05:00
Charles Kerr c8e652c820
refactor: add dns interface class (#3977) 2022-10-17 14:41:42 -05:00
Charles Kerr 79068c512a
refactor: decouple tr-dht from peerMsgs, peerMgr (#3966)
* refactor: decouple peer-mgr from tr-dht

* refactor: remove tr_dhtPort()

* refactor: decouple peer-msgs from tr-dht

* refactor: make tr_udp_core.udp_port_ const

* refactor: rename tr_udp_core::dhtUninit() as startShutdown()
2022-10-15 08:22:43 -05:00
Charles Kerr 572e1bb50f
refactor: add tr_address::fromSockaddr() (#3964)
* refactor: remove TR_DISCARD_ALIGN

* refactor: add tr_address::fromSockaddr()
2022-10-14 01:20:39 -05:00
Charles Kerr 4a359fd481
refactor: session private fields (#3961)
* refactor: make tr_session.private_peer_port a private field

chore: make tr_session.public_peer_port a private field

* refactor: make tr_session.web_ a private field

* refactor: make tr_session.lpd_ a private field

* refactor: make tr_session.bind_ipv4_ private

refactor: make tr_session.bind_ipv6_ private

* refactor: make tr_session.bandwidth_groups_ private; add const accessor

* refactor: make tr_session.port_forwarding_ private

* refactor: make tr_session.peerMgr private pt 1: add tr_session::addIncoming()

* refactor: make tr_session.peerMgr private pt 1: add tr_session::addTorrent()

* refactor: make tr_session.peer_mgr_ private

* refactor: make tr_session.setPeerPort() private
2022-10-13 21:25:02 -05:00
Charles Kerr a2817faab1
refactor: tr_session declaration cleanup (#3958)
* chore: move private tr_session struct declaration to beginning of class

* chore: move all tr_session fields into the same code section

* chore: move private constexpr, const fields before mutable ones

* chore: move trivial fields before nontrivial fields

* chore: reconcile with refactor/session-const-fields-first
2022-10-13 16:25:54 -05:00
A Cœur 4ea9c87fea
fix: some typos (#3904) 2022-10-13 09:35:10 -05:00
A Cœur 33afdc32f9
fix: "Nullptr with nonzero offset" (#3941) 2022-10-11 16:52:13 -05:00
Mike Gelfand f1f55cc3df
Sync translations (#3939)
* Sync translations with code

* Sync translations with Transifex

* Remove Mac menu title that isn't displayed and shouldn't be translated

* Add context to logging level strings in GTK client

* Use "µTP" consistently in code

* Use ellipsis instead of three docs in Qt client strings

* Close HTML tags in blocklist-related strings

* Remove trailing space from a translatable string in Qt client

* Add missing plural forms for English strings in Qt client

* Fix spelling: metaInfo -> metainfo
2022-10-11 18:39:41 +03:00
depler e3b871216f
Add missing include in port-forwarding-upnp.cc (#3911)
Got error `FMT_STRING: identifier not found` due lack of include
2022-10-08 22:27:06 +03:00
Charles Kerr 8ac2c0a814
fix: dht bootstrap regression (#3874)
Fixes #3868
2022-10-06 18:43:18 -05:00
Charles Kerr 89d6533cd7
build: support semver versioning (#3867)
* build: semver versioning

Xref: https://github.com/transmission/transmission/issues/1037

* test: add base62 tests for client-id

* build: include PATCH_VERSION in Transmission.rc.in

* build: semver versioning in version.h

* fixup! build: semver versioning in version.h

undo experimental verison changes that were made for testing purposes

* Fixup version in MSI package filename

Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2022-10-05 16:53:10 -05:00
Charles Kerr fff4c87740
refactor: add tr_address::toSockaddr() (#3870) 2022-10-04 14:52:51 -05:00
Charles Kerr b49129dfa6
fixup: new dht bootstrap regression (#3866) 2022-10-02 20:32:14 -05:00
Charles Kerr fed6d180fe
fixup: new coverity warnings (#3864)
* fixup: memcmp length argument regression

* perf: fix big parameter passed by value

* chore: silence unchecked curl_easy_setopt return value warning
2022-10-02 19:45:38 -05:00
Charles Kerr 3bb8f3c03f
fixup: new clang-tidy warnings (#3863) 2022-10-02 17:56:58 -05:00
Charles Kerr 0a0c15d17c
fix: circular dependency in udp core and dht init (#3862) 2022-10-02 13:18:23 -05:00
Charles Kerr 257d98545b
refactor: add tr_port_forwarding::Mediator (#3855)
* 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
2022-10-01 09:12:49 -05:00
Harm133 467be24358
Blocklist/Session: move loadBlocklists function to BlockListfile struct (#3854) 2022-09-30 18:29:26 -05:00
Harm133 1cd6c0464c
feat: Add IPv6 blocklist support (#3835) 2022-09-30 12:11:52 -05:00
A Cœur f27e1b52f4
Fix TR_ASSERT equality (#3852)
* Fix TR_ASSERT equality

* Further workaround to the assertions from tr-dht

* Update libtransmission/tr-dht.cc

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2022-09-30 10:04:46 -05:00
Charles Kerr bf156a97cf
refactor: port forwarding (#3850)
* refactor: rename state enum type as tr_port_forwarding_state

* chore: use snake_case for tr_shared struct fields

* refactor: replace tr_shared with tr_port_forwarding

* refactor: make tr_natpmp_state an enum class

* refactor: uniform naming for port-forwarding module

* refactor: move output-only parameters in tr_natpmp::pulse() to return struct

* fix: use a nullptr multicastif if bindaddr is empty

* chore: use PascalCase for enum class values

* chore: clean up port-forwarding #includes

* chore: remove unused tr_port_forwarding::peerPort()
2022-09-30 08:59:10 -05:00
Charles Kerr a5ca289f41
fix: #3847 crash on session close (#3849)
* chore: use typesafe sin_addr assignment instead of memcpy()

* refactor: make tr_dhtPrintableStatus private

* refactor: make tr_dhtStatus() private

* refactor: make tr_dht status enum private

* refactor: add safety mutex wrapper around libdht API calls

* refactor: make tr_dht::Status an enum class

* refactor: rename private functions

* refactor: const correctness

* refactor: use typesafe assignment instead of memcpy

* refactor: tr_session does not directly call tr_dht

* refactor: tr_dhtPort() returns std::optional

* refactor: use tr_address::fromCompact4 in tr-dht.cc
2022-09-29 09:12:33 -05:00
Charles Kerr d82090658f
refactor: remove TR_PRIsv macros (#3842)
* refactor: remove TR_PRIsv from transmission-show

* refactor: remove TR_PRIsv from transmission-edit

* refactor: remove TR_PRIsv from transmission-remote

* refactor: remove TR_PRIsv from log.cc

* refactor: remove TR_PRIsv macro

* chore: remove FMT_STRING macro in transmission-edit

* refactor: use __android_log_write()
2022-09-23 14:36:37 -05:00
Charles Kerr 326d9f3daf
refactor: cppcoreguidelines-avoid-goto (#3841)
* refactor: do not use goto in file-win32.cc

* refactor: do not use goto in subprocess-posix.cc

* refactor: do not use goto in peer-io.cc

* build: add cppcoreguidelines-avoid-goto to libtransmission/.clang-tidy
2022-09-23 08:39:13 -05:00
Charles Kerr 56e0a1bda8
chore: add cppcoreguidelines-pro-type-member-init to libtransmission/.clang-tidy (#3840) 2022-09-23 00:51:15 -05:00
L2501 4977c1a02f
add clientIDs for BitTorrent Web, Free Download Manager 6, Torch Browser (#3838) 2022-09-22 16:55:51 -05:00
Charles Kerr 228efa16e3
refactor: tr_globalIPv6() returns a std::optional<in6_addr> (#3836) 2022-09-21 23:59:31 -05:00
Charles Kerr dd12fd010a
chore: iwyu headers (#3833) 2022-09-21 18:34:18 -05:00
Dmitry Antipov 243ab1058d
refactor: fold session UDP innards into C++ class (#3794)
* Use std::unique_ptr to manage UDP core object

N.B.: it's no longer valid to call socket adjustments quirks from
tr_sessionSetUTPEnabled() because the corresponding object may be
not created yet. We have to create (or re-create) it explicitly
(like it's done in tr_sessionSetDHTEnabled()) or just set
is_utp_enabled_ flag of the session and assume that socket
adjustments will be done later when the object is constructed.
2022-09-21 13:25:53 -05:00
Charles Kerr 80d9d5a63b
refactor: add tr_peerIo::peek() (#3798) 2022-09-09 13:12:47 -05:00
Charles Kerr c0f29a89ea
refactor: add [[nodiscard]] (#3793) 2022-09-08 21:49:51 -05:00
Charles Kerr 9280bf3475
chore: re-enable qt clang tidy warnings (#3791) 2022-09-08 18:26:18 -05:00
Charles Kerr 9fb590d3f5
fix: recent coverity warnings (#3788)
* fix: suppress intentional USE_AFTER_FREE in tests

* fix: unnecessary field check

* fix: in ~tr_verify_worker(), release mutex lock before waiting
2022-09-07 19:24:56 -05:00
Dmitry Antipov 2bcb8f8535
Do not fsync descriptor referred to a tty (#3785)
When transmission-daemon is running with '--foreground' option,
log messages are emitted to standard error, which may be referred
to a tty. Since an attempt to fsync() tty is always an error,
an extra isatty() precaution should be applied.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
2022-09-07 13:44:31 -05:00
Charles Kerr 806a6382d7
fixup new minor warnings (#3786)
* fixup! Add fallback for copy_file_range EXDEV error (#3756)

* fixup! refactor: use readability-identifier-naming in clang-tidy (#3784)
2022-09-07 12:41:01 -05:00
Charles Kerr 1782dc6d7a
refactor: use readability-identifier-naming in clang-tidy (#3784) 2022-09-07 11:04:28 -05:00
Xist12gh 32a4709b1a
Add fallback for copy_file_range EXDEV error (#3756)
* Invalid cross-device: copy_file_range changed in Kernel 5.18 (#3654)

* allow fallback to other copy routines based on errno

* tiered kernel copy routines are tried in runtime now when available
2022-09-07 00:25:52 -05:00
Charles Kerr d17341d784
refactor: constify (#3780) 2022-09-06 12:52:58 -05:00
Charles Kerr 82212ff1d8
refactor: move the verify worker thread into a wrapper class (#3775) 2022-09-05 23:43:59 -05:00
Dmitry Antipov 4adcb73bb0
refactor: prefer std::array over plain C array in tr-dht.cc (#3765) 2022-09-05 19:06:49 -05:00
Dmitry Antipov 72a1696900
refactor: fix warning issued during LTO build (#3766)
Fix the following warning emitted when using -flto with GCC 12.2.1:

libtransmission/announcer.cc:929:8: warning: type ‘struct announce_data’ violates the C++ One Definition Rule [-Wodr]
  929 | struct announce_data
      |        ^
libtransmission/announcer-http.cc:299:8: note: a different type is defined in another translation unit
  299 | struct announce_data
      |        ^
libtransmission/announcer.cc:931:15: note: the first difference of corresponding definitions is field ‘tier_id’
  931 |     int const tier_id;
      |               ^
libtransmission/announcer-http.cc:301:22: note: a field with different name is defined in another translation unit
  301 |     tr_sha1_digest_t info_hash;
      |

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
2022-09-05 10:47:45 -05:00
Charles Kerr 8eab7d3ae7
chore: remove dead "fast set" code (#3764)
* chore: remove old fast set code

* chore: remove TR_SHA1_DIGEST_LEN declaration

* chore: remove TR_SHA256_DIGEST_LEN declaration
2022-09-05 08:55:17 -05:00
Charles Kerr ae74a13eb1
test: improve file-win32, file-posix test coverage (#3761) 2022-09-04 19:40:34 -05:00
wiz78 1bba2a8c61
fix tr_session::shouldDeleteSource() (#3759)
shouldDeleteSource() was returning the same value as shouldPauseAddedTorrents()

Co-authored-by: Simone Tellini <simone@tellini.info>
2022-09-04 12:05:39 -05:00
Charles Kerr 581349ac37
refactor: simplify tr_clientForId() (#3751)
* refactor: use make buf_append() a template function; use libfmt

* refactor: make charint() use a lookup table

* chore: use std::equal instead of strncmp
2022-09-03 02:13:22 -05:00
L2501 22669dda5e
Add Advanced Download Manager & LibreTorrent client names (#3750) 2022-09-02 12:37:25 -05:00
Charles Kerr 1062ae8f1f
refactor: split tr_parseNum inout var into two vars (#3748)
build: re-enable cert-err34-c warning
2022-09-02 01:04:09 -05:00
Charles Kerr 6d721fe32f
perf: check torrrent seed ratio less frequently (#3747) 2022-09-01 21:16:43 -05:00
Charles Kerr b01eebdaf4
refactor: tr_peer_event (#3746) 2022-09-01 16:37:11 -05:00
Charles Kerr 3b692e1aa0
refactor: reduce http announce timeout interval to 45 seconds (#3745) 2022-09-01 15:11:51 -05:00
Charles Kerr 6ca0ce683a
refactor: more constexpr (#3744)
Make more simple functions constexpr where possible.
2022-08-31 17:33:51 -05:00
luzpaz f8203148f0
fix: fix various user facing and non-user facing typos (#3743)
* fix: fix various user facing and non-user facing typos

Found via `odespell -q 3 -S ./third-party,*.po,*.ts -L filetest,inout`
2022-08-31 11:28:54 -05:00
Charles Kerr ea05474464
perf: make methods constexpr (#3742) 2022-08-30 23:17:23 -05:00
Charles Kerr d130f7d593
refactor: prefer std::unique_ptr over std::shared_ptr (#3741) 2022-08-30 19:30:47 -05:00
Charles Kerr b989b72c0f
refactor: remove unnecessary default destructors (#3740) 2022-08-30 14:31:40 -05:00
Charles Kerr b7ea4d9f04
refactor: tr_peerIo ref, unref (#3735)
* refactor: replace manual peerIo refcounting with std::shared_ptr
2022-08-30 12:38:30 -05:00
Charles Kerr 7c014e3256
Refactor/tr peer io member funcs (#3734)
* refactor: make tr_peerIoSetEnabled() a member method

* refactor: make tr_peerIoFlushOutgoingProtocolMsgs() a member method

* refactor: make tr_peerIoFlush() a member method

* refactor: make tr_peerWriteBytes() a member method

* refactor: make tr_peerWriteBuf() a member method

* refactor: make tr_peerIoGetWriteBufferSpace() a member method

* chore: remove unused declaration

* refactor: make tr_peerIoUtpInit() a member method

* refactor: make tr_peerIoNew() a member method

* refactor: make tr_peerIoNewOutgoing() a member method

* refactor: make tr_peerIoNewIncoming() a member method
2022-08-29 15:58:18 -05:00
Charles Kerr 0ed595ca0e
refactor: tr_peerIo read buffer (#3732)
* refactor: make tr_peerIoReadBytes() a member method

* refactor: make tr_peerIoReadUint8() a member method

* refactor: make tr_peerIoReadUint16() a member method

* refactor: make tr_peerIoReadUint32() a member method

* refactor: make tr_peerIoSetIOFuncs() a member method

* refactor: make tr_peerIoReconnect() a member method

* refactor: make tr_peerIoClear() a member method

* refactor: make tr_peerIoDrain() a member method

* refactor: move evbuffer_add_hton_16() impl to cc
2022-08-29 13:33:08 -05:00
Charles Kerr cee339e10d
refactor: remove tr_removeElementFromArray() (#3731) 2022-08-28 21:51:26 -05:00
Charles Kerr 0360cfbf72
refactor: remove tr_ctorSetBandwidthPriority() from public API (#3730)
it is only used via RPC, so remove it from transmission.h
2022-08-28 19:04:29 -05:00
Charles Kerr 072bb0322c
refactor: remove tr_quark_get_string() (#3728) 2022-08-28 16:17:07 -05:00
Charles Kerr 4f3f0ccbeb
refactor: remove unused function tr_sys_file_seek() (#3727)
* refactor: remove TR_SYS_FILE_CREATE_NEW

* refactor: remove tr_sys_file_seek()
2022-08-28 14:10:00 -05:00
Charles Kerr 6c5fda2021
refactor: use std::ifstream in torrent-magnet (#3726) 2022-08-28 12:33:58 -05:00
Charles Kerr 185f1f96a5
test: add torrent-magnet tests (#3725) 2022-08-27 17:06:20 -05:00
Charles Kerr db3467b553
refactor: remove tr_sys file_map_for_reading() (#3723) 2022-08-27 14:05:21 -05:00
Charles Kerr 291d2fcb9b
fix: when renaming local data files fails, set the torrent error and pause the torrent (#3717) 2022-08-26 18:57:44 -05:00
Charles Kerr 9e07b6f4c5
fixup! refactor: modernize cache.cc (#3108) (#3715) 2022-08-26 14:46:46 -05:00
Charles Kerr a24679d89f
refactor: modernize-avoid-c-arrays pt. 2 (#3713) 2022-08-26 13:35:28 -05:00
Greg Hazel fa8b6a5e0a
option to disable TCP (#3447) 2022-08-25 21:27:11 -05:00
Charles Kerr 377134f475
fix: lpd fixup (#3704)
* chore: fix copyright of lpd header file

* chore: remove unnecessary forward declarations

* fix: LSD messages use proper format even when no cookie
2022-08-24 22:18:58 -05:00
Charles Kerr e191407dee
refactor: modernize-avoid-c-arrays pt. 1 (#3702) 2022-08-24 20:19:21 -05:00
Charles Kerr e8686095ed
refactor: local peer discovery (#3696) 2022-08-24 16:03:30 -05:00
Charles Kerr ab09718342
fixup! perf: sonarcloud warnings about temp objects (#3686) (#3699) 2022-08-23 15:46:08 -05:00
bexnoss 258faf3623
gtk: Remember 4 recent relocate dirs (#3691)
* fix(gtk): prevent duplicate shortcut folders

This prevents duplicates if the recent destination is also a system
shortcut folder.

* refactor(gtk): create gtr_get_recent_dirs helper

* feat(gtk): remember 4 recent relocate dirs
2022-08-21 21:26:13 -05:00
Viacheslav Chimishuk cb17ea4914
Fix IPv6 announce socket binding interface. (#3692)
When Transmission listens on both IPv4 and IPv6 interfaces IPv4 listen address
is always passed to CURL's CURLOPT_INTERFACE. In general it stays unnoticed but
if user has multiple IPv6 addresses configured on his system random (first?)
IPv6 address is used. It happens because passed value to CURLOPT_INTERFACE
is not correct -- IPv6 expected but IPv4 is passed.
2022-08-21 18:37:38 -05:00
Charles Kerr bbb1ba6ea3
refactor: tr_urlPercentEncode() (#3688) 2022-08-21 08:43:09 -05:00
Charles Kerr 785119f2c2
perf: sonarcloud warnings about temp objects (#3686)
* perf: sonarcloud warnings about unnecessary temporary objects

* refactor: rename tr_sha1_digest_t::final() as finish()
2022-08-20 15:57:32 -05:00
Charles Kerr 4b615572c3 chore: re-enable readability-redundant-access-specifiers warning (#3685) 2022-08-20 14:49:11 -05:00
Charles Kerr 5bcbb7e34b
refactor: aggregate arc4 into libtransmission (#3684) 2022-08-20 13:41:40 -05:00
Charles Kerr d2852b6043
fix: 3579 assertion when RPC client asks for torrent-id 0 (#3683)
Fixes #3579.
2022-08-20 11:55:32 -05:00
Charles Kerr da3d83eaed
refactor: make blockinfo methods constexpr (#3682)
this can be constexpr and is an outlier in CPU profiling.
2022-08-20 10:40:18 -05:00
Charles Kerr 7dd55b64e1
fix: close all timers before destroying the event loop (#3679) 2022-08-19 19:28:24 -05:00
Charles Kerr aac1ab784d
refactor: replace tr_http_escape() with tr_urlEscape() (#3678) 2022-08-19 14:33:06 -05:00
Charles Kerr 1cf19550ad Revert "refactor: use OutputIterator for url-escaped info hash strings (#3672)"
This reverts commit 479a16787e.
2022-08-19 02:18:16 -05:00
Charles Kerr dde626d5e5
refactor: remove unused (#3675)
* refactor: remove unused define TR_PATH_DELIMITER_STR

* refactor: make TR_DEFAULT_BIND_ADDRESS_IPV4 private

* refactor: make TR_DEFAULT_BIND_ADDRESS_IPV6 private

* refactor: make TR_DEFAULT_RPC_HOST_WHITELIST private

* refactor: remove unused function tr_sessionSetRPCUrl()

* refactor: remove unused function tr_sessionGetRPCUrl()

* refactor: remove unused field native_local_path_prefix

* refactor: remove unused field native_unc_path_prefix
2022-08-18 22:47:23 -05:00
Charles Kerr c532728c42
refactor: remove TR_N_ELEMENTS macro (#3674)
* refactor: use std::array for keys in transmission-remote

* refactor: use std::array for wide_module_path in platform.cc

* refactor: use std::array for value in tr_env_get_int()

* refactor: use std::array for SysStoreNames in web.cc

* chore: remove unused macro TR_N_ELEMENTS
2022-08-18 21:31:53 -05:00
Charles Kerr 479a16787e
refactor: use OutputIterator for url-escaped info hash strings (#3672) 2022-08-18 14:49:20 -05:00
Charles Kerr c171d6df7c
refactor: remove tr_utf8_validate from public API (#3671)
it was only used as an impl helper, so make it private
2022-08-18 13:23:59 -05:00
Charles Kerr 76a7994eef
refactor: remove tr_free() (#3668) 2022-08-18 09:14:12 -05:00
Charles Kerr 963a8112a1
refactor: remove tr_strvDup() (#3666) 2022-08-17 21:18:44 -05:00