Commit Graph

276 Commits

Author SHA1 Message Date
HDVinnie
777969b9b4 fix: checkMinInterval function
- phpredis support
2023-10-06 01:06:16 -04:00
HDVinnie
77bec4c06c update: phpredis support 2023-10-05 22:46:12 -04:00
Roardom
361a9b3c0f fix: announce torrent cache misses 2023-09-23 22:07:56 +00:00
HDVinnie
95aadb2e93 fix: TrackerException 2023-09-11 19:22:04 -04:00
Roardom
f055335aec fix: announce torrent cache busting
We don't select the info_hash on the torrent. We have to take it from the validated query parameter instead.
2023-09-10 23:44:00 +00:00
HDVinnie
d52b9e2815 Merge pull request #3131 from Roardom/optimize-process-announce-loop
(Update) Optimize process announce peer loop
2023-09-10 00:51:46 -04:00
Roardom
7e32ff041b update: optimize process announce peer loop
Only loop over once instead of once for each property, check both properties in each iteration, and break early.
2023-09-10 04:47:51 +00:00
HDVinnie
a8c5bbfef4 Merge pull request #3130 from Roardom/fix-announce-user-update
(Fix) Announce user uploaded/downloaded update
2023-09-10 00:45:21 -04:00
Roardom
10dfb5ffef fix: announce user uploaded/downloaded update
Bug caused from 31e7b73549
2023-09-10 03:21:59 +00:00
Roardom
88f8a67d1b update: optimize announce return peer loop
Only loop through the peers when absolutely needed. Don't loop through more peers after we reach the limit. Do logic before looping instead of inside it.
2023-09-10 02:05:43 +00:00
HDVinnie
e04cb67336 Merge pull request #3128 from Roardom/dont-convert-ip-format
(Update) Don't convert ip format
2023-09-09 20:40:51 -04:00
HDVinnie
4c32ed6d63 Merge pull request #3127 from Roardom/fix-inactive-peer-counts
(Fix) Decrease torrent seeders/leechers when a peer is marked inactive
2023-09-09 20:40:25 -04:00
HDVinnie
d3901b0ef0 Merge pull request #3124 from Roardom/increase-cache-expiry
(Update) Increase announce cache expiry
2023-09-09 20:39:14 -04:00
Roardom
c092c30a3e update: don't convert ip format
Bittorrent, MySQL, and Linux (and therefore PHP) all store IP addresses in network byte order, so we don't have to convert them.
2023-09-10 00:13:24 +00:00
Roardom
e62d342cb3 fix: decrease torrent seeders/leechers when a peer is marked inactive 2023-09-09 21:13:00 +00:00
Roardom
f05da6047c update: increase announce cache expiry
Cache busting seems to be working enough that we probably don't need this fail-safe, but we can bump it up a bit at least. The key and value (<50 bytes for non-existant values) are small enough that we don't have to worry about running out of memory with the current rate limit in case of a few malicious users.

