Giter Club home page Giter Club logo

Comments (22)

HDVinnie avatar HDVinnie commented on June 10, 2024

Solved

from unit3d-community-edition.

LostRager avatar LostRager commented on June 10, 2024

With the fix, If you pause and/or unpause the torrent you get the error: unexpected end of file in bencoded string in the torrent client.

No errors in the laravel log.

from unit3d-community-edition.

Roardom avatar Roardom commented on June 10, 2024

With the fix, If you pause and/or unpause the torrent you get the error: unexpected end of file in bencoded string in the torrent client.

No errors in the laravel log.

Seems unrelated, also very vague. It basically means that the tracker response wasn't bencoded or the bencode it returned wasn't valid. What response are you getting via curl?

from unit3d-community-edition.

LostRager avatar LostRager commented on June 10, 2024

Not quite sure how to use curl, but i removed all the bin2hex and hex2bin's from:

protected function checkTorrent($infoHash): object
{
$cacheKey = config('cache.prefix').'torrents:infohash2id';
// Check Info Hash Against Torrents Table
$torrentId = Redis::connection('cache')->command('HGET', [$cacheKey, hex2bin($infoHash)]);
$torrent = Torrent::withAnyStatus()
->with([
'peers' => fn ($query) => $query
->select(['id', 'torrent_id', 'peer_id', 'user_id', 'left', 'seeder', 'port'])
->selectRaw('INET6_NTOA(ip) as ip')
])
->select(['id', 'free', 'doubleup', 'seeders', 'leechers', 'times_completed', 'status'])
->when(
$torrentId === null,
fn ($query) => $query->where('info_hash', '=', hex2bin($infoHash)),
fn ($query) => $query->where('id', '=', $torrentId),
)
->first();
if ($torrentId === null && $torrent !== null) {
Redis::connection('cache')->command('HSET', [$cacheKey, hex2bin($infoHash), $torrent->id]);
}

and

// Part.6 bin2hex info_hash
$queries['info_hash'] = bin2hex($queries['info_hash']);

And the error goes away.

edit: aah i see, now it wont see you as seeding.

from unit3d-community-edition.

Roardom avatar Roardom commented on June 10, 2024

The info_hash query parameter is a 20-byte binary string that we originally stored as a 40-character string encoded as hex using ascii. For the announce queue to work, it converts $queries to json to add it to the redis queue, and it will error if the 20-byte string includes characters invalid in json (only very few info hashes cause this), so that has to be either hex encoded or base64 encoded. In all other cases however, we keep it in the 20-byte format, as searching the torrents table by info_hash was using 50% of all of our database execution time, and that dropped down to 11% (if I remember correctly) once we reduced the size of the column in half. #2713 is valid, but I don't believe what you're currently experiencing is related to bin2hex/hex2bin.

from unit3d-community-edition.

Roardom avatar Roardom commented on June 10, 2024

Regarding curl, something like this should work:

curl "http://domain.tld/announce/[insert passkey here]?info_hash=z%8B%83%9Fx%C3%1D%E7%14%FF%F4%B2%40%27V%BB%05%A6~%0F&peer_id=01234567890123456789&port=1&uploaded=0&downloaded=0&left=0&event=started&numwant=50&compact=1"

with the info_hash containing the 20-byte percent encoded info_hash. It should return the bencoded string. You can edit the parameters to what you used before to cause the invalid bencoded error.

from unit3d-community-edition.

LostRager avatar LostRager commented on June 10, 2024

$torrentId = Redis::connection('cache')->command('HGET', [$cacheKey, hex2bin($infoHash)]);

Should that be hex2bin? Since its returning the id? with hex2bin it returns nothing and without it returns the id.
image

from unit3d-community-edition.

Roardom avatar Roardom commented on June 10, 2024

It just has to be identical to the line 20 lines below it. One sets it, one gets it.

Redis::connection('cache')->command('HSET', [$cacheKey, hex2bin($infoHash), $torrent->id]);

from unit3d-community-edition.

Roardom avatar Roardom commented on June 10, 2024

https://redis.io/commands/hset/
https://redis.io/commands/hget/

from unit3d-community-edition.

LostRager avatar LostRager commented on June 10, 2024

i see,

Here is the result from curl d8:completei1e10:incompletei0e8:intervali3640e12:min intervali3600e5:peers0:6:peers60:e

edit: But if i try to run it again, it returns nothing

Tried running it on 6.5.0 and it returns the same looking line. And when i try to run it again it returns with the announce cooldown message.

from unit3d-community-edition.

Roardom avatar Roardom commented on June 10, 2024

That first result is expected. You should always receive a response however, and that could be the result of that bencode error message. However, I'm unable to reproduce when repeating an announce a second time.

from unit3d-community-edition.

LostRager avatar LostRager commented on June 10, 2024

You were not able to reproduce?

very strange.

I also tried reinstalling and using a fresh db instead of a dump to see if that was the issue. but still have the same issue.

from unit3d-community-edition.

Roardom avatar Roardom commented on June 10, 2024

Hmm, strange. I was using a fresh db too. I'll have to give it another go in a little bit.

from unit3d-community-edition.

Roardom avatar Roardom commented on June 10, 2024

Think we managed to narrow it down to a rogue config setting. Can you give this a try: 45dbf08

from unit3d-community-edition.

LostRager avatar LostRager commented on June 10, 2024

I was already running predis. So this fix did not solve the issue, sadly.

I believe the issue is that the server is not sending more announce messages after the first one. When the announce runs out and you reannounce then you get an answer, but if you reannounce or stop/start again it's not sending anything.

from unit3d-community-edition.

HDVinnie avatar HDVinnie commented on June 10, 2024

Im not sure that's right as it is indeed encoded

// Part.7 base64_encode binary peer_id for job
$queries['peer_id'] = base64_encode($queries['peer_id']);

Im also not able to replicate this issue locally or on a prod site running 7.x.x

from unit3d-community-edition.

LostRager avatar LostRager commented on June 10, 2024

Im not sure that's right as it is indeed encoded

// Part.7 base64_encode binary peer_id for job
$queries['peer_id'] = base64_encode($queries['peer_id']);

Yes, i noticed i got a response now, just not the right one.

from unit3d-community-edition.

LostRager avatar LostRager commented on June 10, 2024

Its super wierd how it cant be replicated...

I've think ive gotten too the cause tho. Its not getting past the min lock check

from unit3d-community-edition.

HDVinnie avatar HDVinnie commented on June 10, 2024
            // Lock Min Announce Interval.
            /*if (config('announce.min_interval.enabled')) {
                $this->checkMinInterval($torrent, $queries, $user);
            }*/

If you comment it out does announce work for you?

from unit3d-community-edition.

LostRager avatar LostRager commented on June 10, 2024
            // Lock Min Announce Interval.
            /*if (config('announce.min_interval.enabled')) {
                $this->checkMinInterval($torrent, $queries, $user);
            }*/

If you comment it out does announce work for you?

yes

from unit3d-community-edition.

HDVinnie avatar HDVinnie commented on June 10, 2024

Interesting. I think I have faced this before myself. Mind opening a new issue regarding checkMinInterval?

from unit3d-community-edition.

LostRager avatar LostRager commented on June 10, 2024

#2715

from unit3d-community-edition.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.