Commit Graph

4909 Commits

Author SHA1 Message Date
Charles Kerr de4634f0a5
fix: clang++ nullptr dereference warning in tr_variantWalk() (#1800)
* fix: clang++ nullptr dereference warning in variant.cc
2021-09-15 13:51:19 -05:00
Charles Kerr e19353bf60
fix: dead-store asssignment warning in file-posix. (#1809)
* fix: dead-store asssignment warning in file-posix.

This also extracts the different per-platform preallocation methods into
their own standalone functions for readability and clarity.
2021-09-15 11:55:46 -05:00
Charles Kerr fc0ba38bc9
refactor: tr_quickfindFirstK --> std::partial_sort (#1794)
* refactor: tr_quickfindFirstK --> std::partial_sort

Remove `tr_quickfindFirstK()` and use `std::partial_sort()` instead.

Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2021-09-15 09:32:07 -05:00
Charles Kerr abdfcb9681
fix: dead store warning in peer-msgs.cc (#1804) 2021-09-14 22:49:04 -05:00
Charles Kerr 19de6035a5
fix: dead store warning in handshake.cc (#1803) 2021-09-14 21:23:53 -05:00
Dmytro Lytovchenko 43d1ece562
C++ modernization: Replace NULLs with typesafe nullptrs (#1799)
Fixing CI errors and build errors
Reverted changes: NULL in EV_SET macro; Clang-formatting
Reverted changes: MacosX *.m files reverted from master
2021-09-14 19:18:09 -05:00
Charles Kerr 098c7508e3
fix: clang nullptr dereference warning in utils.cc (#1797)
We know what strings are passed into tr_strip_positional_args(). Instead
of using dynamic allocation, use a fixed-size array that's big enough to
fit the strings that we have.
2021-09-13 08:45:01 -05:00
Charles Kerr 4c1b627647
refactor: port libtransmission to C++ (#1787)
Port libtransmission to C++. This PR doesn't refactor everything to c++.
Its code changes are only what was necessary to compile and link as c++.
See libtransmission/README.md for details on how to submit modernization 
patches!

Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2021-09-12 12:41:49 -05:00
Mike Gelfand a459e5e11b
Switch to a standalone ARC4 implementation (#1788)
* Switch to a standalone ARC4 implementation

This frees us from expecting it being provided by one of the crypto
libraries we support, all of which deprecated and/or removed it at this
point.

Fixes: #1103
Fixes: #1777

* Suppress lgtm warnings about RC4 being weak (we don't care)
2021-09-12 06:47:29 +03:00
Charles Kerr 97a6f1232e
fixup! perf: prioritize announces based on scrape stats (#1782) (#1786)
* fixup! perf: prioritize announces based on scrape stats (#1782)
2021-09-11 08:11:46 -05:00
Charles Kerr 40868d1621
perf: faster tr_sessionCountQueueFreeSlots() (#1785)
The previous code had some redundant calculations, e.g. calling 
tr_torrentGetActivity() a couple of times per torrent, once in 
tr_sessionCountQueueFreeSlots() and once in tr_torrentIsStalled(). 
Only one call is necessary.

tr_sessionCountQueueFreeSlots() used to keep iterating through all 
torrents even if the number of free slots had already been decremented 
to zero, even though further iteration does not change the zero return 
value :) This PR checks the return value while looping to prevent this.
2021-09-10 15:15:35 -05:00
Charles Kerr a673c49bd6
perf: do not generate address strings as log name if logging is disabled (#1784)
* perf: if logs are disabled, don't build log names

handshake.c and peer-io.c call tr_peerIoGetAddrStr() to build a name for
passing to tr_logAddDeepNamed(). Since tr_peerIoGetAddrStr() isn't free,
make sure deep logging is enabled before building the name.
2021-09-10 12:22:46 -05:00
Charles Kerr 756bb349d6
perf: prioritize announces based on scrape stats (#1782)
* perf: prioritize announces based on scrape stats

This change is to improve responsiveness when starting a large batch of
torrents, e.g. when starting up a seedbox, but is also generally useful.

First, try to scrape as many torrents as as quickly as possible, giving
preference to that even over announces. Thanks to multiscrape we can run
through scrapes an order of magnitude faster than announces. Then scrape
responses tell us which swarms have leechers and we can prioritize those
torrents' announces.

Second, increase how many scrapes and announces we start at a time. This
limit probably hasn't been needed since 2da97b25 and by scraping faster,
the sooner we'll know which torrents to announce first.

* chore: remove printf() tracer
2021-09-09 19:28:22 -05:00
Charles Kerr d6cb99e57c
perf: use scrape to know when a private swarm is all-seeds (#1780)
* perf: use scrape to know when a swarm is all-seeds

For private torrents, the tracker is the sole source of peers. So when a
private torrent's tracker responds that there are 0 leechers, we can use
that information to mark the entire swarm as seeders and to not initiate
connections to those peers if we are seeding. This can help seedboxes to
more efficiently pick which swarms to prioritize.

This strategy is not used on public torrents, since new seeder-to-seeder
connections can be useful there for pex.

This PR changes tr_peerMgrAddPex() to (1) remove tr_atom.seedProbability
field (which was not as robust as intended) and (2) add batches of peers
instead of a single peer.

* fix: only use all-seeds check for private torrents
2021-09-09 15:25:30 -05:00
Charles Kerr f83e07e2a0
perf: do not rechoke in tr_peerMgrStartTorrent() (#1779)
tr_peerMgrStartTorrent() is called once per torrent on startup, so this
can be expensive if the user has a lot of torrents.

Instead, enqueue a pending rechoke that will happen on idle. This way,
all the added torrents can be handled by a single rechoke call.
2021-09-09 07:36:10 -05:00
Charles Kerr c0ed82533c
perf: lookup tables for faster torrent searching. (#1778)
* perf: lookup tables for faster torrent searching.

tr_torrentFindFromId(), tr_torrentFindFromHashString(), and
tr_torrentFindFromHash() are now O(log N) instead of O(N) where
N is the number of torrents.

* build: fix clang-tidy warning

error: integer to pointer cast pessimizes optimization opportunities
[performance-no-int-to-ptr,-warnings-as-errors] from TR_BAD_SYS_FILE
which expands to INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)
2021-09-09 00:22:29 -05:00
Mitch Livingston e9a39fb608
Merge branch 'master' into prefetch-magnet 2021-08-22 18:56:58 -04:00
Mike Gelfand db3d40d0ed Switch to clang-format for code formatting, include Mac client 2021-08-16 00:38:29 +03:00
Mike Gilbert 409f59889b
Restore support for the INSTALL_LIB option (#1756)
It appears this was removed by accident.

Fixes: 677dc73eac
2021-08-13 21:26:38 +03:00
RobCrowston 0155252823
Add in-kernel file copying for several platforms. (#1092)
* Add in-kernel copying support for Linux (sendfile64(2), copy_file_range(2)), FreeBSD 13 (copy_file_range(2)), MacOS (copyfile(2)), and Windows (CopyFileExA).

* Fix macro name USE_COPY_FILE_RANGE.

* Minor bugfixes for userspace fallback.

* Fix linux sendfile64 bugs.

* Remove some overzealous asserts.

* Allow transmission-test-copy to take an optional argument for an external reference file.

* Fix return value error of tr_sys_path_copy.

* Use COPYFILE_ALL for Macs without COPYFILE_CLONE.

* Add in-kernel file copying for several platforms.

Numerous operating systems now have support for copying files directly in the
kernel, which is generally more efficient than copying in a userspace read(2)/
write(2) loop. (This becomes particularly relevant for 4th gen PCI-E storage,
which approaches the latency of DRAM.) For Linux I use sendfile64(2), and, for
later kernels, copy_file_range(2). FreeBSD 13 will also support
copy_file_range(2). MacOS has copyfile(2), and Windows has CopyFileExA.
Operating systems lacking such a syscall continue to use the existing
read(2)/write(2) loop.

* Appease uncrustify.

* Appease uncrustify.

* copy-test: generate random content at run time.

* copy-test: Stylistic changes and more check()s.

* copy-test: files_are_identical should follow test idioms

* tr_sys_path_copy: numerous tweaks as requested by review.

* s/old file/source file; s/new file/destination file.

* tr_sys_path_copy: handle win32 wide characters in paths.

* Uncrustify.

* test-copy: Use non-string create_file_with_contents.

* tr_sys_path_copy: numerous fixes.

Per review: generate test file content at runtime; tidy use of check();
fix style; re-measure file sizes in the copy; define a macro when the
system does not provide it; use Unicode APIs on Windows; and fix
documentation.

* Updated as per comments.

* Rebase kernel-copy changes onto 3.0 with gtest.

* Undo irrelevant comment change.

* Fix syntax error.

* Use tr_malloc() instead of tr_valloc().

* Use EXPECT instead of TR_ASSERT in gtest.

* Add error handling.

* Acceptable coding style has changed again.

Now it's camelCase. Also use nullptr instead of NULL, etc.

* Fix east/west const.

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
2021-08-07 12:04:03 +03:00
Charles Kerr 07d385cf44
refactor: torrent-complete-sound-command is a list (#1710)
* refactor: torrent-complete-sound-command is a list
2021-05-25 11:21:41 -05:00
Lucas Clemente Vella 1194b88258
Renaming variables to better reflect what they do. (#1660)
Because bound IPv4 is hardly ever a public address.

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-05-19 15:45:03 -05:00
Mark Deepwell c7feedcf45
Support uTorrent Web with both azureus style and the one without the dash at the end 2021-05-11 21:39:09 -07:00
Mark Deepwell d57f575892
Retain full BitLord build number 2021-04-27 20:47:37 -07:00
Mark Deepwell 7ff6d8cf36
Add unrecognized client names #1363
This is based off of PR#1526 by azy5030 to add in: Torrent Web, BiglyBT, and FrostWire. I made the additional change requested by livings124.

In addition this also adds support for: HTTP Seed, aria2 (#532), and BitLord.
2021-04-27 20:47:33 -07:00
Norbert Papke d2c8137518 Fixes transmission/transmission#564
Per analysis by cfpp2p
(https://github.com/transmission/transmission/issues/564#issuecomment-377612224),
a duplicate search is not an error.
2021-02-06 10:56:09 -08:00
Charles Kerr 41f225df7b
Remove posix memalign (#1520)
* refactor: remove unnecessary func tr_valloc()

We're only using it in a handful of places, and none of them need the
kind of alignment that posix_memalign() provide. So we can drop a few
dozen lines by removing the portability wrapper.
2020-11-15 15:53:42 -06:00
Chrool cfce6e2e3a
configure anti brute force (#1447)
* add brute force configuration options
2020-11-14 12:43:42 -06:00
Charles Kerr 9d313a8816
sonarcloud warnings 9 (#1511)
* refactor: const correctness 

* refactor: fix some implicit conversions

* refactor: make local pointers const if their objects are not modified

* refactor: do not cast away const in torrent-cell-renderer

* refactor: remove call to deprecated gtk_icon_size_lookup_for_settings

* refactor: member functions that do not mutate their objects should be declared const

* chore: do not end comments with a semicolon
2020-11-08 21:31:02 -06:00
Charles Kerr 6b0408b320
refactor: fix more sonarcloud warnings (#1509)
* chore: simplify loop logic

* refactor: simplify isValidUtf8()

* refactor: use std::make_unique in Application::Application

* refactor: avoid raw pointers in DetailsDialog

* refactor: simplify DetailsDialog::refreshPref()

* refactor: make Application methods const

* refactor: reduce cognitive complexity of buildTrackerSummary()
2020-11-08 13:54:40 -06:00
Charles Kerr 7f147c65fb
refactor: fix more sonarcloud warnings (#1508)
* refactor: const correctness

* refactor: use getpwuid_r instead of getpwuid

* chore: simplify dict walking loop logic

* refactor: remove dead store assignment in announcer

* refactor: use std::make_shared
2020-11-05 16:46:21 -06:00
Charles Kerr e74b3bad8b
chore: fix more sonarcloud warnings (#1507)
* refactor: don't let realpath() alloc return memory

* chore: silence array-bounds-read warning

* chore: tidy memcmp of union
2020-11-03 21:23:53 -06:00
Charles Kerr 46cb0b5e65
refactor: sonarcloud warnings about overly-complex looping logic (#1503)
* chore: simplify loop logic
2020-11-03 18:59:19 -06:00
Charles Kerr 0bfbc3eba7
Sonarcloud warnings 4 (#1499)
* chore: fix some sonarcloud html warnings (e.g. deprecated attribute use)

* chore: uppercase literal suffixes

* chore: remove redundant casts

* chore: remove commented-out code

* chore: use qInfo() instead of std::cerr
2020-11-02 09:16:12 -06:00
Charles Kerr 73fdd722a7
Sonarcloud warnings 3 (#1498)
* chore: use ClassName:: for calling static methods

* chore: prefer to initialize member data in the class initializer
2020-11-01 19:13:32 -06:00
Charles Kerr 19e52d8b9a
chore: sonarcloud warnings 2 (#1496)
* fix "merge nested if" sonarcloud warnings

* fix explicit constructor warnings in qt client
2020-11-01 15:47:57 -06:00
Charles Kerr e59fe7daaf
fix: silence some sonarcloud warnings (#1493)
* refactor: add null ptr check in initPeerRow()

* refactor: add a nullptr gurad in icon_cache_get_mime_type_icon

* chore: silence two "break notreached" warnings

* chore: silence sonarcloud html warnings

* chore: silence sonarcloud uninitialized var warning

* chore: silence sonarcloud nullptr warning
2020-10-31 16:23:43 -05:00
Charles Kerr 61d221c8bb
Web client add licensing info (#1481)
* chore: add '@license' tag to web sources' comments

Webpack's tersify plugin looks for that JSDoc tag in order to decide
which comments to extract into the generated license file.

* chore: address sonarcloud.io warnings

* chore: address sonarcloud.io code smells

* fixup! chore: address sonarcloud.io warnings
2020-10-25 16:13:48 -05:00
Charles Kerr cd453764b1
feat: web client refresh (#1476)
Give the web client a major overhaul.

User-visible highlights include:

* Mobile is now fully supported.
* Added fullscreen support on mobile.
* Better support for dark mode.
* Added mime icons to the torrent list.
* Improved theme consistency across the app.

Maintainer highlights include:

* Updated code to use ES6 APIs.
* No longer uses jQuery UI.
* No longer uses jQuery.
* Use Webpack to bundle the Javascript, CSS, and assets together -- the entire bundle size is now 68K gzipped.
* Added eslint / prettier / stylelint tooling.
* Uses torrent-get's 'table' mode for more efficient RPC calls.
2020-10-23 20:04:25 -05:00
Charles Kerr f59118d1fe
feat: add torrent-get 'primary-mime-type' to RPC. (#1464)
* feat: add torrent-get 'primary-mime-type' to RPC.

This is a cheap way for RPC clients to know what type of content is in a
torrent. This info can be used to display the torrent, e.g. by using an
icon that corresponds to the mime type.

* use size_t for content byte count

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* explicit boolean expressions

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* use uint64_t for content byte counts

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* avoid unnecessary logic branches

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* explicit cast

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* refactor: add an autogenerated mime-type.h header

* chore: maybe fix the win32 FTBFS

* chore: add mime-types.[ch] to xcode

* Squashed commit of the following:

commit 4c7153fa48
Author: Mike Gelfand <mikedld@users.noreply.github.com>
Date:   Tue Oct 13 03:15:19 2020 +0300

    Remove autotools-based build system (#1465)

    * Support .git files (e.g. for worktrees, submodules)
    * Fix symlinks in source tarball, switch to TXZ, adjust non-release name
    * Remove autotools stuff

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
2020-10-13 10:33:56 -05:00
Mike Gelfand 4c7153fa48
Remove autotools-based build system (#1465)
* Support .git files (e.g. for worktrees, submodules)
* Fix symlinks in source tarball, switch to TXZ, adjust non-release name
* Remove autotools stuff
2020-10-13 03:15:19 +03:00
Charles Kerr a4dd67ae45
chore: fix some fixmes (#1449)
* chore: remove assertions that were flagged for removal

* chore: remove unneeded check

* refactor: move tr_peerIoAddrStr to net.h

* refactor: formatter API now takes size_t args

* chore: remove out-of-date FIXME comment

* refactor: cleanup logging win32 ifdefs
2020-09-13 16:43:29 -05:00
Charles Kerr 83cc7e04c8
Fix more coverity warnings (#1445)
cast intentionally-ignored function retval to null

remove superfluous JSON polyfill from web client.
2020-09-12 08:17:18 -05:00
Charles Kerr efaa66a920
fix: resolve some lgtm warnings (#1444)
* fix: warnings found by LGTM static analyzer
2020-09-11 16:07:45 -05:00
Charles Kerr d3323ddee0
fix: Coverity warnings (#1443)
* fix: coverity warnings
2020-09-10 18:50:46 -05:00
Charles Kerr e127b20c05
chore: fix compiler warnings (#1412)
* chore: fix compiler warnings
2020-08-27 18:41:26 -05:00
Mike Gelfand b7a8bd45b7 Reformat affected code after recent changes 2020-08-18 20:31:06 +03:00
Mike Gelfand 75458d6be3 Make use of TR_UNUSED macro where cast-to-void was used before 2020-08-18 14:34:49 +03:00
Mike Gelfand ff8d0dbf3b Switch from UNUSED macro to TR_UNUSED macro
Since there is no way to mark parameters as [potentially] unused in
standard C and when using MSVC compiler, use the widely accepted
cast-to-void approach instead.
2020-08-18 14:19:55 +03:00
Mike Gelfand 077f4d8d2b Require C11, switch to standard static_assert 2020-08-18 14:19:55 +03:00
Charles Kerr 677dc73eac
refactor: use GTest for running tests (#1383)
* refactor: use google-test on libtransmission tests
2020-08-11 13:11:55 -05:00
RobCrowston 6fee8724ab
Allow the operating system to set the size of the listen queue connection backlog. (#922)
* Allow the operating system to determine the size of the listen queue connection backlog.

* On Windows, set the listen queue backlog to SOMAXCONN, as advised in https://docs.microsoft.com/en-us/windows/desktop/api/winsock2/nf-winsock2-listen.
2020-07-28 22:14:07 -05:00
Vitaly Potyarkin 2da97b25fa
Lift 1024 open files limit (switch to curl polling API) (#893)
* Switch to new libcurl's polling interface

* Drop unused includes

* Use NOFILE limit value defined by operating system

* Avoid tight loops, ensure blocking for a small timeout

When there are no file descriptors to wait for, select() would work the
same as sleep(). But curl_multi_wait() returns immediately in this case,
so we need to add explicit wait to avoid tight loops.

Documentation: https://curl.haxx.se/libcurl/c/curl_multi_timeout.html
Discussion: https://curl.haxx.se/mail/lib-2018-03/0074.html

* Bump libcurl minimum version to 7.28.0
2020-07-28 21:38:27 -05:00
Pedro Scarapicchia Junior 5be8bd50f9
Check if log deep is enabled before tr_logAddDeep (#1329)
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2020-07-28 12:31:36 -05:00
Charles Kerr 00be8d00d7
refactor: make variant_headers reusable to qt app. (#1369)
* refactor: make variant_headers reusable to qt app.

Torrent.cc's `change()` template methods are generically useful to deal
with tr_variant wrangling, but previously were only used in Torrent.cc.
This PR moves them into a new API `VariantHelpers.h` for use by Prefs,
Session, TorrentModel, etc.
2020-07-26 23:30:58 -05:00
Charles Kerr fcda077cdd
chore: remove extraneous/default class destructors (#1317)
* chore: remove extraneous/default class destructors

* fixup! chore: remove extraneous/default class destructors
2020-06-15 09:30:29 -05:00
Mike Gelfand 0c10308e06
Add missing files that fail build from tarball (#1247)
Fixes: #1246, #1138
2020-05-23 02:13:59 +03:00
qu1ck 2fab317040
Add TR_TORRENT_LABELS to env variables available to scripts (#868)
* Add TR_TORRENT_LABELS to env variables available to scripts

* Add unit test for tr_strjoin

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2020-05-13 18:54:44 -05:00
Mingye Wang d7f2dee4e0
crypto-utils: do tr_rand_int without abs (#1198)
* crypto-utils: do tr_rand_int without abs

There is really not much point in trying to abs a random int when you can just interpret it as unsigned in the first place.

* fixup! trailing space

how did this get in here?

* fixup! unsigned int

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2020-05-11 20:34:03 -05:00
Tom Richards a82e728ad5
fix: memory leak in magnet parsing (#1222)
* Fix memory leak in magnet parsing

* Update libtransmission/magnet.c

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* Lint

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2020-05-11 19:57:06 -05:00
Charles Kerr fa6df52d58
chore: remove unused methods (#1207)
* chore: remove unused methods in qt client

* chore: remove unused libtransmission methods

* chore: remove unused gtk methods

* chore: remove more unused libtransmission methods

* chore: remove more unused code found by @reardonia
2020-05-11 17:20:46 -05:00
Charles Kerr 87c9287b6a
refactor: in tr_truncd(), use DBL_DIG in printf() (#1186)
Previously it was calculated from `log10(1.0 / DBL_EPISILON) - 1`;
however, there's no need to calculate it out when there's an ANSI
standard that already spells it out consisely.
2020-05-01 22:11:45 -05:00
Mike Gelfand 2123adf8e5 CVE-2018-10756: Fix heap-use-after-free in tr_variantWalk
In libtransmission/variant.c, function tr_variantWalk, when the variant
stack is reallocated, a pointer to the previously allocated memory
region is kept. This address is later accessed (heap use-after-free)
while walking back down the stack, causing the application to crash.
The application can be any application which uses libtransmission, such
as transmission-daemon, transmission-gtk, transmission-show, etc.

Reported-by: Tom Richards <tom@tomrichards.net>
2020-04-29 17:29:38 +03:00
Bogdan Vasiliev a6482b0061
GTK: behavior improvements of the torrent details window (#892)
* gtk: torrent details file-list default sort

* gtk: save torrent details window size

* gtk: torrent details window size & sort, code style

* gtk: torrent details window, conf.c dict fix

Co-authored-by: Charles Kerr <ckerr@github.com>
2020-04-27 16:34:02 -05:00
RobCrowston 6bb8b2e78a
Refactor tr_torrentFindFile2 (#921)
* Factor-out file seek in tr_torrentFindFile2.

* Update libtransmission/torrent.c

Co-Authored-By: RobCrowston <crowston@protonmail.com>

* Fix code style.

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
Co-authored-by: Charles Kerr <ckerr@github.com>
2020-04-27 15:07:01 -05:00
Guido Cella d3c55f2b0e Fetch metadata of stopped magnets 2019-12-15 17:18:11 +01:00
Charles Kerr 44fc571a67
feat: add editDate to RPC (#1056)
* feat: add tr_stat.infoDate to note tr_info changes

The last time during this session that any tr_info field changed
(e.g. trackers/filenames edited or magnet torrent got metadata).
RPC clients can monitor this to know when to reload fields which
don't usually change.
2019-11-12 17:13:42 -06:00
Charles Kerr c62cb35fd4
qt client speedups
* faster updating of trackers combobox.
* generate trackerDisplayNames just once per torrent
* refactor: cache torrent delegate's warning emblem
* refactor: change mainwin refresh debounce to 200ms
* refactor: do not store trackers, hosts in QVariant
* refactor: don't use `virtual` when it's not needed
* refactor: faster counting torrents-matching-filter
* refactor: faster tracker handling in filterbar
* refactor: improve json parser's prealloc heuristic
* refactor: make Torrent::hasError() faster
* refactor: remove redundant speed stats collection
* refactor: remove unnecessary tor->isQueued() calls
* refactor: use unordered containers where possible
* scale favicons only once, when adding to the cache
2019-11-11 19:37:05 -06:00
Charles Kerr 49fdd0b430
chore: update jsonsl parser snapshot (#1050)
source: https://github.com/mnunberg/jsonsl
2019-11-09 18:06:36 -06:00
Charles Kerr 96f76999aa
feat: add "table" format in torrent-get RPC (#1049)
* feat: add optional "format" arg to torrent-get RPC

If the "format" request was "objects" (default), "torrents" will be an
array of objects, each of which contains the key/value pairs matching
the request's "fields" arg. This is unchanged from previous versions.

If the format was "table", then "torrents" will be an array of arrays.
The first row holds the keys and each remaining row holds a torrent's
values for those keys. This format is more efficient in terms of JSON
generation and JSON parsing.
2019-11-09 17:02:23 -06:00
Charles Kerr abac811dd2
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings

* fix: implicit fallthrough warning

* fixup! fix: implicit fallthrough warning

* fix: disable warnings for 3rd party code

Since we want to leave upstream code as-is

* fixup! fix: disable warnings for 3rd party code

* fixup! fix: disable warnings for 3rd party code

* silence spurious alignment warning

Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: 90ac46f710/f/src/util/util_safealign.h (_35)

* fixup! fix: disable warnings for 3rd party code

* fixup! fix: implicit fallthrough warning

* make uncrustify happy

* remove uncrustify-test.sh

that's probably off-topic for this PR

* fixup! fix: __attribute__(__printf__) warnings

* Update libtransmission/CMakeLists.txt

Co-Authored-By: ckerr <ckerr@github.com>

* fixup! silence spurious alignment warning

* use -w for DISABLE_WARNINGS in Clang

* refactor: fix libtransmission deprecation warnings

* fix: pthread_create's start_routine's return value

This was defined as `void` on non-Windows but should have been `void*`

* chore: uncrustify

* fix: add DISABLE_WARNINGS option for SunPro Studio

* fix "unused in lambda capture" warnings by clang++

* fix 'increases required alignment' warning

Caused from storing int16_t's in a char array.

* fix net.c 'increases required alignment' warning

The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.

* make building quieter so warnings are more visible

* fixup! fix 'increases required alignment' warning

* Fix -Wcast-function-type warnings in GTK+ app code

https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.

GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.

Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.

In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).

* fixup! fix "unused in lambda capture" warnings by clang++

* fixup! fix "unused in lambda capture" warnings by clang++

* fix two more libtransmission compiler warnings

* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 11:27:03 -06:00
Tom Forbes 8d7fbb5d45 Increase the buffer size used in tr_moveFile (#933)
In some filesystems, including ones mounted on a network drive, using a small buffer size 
significantly hurts copy performance. Upping the buffer to 1024kb to increase copy performance.
2019-11-06 09:46:13 -06:00
Pavel Shlyak 2ef07517b6 Cleanup duplicates in clients.c (#991) 2019-10-21 08:20:40 -05:00
Mingye Wang bcf8128400 Unify/Modernize TOS to DSCP standards (#737)
* Unify/Modernize TOS to DSCP standards

The set of pre-named TOS values are now renamed to the latest DSCP
standards, with traffic classes and everything exciting. To keep
everything in the same place, a segment has been added to net.h to keep
the currently named values.

A result of these changes is that "lowcost" is probably no longer
harmless, as it now encourages the router to preferentially drop the
packages when bandwidth requires so. "lowdelay" is assigned to a pretty
high AF class for SIP and stuff. I am not sure at all about the
"throughput" assignment. I mean, the whole point of DSCP-fication is
translating from the old ToS bits to a more precedence-based notation,
and precedence is supposed to lie beside the old 4 ToS bits...

A funny interaction between the AFxy and the old ToS fields lies in
the old "reliability" (0x08) field. All odd numbers of y (1, 3 : low,
high) switches it on. If you spend 5 more minutes on it you can probably
come up with "pun" values that hold similar meanings in DSCP and
Prec/ToS.

By removing the IPv6 override, I should have kind of satisfied the #692
request.

Fixes: #692
2019-07-21 14:09:04 +03:00
Mike Gelfand eef4799388 Update Uncrustify config to 0.69 2019-07-15 02:30:41 +03:00
Mike Gelfand 35ed02a1fd Use explicit boolean conversions (follow-up) 2019-07-14 22:57:40 +03:00
Mike Gelfand 10cdd7f790 Use explicit boolean conversions 2019-07-14 16:25:07 +03:00
Mike Gelfand 16d385e4c7 Fixup code style 2019-07-13 23:02:27 +03:00
Mike Gelfand ec79767e5f Support OFD locks and missing flock 2019-07-13 22:53:04 +03:00
Mike Gelfand a3e4919385 Introduce `tr_str_is_empty` to relay intent better 2019-07-13 12:00:06 +03:00
Mike Gelfand bff188c2cf Fully cover `tr_metainfo_sanitize_path_component` 2019-06-24 06:32:38 +03:00
Mike Gelfand 99033b067d Sanitize suspicious path components instead of rejecting them
Apply the same rules on all the supported platforms to avoid issues
with network shares and alien file systems.

For future compatibility, explicitly mark adjusted paths as renamed.

Fixes: #294
2019-06-23 18:08:31 +03:00
Mike Gelfand 139f3a3f4b Add missing declaration for `tr_strcasestr` 2019-06-23 12:07:33 +03:00
Mike Gelfand f3968b7708 Load CA certs from system store on Windows / OpenSSL
Fixes: #446
2019-06-23 11:59:53 +03:00
LaserEyess 750589101a Parse session-id header case-insensitively (#765)
RFC 2616 defines headers as case-insensitive, so if rpc is behind a
reverse proxy that lowers the case of headers, transmission will not
parse them correctly.

A new wrapper function, `tr_strcasestr` is added to
libtransmission/utils.c to allow for comparisons of headers case
insensitively, and checks in cmake and autogen are included.
2019-03-17 17:37:52 +03:00
Mike Gelfand 5693e59256 Define each identifier in a dedicated statement
* MISRA C++:2008, 8-0-1 - An init-declarator-list or a member-declarator-list
  shall consist of a single init-declarator or member-declarator respectively
* CERT, DCL52-J. - Do not declare more than one variable per declaration
* CERT, DCL04-C. - Do not declare more than one variable per declaration
2019-03-17 09:15:35 +03:00
Mike Gelfand 97a0fed734 Remove side effects from right hand operands of && or ||
* MISRA C:2004, 12.4 - The right-hand operand of a logical && or || operator
  shall not contain side effects.
* MISRA C++:2008, 5-14-1 - The right hand operand of a logical && or ||
  operator shall not contain side effects.
* MISRA C:2012, 13.5 - The right hand operand of a logical && or || operator
  shall not contain persistent side effects
* CERT, EXP02-C. - Be aware of the short-circuit behavior of the logical AND
  and OR operators
2019-03-17 09:09:08 +03:00
Mike Gelfand 17307e7484 Extract assignments from expression
Assignments explicitly enclosed in parentheses are ignored.

* MISRA C:2004, 13.1 - Assignment operators shall not be used in expressions
  that yield a Boolean value
* MISRA C++:2008, 6-2-1 - Assignment operators shall not be used in
  sub-expressions
* MISRA C:2012, 13.4 - The result of an assignment operator should not be used
* MITRE, CWE-481 - Assigning instead of Comparing
* CERT, EXP45-C. - Do not perform assignments in selection statements
* CERT, EXP51-J. - Do not perform assignments in conditional expressions
2019-03-17 08:00:15 +03:00
Mike Gelfand d3b8982195 Uppercase the literal suffixes
* MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a
  literal suffix
* CERT DCL16-C. - Use "L," not "l," to indicate a long value
* CERT, DCL50-J. - Use visually distinct identifiers
2019-03-17 07:07:48 +03:00
Mike Gelfand 698bb2c418 Attempt to explain something to Coverity
I'm seeing 7 potentially false reported issues re. use of uninitialized buffer
data here. It seems that `read` function should be properly supported by
Coverity, but maybe it can't figure out the postconditions of it properly...
Walking in the dark here.
2019-03-13 05:32:35 +03:00
Mike Gelfand 10b0a280b1 Let compiler calculate static quark lenghts for us 2019-03-13 00:01:17 +03:00
Mike Gelfand 1442f8fded Fix build break from previous commit on old Clangs
Remove static assert altogether: it should have worked everywhere anyway,
otherwise there is no point.

Add a few casts here and there to ensure proper type for directory handle.
2019-03-10 19:52:27 +03:00
Mike Gelfand 36110e18c4 Fix build on E2K with LCC (patch by Michael Shigorin, ALT Linux) 2019-03-10 19:35:10 +03:00
Charles Kerr 309d97c578
fix: Coverity warnings (#842)
* Silence coverity CHECKED_RETURN on added.f load

The existing code behaved alright since added.f is optional.
However, by testing for success we can both silence the warning
and prevent a useless initialization of NULL/0 to added_f and
added_f_length.

* Silence coverity CHECKED_RETURN on added6.f load

ipv6 variant of previous commit.

* Silence coverity CHECKED_RETURN writing benc strs

saveStringFunc() gets the target string by calling tr_variantGetStr().
It previously didn't check to see if this function succeeded because
saveStringFunc() isn't reached without the type already being known.
However, checking the return value costs nothing and makes Coverity happy.

* Silence coverity CHECKED_RETURN on ut metadata

Like earlier few Coverity commits in this PR, we're handling optional
values by declaring stack locals set to the default (e.g. -1) and then
trying to read the variant.

Unlike the earlier commits, there is a two-part step to thise read:
checking for the metadata, then checking for the individual fields.
The earlier fixes' aproach -- e.g. initializing to -1 only if the reads
failed -- would involve new nested conditionals. I find the new complexity
to outweigh the benefit of removing the dead store, so in this case I'm
casting the return value to `(void)` to tell Coverity to shush.

* Silence coverity CHECKED_RETURN on scrape

Check the return value of tr_variantGetInt() when showing
seeder and leecher counts in transmission-show.

* Silence CHECKED_RETURN on rpc recently-active

When building a list of removed torrent IDs from variants, confirm that
we can read the IDs from the variants before adding them to the list.
I don't _think_ this would have failed before, but Coverity's right that
it's reasonable to add a safeguard here.

* fix: better fix to serializing benc strings

The approach in 33e2ece7e5 was
a little problematic: GetString() shouldn't fail here; but if
it somehow did, we still want to encode a zero-length benc string here.

* chore: make uncrustify happy
2019-02-18 22:38:24 +00:00
qu1ck 7aa12a025d Add labels feature (#822)
* applied changes from https://github.com/Elbandi/transmission/tree/elbandi/labels to official transmission repo

* Fix compilation errors

* Address review comments

Changed `tr_ptrArray* labels` to `tr_ptrArray labels`;
Removed tr_ptrArrayNew() tr_ptrArrayDup() tr_ptrArrayFree()
Use tr_strsep() to split string by delimiters
Update transmission-remote.1
Update rpc-spec.txt

* Fix warning, address comments

* Rebase, fix formatting and address comments

Use uncrustify to format changed files
Fix "const <type>" -> "<type> const"
Fix small comments

* Lock torrent for setLabels, check for duplicates

* Check for empty labels in daemon

* Stop on first error
2019-02-17 04:33:57 -05:00
Charles Kerr 2013772aad
feat: make multiscrape limits adaptive (#837)
* feat: make multiscrape limits adaptive

Previously hardcoded by TR_MULTISCRAPE_MAX. This change makes
that the initial value, then incrementally lowers the value
when multiscrapes get "req too long" style errors.

* fix: don't log personal announce url

* chore: treat HTTP 400 as scrape-too-long

* chore: copyediting

* chore: copyediting

* move 'const' to the right of the type

* make conditional tests explicitly boolean

* make 'key' const

* don't lookup a value we already have

* make an array for known too-big scrape error messages

* improved multiscrape throttle logging

* fix: multiscraping of low numbers of torrents

Handle the case of getting a 'multiscrape too big' error message
back even if the user fewer than TR_MULTISCRAPE_MAX torrents.

* uncrustify

* fix oops

* refactor: remove TR_MULTISCRAPE_MIN

Is there any reason to have a minimum batch size?

* make test explicit boolean

Co-Authored-By: ckerr <ckerr@github.com>

* improve declaration of too_long_errors

Co-Authored-By: ckerr <ckerr@github.com>

* make test explicitly boolean

Co-Authored-By: ckerr <ckerr@github.com>

* make test explicitly boolean

Co-Authored-By: ckerr <ckerr@github.com>

* improve looping decl of too_long_errors
2019-02-16 15:19:38 -05:00
Mike Gelfand 1d6d946388 Fixup some formatting leftovers 2019-02-16 10:50:37 +03:00
Mike Gelfand 82df3a87f4 Update to Uncrustify 0.68.1
Tweak a few rules in the process. Now all code in cli, daemon, gtk,
libtransmission, qt, and utils is properly formatted with no manual
intervention.
2019-02-15 09:21:48 +03:00
Charles Kerr 39d1a54fbd
Merge branch 'master' into update-resume-file-before-invoking-torrent-scripts 2019-02-06 02:00:47 -05:00
Charles Kerr 5082393d92 address dirty/save sequencing issue in prev commit 2019-02-02 14:49:53 -06:00
Charles Kerr b04f2df299
Merge pull request #741 from Artoria2e5/parseline-cidr
Support CIDR-notated blocklists
2019-02-01 23:38:48 -06:00
Charles Kerr 08f5a0fdaa fix: update the resume file before running scripts
This is useful if the client script is going to access
the .resume file. Ensuring an up-to-date .resume file
means that user scripts will be able to access it.
2019-02-01 21:59:17 -06:00
Peter Dave Hello 7a0d2e63c7 Refactor shell scripts with syntax and styling fixes 2019-01-16 03:22:29 +08:00
Mingye Wang 847b43ffd3 (squash later) test rule count 2018-10-17 10:26:05 -04:00
Mingye Wang 94ee776113 (squash later) blocklist cidr endianness 2018-10-17 09:41:19 -04:00
Mingye Wang f61306f65f (squash later) fix pflen handling in cidr 2018-10-14 12:44:01 -04:00
Mingye Wang b3129591db Support CIDR-notated blocklists
This commit adds a new blocklist line format, namely individual IPv4
CIDR ranges separated by newlines. Text put after each entry is ignored
by sscanf, so feel free to put any kind of comments there.

Fix #230.
2018-10-13 17:23:45 -04:00
Mike Gelfand a53bae2849 Fix file-test on Win32 due to file/dir symlinks difference 2018-09-04 01:06:21 +03:00
Mike Gelfand c951848a5b Merge branch '2.9x' 2018-05-01 22:44:51 +03:00
userwithuid 873006c373 fix logic for setting the curl ca bundle file
we do not want to delete the system default by setting this to NULL...
2018-04-25 08:21:50 +00:00
Mike Gelfand 69d9afd75a Adjust CFBundleVersion format to fix Sparkle update check
Set the first version component to be the same as the last Subversion-based
release build version and add two more components (major and minor version
numbers). To allow for nightly build updates this should probably include
another component (e.g. build timestamp), but we're not there yet.
2018-04-17 13:25:49 +03:00
geertjan cc0b931431 Fix setting the ETA timestamps
Field etaDLSpeedCalculatedAt was set too early, causing the condition
following it to always be false. The same for etaULSpeedCalculatedAt.
2018-04-06 22:52:29 +03:00
Mike Gelfand 444f15edf8
Merge pull request #522 from gjalsem/master
Fix setting the ETA timestamps
2018-04-06 22:49:27 +03:00
Mike Gelfand ab4d707305
Merge pull request #528 from neheb/patches
Fix compile errors for 2.9x
2018-04-06 22:34:11 +03:00
Bernard Spil 06a1644e29 Fix build with LibreSSL 2.7
LibreSSL 2.7 adds OpenSSL 1.1 API

See also: https://bugs.freebsd.org/226953
Signed-off-by: Bernard Spil <brnrd@FreeBSD.org>
2018-04-06 22:17:41 +03:00
Niklas Haas 11d29ff62d LibreSSL compatibility
This seems to be the idiomatic way to fix libressl compatibility issues,
judging by what most other open source projects seem to be doing.

I've confirmed that transmission builds with libressl for me after this
patch is applied.
2018-04-06 22:16:26 +03:00
Mike Gelfand 9d96f87ec3 Fix coding style and building with !TR_LIGHTWEIGHT 2018-04-06 22:15:22 +03:00
Bernard Spil bdffe25b42 Fix build with LibreSSL 2.7
LibreSSL 2.7 adds OpenSSL 1.1 API

See also: https://bugs.freebsd.org/226953
Signed-off-by: Bernard Spil <brnrd@FreeBSD.org>
2018-04-01 22:39:09 +02:00
Mike Gelfand 4d5fe6ede9 Add support for mbedtls (formely polarssl) 2018-02-23 20:46:39 -08:00
geertjan 23e469a6b2 Fix setting the ETA timestamps
Field etaDLSpeedCalculatedAt was set too early, causing the condition
following it to always be false. The same for etaULSpeedCalculatedAt.
2018-02-19 21:06:34 +01:00
Mike Gelfand 96926a8337 Update DHT library to 0.25
Fixes: #508
2018-02-10 11:35:14 +03:00
Rosen Penev a3ef28bd68 Set compression to curl defaults
While zlib is mandatory for transmission, it is not mandatory for curl.

A libcurl that has been compiled with no support for zlib will return no data if compressed responses are set to on.

In the basic case this prevents the port checking functionality from working properly. It also prevents web seeding from working as well.
2018-01-31 20:59:01 -08:00
Mike Gelfand 94be7dbd9b Merge branch '2.9x' 2018-01-25 03:07:52 +03:00
Mike Gelfand 4b6529d883 Don't crash if path passed to tr-create doesn't exist 2018-01-24 23:45:13 +03:00
Mike Gelfand 3106675261 Fix UNC paths resolution on Windows
While resolved paths always contain the	`\\?\` prefix, it's not	always
correct	to strip only those 4 chars. In	case of	UNC paths, the prefix
is actually a bit longer (`\\?\UNC\`) and needs	to be replaced with `\\`
instead.

Failing	to do so results in invalid paths, e.g.	`\\Host\Share\File` becomes
`UNC\Host\Share\File` which totally wrong.
2018-01-24 23:45:08 +03:00
Mike Gelfand 6da6629887 Add unit tests uncovering improper UNC paths resolution
While resolved paths always contain the `\\?\` prefix, it's not always
correct to strip only those 4 chars. In case of UNC paths, the prefix
is actually a bit longer (`\\?\UNC\`) and needs to be replaced with `\\`
instead.

Failing to do so results in invalid paths, e.g. `\\Host\Share\File` becomes
`UNC\Host\Share\File` which totally wrong.
2018-01-24 23:12:17 +03:00
Mike Gelfand 7f008edab6 Improve version.h file generation
Store full revision hash in REVISION file. Write fixes 10 chars of revision
hash to version.h. Use `#pragma once` in version.h. Support getting revision
from TeamCity environment variable (similar to Jenkins).
2018-01-23 21:59:09 +03:00
Mike Gelfand b875e79f3d Replace SVN and SCM with VCS everywhere 2018-01-23 21:58:33 +03:00
Mike Gelfand 99c9b90965 Fix memory leak in `tr_dhtInit` in failure condition
Fixes: #482
2018-01-23 21:20:30 +03:00
Sebastian Andrzej Siewior 22bde650ea transmission: build against openssl 1.1.0
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2018-01-19 02:44:12 +03:00
Mike Gelfand c0c2ba0b13 Make host validation not depend on CSRF being enabled (see #468) 2018-01-17 23:38:12 +03:00
Mike Gelfand 90686f30ce Support IPv6 addresses when whitelisting hosts (see #468) 2018-01-17 23:32:14 +03:00
Mike Gelfand c22e687b51 Simplify `tr_ssha1_matches` logic
Gets rid of needless heap memory allocations and copying. Convert SHA1 hash
to hex in-place.

Fixes: #141
2018-01-17 01:17:50 +03:00
Mike Gelfand 1d04ea65d3 Don't switch trackers while announcing
Fixes: #297
2018-01-17 01:09:07 +03:00
Mike Gelfand aa2730d47c Switch to HTTPS links, adjust wiki links where possible
Fixes #39
2018-01-16 01:12:59 +03:00
Tavis Ormandy 440f03e9ad mitigate dns rebinding attacks against daemon 2018-01-16 01:12:56 +03:00
Mike Gelfand 7cc4cfbe7b Abort handshake if establishing DH shared secret fails
Fixes #27
2018-01-15 23:51:44 +03:00
Tavis Ormandy cf7173df93 mitigate dns rebinding attacks against daemon 2018-01-15 23:31:25 +03:00
Mike Gelfand ffcca3964d Adjust test names in CMake to be in line with autoconf ones 2017-12-02 17:58:15 +03:00
Mike Gelfand fae6b40002 Fix memory leaks in subprocess test 2017-12-02 17:57:11 +03:00
Mike Gelfand 30c7c05cbb Refactor completion scripts execution
There're still a few issues here and there, but overall I believe it's now
better than it was before.
2017-11-28 10:03:08 +03:00
Mike Gelfand 5b29fe1556 Ensure include guard is the first non-comment line 2017-11-14 23:21:28 +03:00
Mike Gelfand ede21744d3 Fix potential NULL pointer dereference introduced by last commit 2017-10-31 10:01:06 +03:00
Mike Gelfand 474aabbbc4 Take another approach to creating intermediate dirs on *NIX
Walk up one level at a time until the directory creation succeeds, then go
back down one level at a time. This reduces the number of operations in the
most common case (when directory already exists).
2017-10-30 10:23:18 +03:00
Dhiru Kholia 874df139e1 Add Peer ID for Baidu Netdisk
Baidu Netdisk uses Azureus-style Peer ID with "-BN" prefix.
2017-08-26 11:11:31 +05:30
bobbyhopere cb6047ba3c All modifications suggested by mikedld 2017-08-13 13:53:41 +02:00
bobbyhopere 5f25e3be7f anti-brute force for RPC Server 2017-08-12 16:36:43 +02:00
Mike Gelfand 6410a460ea Merge pull request #360 from clyang/master
Improving ToS on IPv6 connections
2017-08-08 18:32:44 +03:00
Dhiru Kholia e1c8ec41f8 Add Peer ID for Folx
Based on experiments with Folx version 5.2.1.13690 running on macOS
Sierra.

Folx uses Azureus-style Peer ID with "-FL" prefix.
2017-08-05 12:29:16 +05:30
clyang 81c9653383 Improve ToS on IPv6 connections 2017-08-03 06:30:54 +03:00
Dhiru Kholia 8c87a58cdd Add Peer ID for Free Download Manager (FDM)
Based on experiments with FDM 5.1.32 running on Windows 10.

FDM uses Azureus-style Peer ID with "-FD" prefix.
2017-08-02 20:33:41 +05:30
Mike Gelfand bb4741002f Go back to using hash as base name for resume and torrent files
The format introduced in TRAC-394 is nice but brings its own issues (e.g.
TRAC-4189, #122). I'm okay with a bit of grepping myself if it makes the
experience better for end users.

Using hashes results in filenames well under 255 bytes limit on some
filesystems. If even that will not be enough, I'd suggest reporting the
issue elsewhere.

Fixes: #122
2017-07-26 21:32:26 +03:00
Mike Gelfand 55b41c9015 Patch up file test to allow for a bit of time discrepancy
Since one cannot really compare system time to filesystem time (see e.g.
https://lkml.org/lkml/2017/3/30/809), allow for 1 second error to avoid
(or at least minimize) random test failures.
2017-07-21 00:45:30 +03:00
Simon Wells 44411d719c Change TR_CURL_SSL_VERIFY to TR_CURL_SSL_NO_VERIFY
use secure by default and change the env var to match curl -k behaviour

Closes: #179
2017-07-16 20:48:44 +03:00
Mike Gelfand 580c5e4166 Rename `tr_sys_file_prefetch` to `tr_sys_file_advise`
New function now supports two flags: will need and don't need.
2017-07-08 16:09:37 +03:00
Mike Gelfand 28c872af1e Change `tr_sys_file_prefetch` behavior a bit
Return true by default. Only return false if we did in fact perform some
action and it failed.
2017-07-08 12:51:36 +03:00
Mike Gelfand 8c88e8bba0 Change torrent location even if no data move is needed
This helps when old and new location point to the same place but the actual
path differs (i.e. one of the paths is a symlink).

Fixes: #35
2017-07-06 21:46:32 +03:00
Mike Gelfand a86266d3c2 Don't switch trackers while announcing
Fixes: #297
2017-07-04 21:22:26 +03:00
Mike Gelfand d46fdda9ea Correct "annouce" spelling
Fixes: #303
2017-07-02 19:18:02 +03:00
Mike Gelfand 27b6884408 Move uTP timer to session struct 2017-07-02 13:31:33 +03:00
Mike Gelfand 87c9596305 Fix a couple more implicit boolean expressions 2017-07-02 13:26:26 +03:00
Mike Gelfand 18aabdeb06 Introduce peer socket struct to improve readability 2017-06-28 18:50:05 +03:00
Mike Gelfand 74548e01b6 Remove obsolete comment as we're using C99 now 2017-06-28 18:50:05 +03:00
Mike Gelfand 13bbaeec76 Use field initializers for readability 2017-06-24 13:30:33 +03:00
Aleksej Lebedev b7b1d2475e Fixed platform-quota.c for DragonFly. The patch is taken from dports. 2017-06-19 19:27:05 +03:00
Mike Gelfand f701d501a8 Move generic macros to a separate tr-macros.h file 2017-06-18 17:11:20 +03:00
Mike Gelfand deea6fc6a2 Bring assertions closer to the beginning of blocks 2017-06-13 07:44:09 +03:00
Mike Gelfand 98695fe3c1 Introduce our own assertion macros with finer control 2017-06-08 10:24:12 +03:00
Mike Gelfand 5f7bc801c8 Make use of new checking capabilities in unit tests 2017-05-30 20:56:12 +03:00
Mike Gelfand 3d0b06ca0f Add generic `check_mem` (libtest) 2017-05-30 20:09:19 +03:00
Mike Gelfand 2a7cf67913 Add generic `check_bool`, extend `check` to be more informative (libtest) 2017-05-30 19:21:14 +03:00
Mike Gelfand b1b5a577cf Transform `check_ptr_eq` into generic `check_ptr` (libtest) 2017-05-30 17:51:50 +03:00
Mike Gelfand 437904198e Transform `check_uint_eq` into generic `check_uint` (libtest) 2017-05-30 17:51:50 +03:00
Mike Gelfand 9c3c6f11e0 Transform `check_int_eq` into generic `check_int` (libtest) 2017-05-30 17:51:50 +03:00
Mike Gelfand 14c30119d4 Transform `check_str_eq` into generic `check_str` (libtest) 2017-05-30 17:51:46 +03:00
Mike Gelfand 341b778099 Continue running other test-cases even if one fails (libtest) 2017-05-30 17:44:51 +03:00
Mike Gelfand c071f824ec Pass `(u)intmax_t` instead of `(u)int64_t` to `check_(u)int_eq` (libtest) 2017-05-30 17:44:47 +03:00
Mike Gelfand 7a238e7c65 Rename `check_streq` to `check_str_eq` to be in line with other macros (libtest) 2017-05-30 17:44:42 +03:00
Mike Gelfand 432d573f2c Fixup 2321bc3fad (unintended logic change, spotted by cfpp2p in #297) 2017-05-29 08:50:40 +03:00
Mike Gelfand f27596238d Include stdbool.h unconditionally
All the compilers should provide the header file by now. Remove `tr_isBool`
sanity checks along the way as compiler should guarantee that bool (_Bool)
values are 0 or 1 and nothing else.
2017-05-24 22:53:06 +03:00
Mike Gelfand 295d3359b2 Little bastards keep popping up here and there :( 2017-05-23 22:17:17 +03:00
Mike Gelfand 501be27972 Reduce code duplication in logging macros 2017-05-22 23:20:28 +03:00
Dhiru Kholia dda33afbe0 Add Peer ID for PicoTorrent
Based on information from https://github.com/picotorrent/picotorrent and
http://www.picotorrent.org/.

PicoTorrent uses Azureus-style peer ID: -PI-. Example: -PI0091- (major:
0, minor: 09, patch: 1).
2017-05-21 12:30:47 +05:30
Mike Gelfand 82722476aa Fix some issues reported by Coverity 2017-05-20 23:31:56 +03:00
Mike Gelfand 8f3cb1c68d Wrap sizeof arguments in braces 2017-05-20 19:29:23 +03:00
Mike Gelfand 6303bb2247 Disable part of mmap test on OpenBSD that depends on UBC 2017-05-20 13:34:23 +03:00
Niklas Haas 4d7446e477
LibreSSL compatibility
This seems to be the idiomatic way to fix libressl compatibility issues,
judging by what most other open source projects seem to be doing.

I've confirmed that transmission builds with libressl for me after this
patch is applied.
2017-05-20 07:16:53 +02:00
Mike Gelfand 6b0229a546 Fix some issues reported by Coverity 2017-05-16 21:37:00 +03:00
Mike Gelfand 1e3d20422a Reduce for loop variables scope 2017-05-14 01:38:31 +03:00
Mike Gelfand 6d5e48f9e2 Fix some more off-by-one errors on last piece
See: TRAC-4037 and e2584b04ff
2017-05-09 14:23:25 +03:00
Piotr Drąg ccabc01900 lib: fix translator comment extraction
gettext won’t pick up a comment if it’s
not exactly one line above the string.
2017-05-02 21:22:15 +02:00
Mike Gelfand 87220d44a5 Fix FTBFS on Windows (oops!) 2017-05-01 19:08:30 +03:00
Mike Gelfand 14370e5353 Fix a number of other style inconsistencies met along the way (part 2) 2017-05-01 18:47:49 +03:00
Mike Gelfand e1d53855f4 Avoid declaring multiple variables on the same line 2017-05-01 18:46:41 +03:00
Mike Gelfand 1bc247c105 Merge pull request #161 from slokhorst/rpc-ipv6
Allow the RPC server to listen on an IPv6 address
2017-05-01 13:31:14 +03:00
Mike Gelfand 6a74bd438c Announce INT64_MAX as size left if the value is unknown
This helps with trakers like Amazon S3 where signed type is used but
negative values aren't accepted.

Fixes: #250
2017-05-01 12:33:55 +03:00
Mike Gelfand ac4fa04277 Announce -1 as size left if the value is unknown
Fixes: #250
2017-04-30 21:18:02 +03:00
Mike Gelfand efaa9d0ddc Compare system function return value to a specific value indicating the error 2017-04-30 19:47:18 +03:00
Mike Gelfand b342d134cb Merge pull request #256 from kholia/Xfplay
Add Peer ID for Xfplay torrent client
2017-04-30 19:43:49 +03:00
Mike Gelfand fbd8d4c79f Fix a number of other style inconsistencies met along the way 2017-04-30 19:33:55 +03:00
Mike Gelfand a762c770f2 Make conditional expressions explicitly boolean 2017-04-30 19:26:01 +03:00
Dhiru Kholia e970d7e546 Add Peer ID for Xfplay torrent client
This is based on the following resources,

http://www.xfplay.com/history.html
https://down.xfplay.com/xfplay9.994.exe
https://down.xfplay.com/xfplay9.992.exe
https://down.xfplay.com/xfplay9.991.exe
https://down.xfplay.com/xfplay9.99.exe
http://q.xfplay.com/
2017-04-29 12:40:55 +05:30
Sebastiaan Lokhorst ac661ff099 Allow the RPC server to listen on an IPv6 address 2017-04-26 17:46:36 +02:00
Mike Gelfand 6a15bc6742 Fix mount points enumeration (platform quota) on Solaris
Per documentation, `getmntent` returns 0 on success and -1 on error.
2017-04-22 21:42:44 +03:00
Mike Gelfand 4f9d9ad92b Code style change leftovers
For some reason, GTK client wasn't fully processed. All the rest of changes
are mostly in comments.
2017-04-21 10:40:57 +03:00
Mike Gelfand dadffa2c0f Align type qualifiers to the right (code style)
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".
2017-04-20 19:53:20 +03:00
Mike Gelfand d7930984ef Adjust uncrustify config, reformat all but Mac client
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.
2017-04-20 10:01:22 +03:00
Mike Gelfand 0f75e64d71 Detach the thread from within itself to avoid race condition
Fixes: #188
2017-02-23 00:07:39 +03:00
neheb 944382a62e Add TCP_FASTOPEN support
Should make transmission slightly faster.
2017-02-19 12:54:01 +03:00
Edward Betts 9e1c76a50f fix spelling mistake 2017-02-01 10:14:11 +00:00
Mike Gelfand 1cc67b31dd Use PRIdMAX instead of TR_PRI_SOCK to accomodate intltool 2017-01-27 04:50:14 +03:00
Mike Gelfand c1f08edf79 Fix memory leaks found by GCC's -address=sanitize (reported by milloni)
Fixes: #56
2017-01-17 23:55:34 +03:00
Mike Gelfand 67bda2dcb8 Handle two more cases where dirname/basename may have returned NULL (adds to 91f8ceb20d) 2017-01-17 02:22:31 +03:00
Mike Gelfand fd93316466 Improve version.h file generation
Store full revision hash in REVISION file. Write fixes 10 chars of revision
hash to version.h. Use `#pragma once` in version.h. Support getting revision
from TeamCity environment variable (similar to Jenkins).
2017-01-15 00:54:56 +03:00
Mike Gelfand 3375b22b23 Simplify `tr_ssha1_matches` logic
Gets rid of needless heap memory allocations and copying. Convert SHA1 hash
to hex in-place.

Fixes: #141
2017-01-09 14:15:07 +03:00
Mike Gelfand 15625de3c7 Extend SSHA1 test to check for predefined matches
Reduce number of test iterations to 4K along the way to shorten execution
time.
2017-01-09 14:12:17 +03:00
Mike Gelfand 4179a623d5 Interrupt verification ASAP if torrent is being removed 2016-12-31 14:23:06 +03:00
Mike Gelfand 0ac657c5f1 Fix up rename test to avoid random use-after-free failures 2016-12-25 19:44:38 +03:00
Mike Gelfand 3cda09ea81 Fix up rename test to avoid random duplicate torrent failures 2016-12-24 21:24:50 +03:00
Mike Gelfand 88505c345f Allow for different-cased "nan" value returned by tr_truncd 2016-12-24 20:20:55 +03:00
Mike Gelfand 448d8f39f6 CMake support for Solaris 2016-12-24 20:16:54 +03:00
Mike Gelfand 193d68cc5c Move tr_metainfoFree call higher per review comment 2016-12-09 22:01:58 +03:00
seiyap70 8541d74793 free the info resource if failed
free the info resource if failed
2016-11-07 14:07:56 +08:00
Mike Gelfand d8dd6f9c75 Merge pull request #60 from milloni/strncmp-instead-of-memcmp
Use strncmp instead of memcmp to avoid out-of-bounds reads
2016-11-02 23:13:25 +03:00
Markus Amalthea Magnuson 5b9ba3be0d HTTPS links for trac, forum, portcheck, and build subdomains. 2016-11-02 20:50:22 +01:00
Mike Gelfand 71af7be04f Improve support for wolfssl (formely cyassl) 2016-10-26 22:27:20 +03:00
Mike Gelfand 7f94c8df6c Add support for mbedtls (formely polarssl) 2016-10-26 22:27:20 +03:00
Maciej Wolny 69c33d0e18 Fix signedness related warnings 2016-10-20 20:27:55 +02:00
Maciej Wolny c6ad5bd36c Go back to using memcmp in libtransmission/net.c 2016-10-20 17:35:46 +02:00
Mike Gelfand 0390684bc4 Merge pull request #42 from wbx-github/master
uClibc-ng since 1.0.18 has sys/quota.h synced with GNU libc
2016-10-19 21:01:06 +03:00
Waldemar Brodkorb bae138ca22 uClibc-ng since 1.0.18 has sys/quota.h synced with GNU libc 2016-10-19 19:33:35 +02:00
Mike Gelfand eda26f7590 Make sure `tr_sha1` calls pass lengths as int
This fixes inability to authenticate with password-protected session, and
a few more issues it seems.
2016-10-18 00:05:03 +03:00
Maciej Wolny 3a1730495d Use strncmp instead of memcmp to avoid out-of-bounds reads 2016-10-05 16:19:31 +02:00
Mike Gelfand 17fb783c50 Add session-id.{c,h} to autoconf and Xcode builds 2016-09-27 21:36:01 +03:00
Mike Gelfand 661e2b513d Return session ID as part of "session-get" response 2016-09-27 21:18:36 +03:00
Mike Gelfand ff73e65069 Handle "fields" argument in "session-get" RPC request
If "fields" array is present in arguments, only return session fields
specified. Otherwise return all the fields as before.
2016-09-27 21:18:32 +03:00
Mike Gelfand b82f6009dd Maintain lock file(s) corresponding to session ID 2016-09-27 20:53:10 +03:00
Mike Gelfand 26b0a041cc Factor out session ID into a standalone entity 2016-09-21 22:29:56 +03:00
Mike Gelfand 4c00df9463 Abort handshake if establishing DH shared secret fails
Fixes #27
2016-09-18 14:01:00 +03:00
Mike Gelfand 8c8386a7f3 Fix coding style and building with !TR_LIGHTWEIGHT 2016-09-07 01:09:04 +03:00
Sebastian Andrzej Siewior f91cf5ad8c transmission: build against openssl 1.1.0
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2016-09-06 00:11:17 +02:00
Mike Gelfand 2248d3670f Get rid of $Id$ SVN keywords in source files 2016-09-02 23:10:15 +03:00
Mike Gelfand 1b81bb7682 Replace SVN and SCM with VCS everywhere 2016-09-02 22:21:00 +03:00
Mike Gelfand 076fd29098 #6071: Fix typo in comment 2016-04-23 16:21:39 +00:00
Jordan Lee 7cd2d10d00 crypto.h and crypto-utils.h can't use #pragma once, it breaks our name munging in crypto-test-ref.h 2016-03-29 19:02:26 +00:00
Jordan Lee c1abfe87c8 maybe fix double-include of crypto.h / crypto-utils.h in crypto-test 2016-03-29 17:18:50 +00:00
Jordan Lee 1af60ad6ad use '#pragma once' instead of #ifndef..#define..#endif guards 2016-03-29 16:37:21 +00:00
Jordan Lee 77b5105ea0 fix bad TR_DEPRECATED macro on clang :P 2016-03-29 16:01:41 +00:00
Jordan Lee 8d38442cc1 give a useful definition of TR_DEPRECATED on msvc as well 2016-03-29 15:47:29 +00:00
Jordan Lee 5fbd24fda5 fix a handful of minor compiler warnings, mostly in the unit tests, eg field width shortening or implicit signed/unsigned conversions 2016-03-29 03:04:54 +00:00