Co-authored-by: HDVinnie <hdinnovations@protonmail.com>
2023-09-09 06:12:39 +00:00
Roardom
ecb60fd4a2 remove: unneeded binary string encoding in announce
When the queue system was used, Laravel's queue system required all variables to be json-encodable, which meant encoding binary strings in either hex or base64. Now that we have inlined the queue, we can use the binary data directly without encoding.
2023-09-09 05:16:56 +00:00
HDVinnie
97c44d10e6 Merge pull request #3122 from Roardom/manual-announce-bencoding
(Update) Manually bencode the announce response
2023-09-08 05:23:42 -04:00
Roardom
285642f26e fix: ci 2023-09-08 03:04:26 +00:00
Roardom
9345ad6bb3 update: manually bencode the announce response
Performance optimization compared to recursively encoding one character at a time using the Bencode helper function.
2023-09-08 01:46:58 +00:00
Roardom
8707d7f42d update: remove throw_if helper overhead in announce 2023-09-07 23:23:18 +00:00
Roardom
bc94c0ed5e update: cache torrents in announce by infohash 2023-09-07 03:37:09 +00:00
HDVinnie
b02991b284 Merge pull request #3117 from Roardom/treat-stop-differently-for-min-announce-enforcement
(Update) Delete min interval timer if stopped event
2023-09-05 21:03:18 -04:00
Roardom
f622a356b5 update: delete min interval timer if stopped event 2023-09-06 00:28:39 +00:00
Roardom
cb123390f3 fix: don't upsert peer connectable status
We calculate these asynchronously now.
2023-09-05 21:48:58 +00:00
Roardom
600f1ef3b0 fix: missing required selected columns
We need the `uploaded` and `downloaded` columns for the history calculations
2023-09-05 21:48:07 +00:00
HDVinnie
94cab6ac8f remove: announce dead code 2023-09-04 18:25:15 -04:00
HDVinnie
41417d8c07 Merge branch '7.x.x' into pr/3114 2023-09-04 12:35:04 -04:00
Roardom
cfa417de3b update: inline announce processing job into announce 2023-09-04 10:02:44 +00:00
Roardom
d7287b86cf fix: min interval enforcement
Arguments are in the wrong order
2023-09-01 07:12:33 +00:00
HDVinnie
f510d77cbb Merge branch '7.x.x' into announce-interval 2023-08-31 18:48:02 -04:00
HDVinnie
624e4f2b68 update: announce controller
- remove dead timestamp code
- decrease mix / max intervals
- simplify checkMinInterval function
2023-08-31 18:41:43 -04:00
HDVinnie
ffaa3452b1 update: announce controller
- return times_completed metric to user client
2023-08-31 18:35:18 -04:00
Roardom
82a368e25c update: improve peer min interval enforcement
Now that peers are only updated every 5 seconds, we need to cache their last announce timestamp in redis instead of relying on the updated_at timestamp in the database
2023-08-30 12:48:35 +00:00
Roardom
8127734979 fix: various larastan command issues 2023-08-25 07:58:38 +00:00
Roardom
21de4f2047 fix: race condition in download slot limit 2023-08-13 11:12:13 +00:00
HDVinnie
9d2613e7b0 Merge pull request #2988 from Roardom/lowercase-event
(Update) Lowercase the announce event at beginning
2023-07-31 21:49:23 -04:00
Roardom
9ed19c1593 update: lowercase the announce event at beginning
No need to keep converting it.
2023-07-30 01:20:11 +00:00
Roardom
c554e29abe update: keep peers that stopped announcing for longer
Now that we upsert history records without first selecting them, we can't rely on storing a peer's last uploaded/downloaded values in the history record to determine the user's uploaded/downloaded delta between the last announce. If a user has internet issues for a brief period of time but their client continues working, then their change of upload/download between the two announces needs to be kept track of. This is usually kept track of in the peer record, but if the peer is deleted after 2 hours of not announcing, then their last uploaded/downloaded data is deleted with it. We previously stored this data in the history table to handle such cases but this became erroneous if the user had multiple peers on a torrent. This new solution keeps the peers in the database for 2 days before concluding that the peer isn't coming back and deletes the peer permanently. After which point, a new peer will be created and an assumption is made that they uploaded/downloaded 0 data within their downtime.
2023-07-29 05:12:35 +00:00
Roardom
b5246a0e80 Revert "fix: redundant fetching of records from the database"
This reverts commit 7d3a9e244e.
2023-07-28 05:21:31 +00:00
Roardom
2392da1310 Revert "fix: laravel default job model serialization"
This reverts commit 55d03d3819.
2023-07-28 05:20:33 +00:00
Roardom
55d03d3819 fix: laravel default job model serialization
laravel by default automatically serializes models in a custom way when inserted into a job queue and fetches the model from the database again when the job is ran. We would rather not have these extra queries, so we can't pass in models, or data that is already serialized (as laravel will try to deserailize our serialization too and fail), so we opted for arrays, and filling in the properties into a new model again once the job is handled.
2023-07-27 03:11:04 +00:00
Roardom
7d3a9e244e fix: redundant fetching of records from the database
The `SerializesModels` trait fetches a new copy of the record from the database, causing 4 more queries than we thought we were using. This change reduces the query time in the ProcessAnnounce job by 55%.
2023-07-26 02:18:20 +00:00
Roardom
eca50b5224 update: use prepared statement instead of eager loading peers 2023-07-23 09:16:44 +00:00
Roardom
0ffeb4fcf5 fix: missing include in announce controller 2023-07-10 20:44:22 +00:00
Roardom
741adef615 add: moderation scopes 2023-07-10 04:20:40 +00:00
Roardom
9d4789ba91 refactor: require whitespace before statements 2023-07-07 00:27:13 +00:00
Roardom
b5493c5642 refactor: swap where('id', '=', ) for find() 2023-06-19 23:18:40 +00:00
HDVinnie
19827844fd fix: #2715 2023-05-14 17:00:54 -04:00
Roardom
b52bffc728 refactor: reduce unnecessary collection calls 2023-04-09 00:06:47 +00:00