Git Product home page Git Product logo

tgragnato / magnetico Goto Github PK

View Code? Open in Web Editor NEW

This project forked from boramalper/magnetico

31.0 31.0 5.0 20.26 MB

Autonomous (self-hosted) BitTorrent DHT search engine suite

Home Page: https://tgragnato.it/magnetico/

License: GNU Affero General Public License v3.0

JavaScript 7.30% Go 86.25% CSS 4.09% Makefile 0.13% HTML 1.97% Dockerfile 0.27%
bittorrent dht magnetico search-engine self-hosted

magnetico's Introduction

Hi there πŸ‘‹ I'm Tommaso

  • πŸ”§ I am a backend developer currently engaged in platform engineering roles
  • πŸ’Ό I strive to leverage my knowledge and expertise to create and manage robust and scalable infrastructures
  • πŸš€ My focus is on security, containerization and orchestration, monitoring and logging
  • πŸ”­ I am presently working on projects that involve Go and/or PHP
  • 🌱 I am actively engaged in expanding my skill set by delving into the realms of Ruby and Javascript
  • πŸ’¬ I'm always eager to engage in discussions and share my knowledge, especially about networking and censorship circumvention

magnetico's People

Contributors

ad-m avatar afjoseph avatar anacrolix avatar askalexsharov avatar boramalper avatar capricornusx avatar ct1n avatar dborzov avatar dependabot[bot] avatar digitalalchemist avatar elgatito avatar figbert avatar hustcat avatar jangrewe avatar lruggieri avatar ls0f avatar marcovidonis avatar mh0lt avatar milosgajdos avatar monkeywie avatar mweinelt avatar ngosang avatar nsf avatar phasip avatar richardkiss avatar tgragnato avatar ucwong avatar yarikk avatar yenforyang avatar zhulik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

magnetico's Issues

Make: invalid memory address or nil pointer dereference

When running make, right after the TestFlush test, it stops with the following error.
I'm not experienced in go, what should I do to build it?

2024/03/13 09:40:24 Updating database schema from 0 to 1... (this might take a while)
2024/03/13 09:40:24 Updating database schema from 1 to 2... (this might take a while)
2024/03/13 09:40:24 Updating database schema from 2 to 3... (this might take a while)
=== RUN   TestTorrentMetadata_MarshalJSON
--- PASS: TestTorrentMetadata_MarshalJSON (0.00s)
=== RUN   TestNewStatistics
--- PASS: TestNewStatistics (0.00s)
=== RUN   TestParseISO8601
=== PAUSE TestParseISO8601
=== RUN   TestDaysOfMonth
--- PASS: TestDaysOfMonth (0.00s)
=== RUN   TestIsLeap
--- PASS: TestIsLeap (0.00s)
=== RUN   TestPostgresDatabase_ExecuteTemplate
--- PASS: TestPostgresDatabase_ExecuteTemplate (0.00s)
=== RUN   TestPostgresDatabase_OrderOn
--- PASS: TestPostgresDatabase_OrderOn (0.00s)
=== RUN   Test_sqlite3Database_DoesTorrentExist
=== PAUSE Test_sqlite3Database_DoesTorrentExist
=== RUN   Test_sqlite3Database_GetNumberOfTorrents
=== PAUSE Test_sqlite3Database_GetNumberOfTorrents
=== RUN   Test_sqlite3Database_AddNewTorrent
=== PAUSE Test_sqlite3Database_AddNewTorrent
=== RUN   Test_sqlite3Database_QueryTorrents
=== PAUSE Test_sqlite3Database_QueryTorrents
=== RUN   Test_sqlite3Database_GetTorrent
=== PAUSE Test_sqlite3Database_GetTorrent
=== RUN   Test_sqlite3Database_GetFiles
=== PAUSE Test_sqlite3Database_GetFiles
=== RUN   Test_sqlite3Database_GetStatistics
=== PAUSE Test_sqlite3Database_GetStatistics
=== CONT  Test_sqlite3Database_DoesTorrentExist
=== CONT  Test_sqlite3Database_QueryTorrents
=== RUN   Test_sqlite3Database_QueryTorrents/Test_Relevance
=== RUN   Test_sqlite3Database_DoesTorrentExist/Test_Empty
--- FAIL: Test_sqlite3Database_QueryTorrents (0.00s)
    --- FAIL: Test_sqlite3Database_QueryTorrents/Test_Relevance (0.00s)
=== CONT  Test_sqlite3Database_AddNewTorrent
=== RUN   Test_sqlite3Database_AddNewTorrent/Test_Nil
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0xc51f6b]

goroutine 3 [running]:
testing.tRunner.func1.2({0xddf080, 0x1382280})
	/usr/lib/go/src/testing/testing.go:1631 +0x3f7
testing.tRunner.func1()
	/usr/lib/go/src/testing/testing.go:1634 +0x6b6
panic({0xddf080?, 0x1382280?})
	/usr/lib/go/src/runtime/panic.go:770 +0x132
github.com/tgragnato/magnetico/persistence.Test_sqlite3Database_QueryTorrents.func1(0xc0000b2000)
	/opt/magnetico/persistence/sqlite3_test.go:174 +0xab
testing.tRunner(0xc0000b2000, 0xc0000ac000)
	/usr/lib/go/src/testing/testing.go:1689 +0x21f
created by testing.(*T).Run in goroutine 34
	/usr/lib/go/src/testing/testing.go:1742 +0x826
FAIL	github.com/tgragnato/magnetico/persistence	0.046s
FAIL
make: *** [Makefile:15: test] Error 1

How to run this?

Would you mind expanding readme with instructions on running this? Especially in docker for windows.

bitmagnet.io

I find this project - bitmagnet.io.
This seems to be a more complete solution for users. Maybe we can join them? ;)

Running on Ubuntu - "Easy installation" in readme is deceptive!

Its clear that this is not an "Easy installation" as the readme would suggest.

After 4 hours of my time, 20+ years of computing experience, added googling and prompting, here is what I've been able to do so far from a fresh install of Ubuntu (24):

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# DB
sudo docker pull postgres
sudo docker run --net=host --name magnetico-postgres -e POSTGRES_USER=magnetico -e POSTGRES_PASSWORD=magnetico -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres
sudo docker exec -it magnetico-postgres bash
psql -U magnetico
CREATE EXTENSION pg_trgm;
quit

# magnetico
git clone https://github.com/tgragnato/magnetico
cd ./magnetico
docker build -t mag .
sudo docker run --net=host --rm -it --name contmag --entrypoint "/bin/sh" prjmag -c /usr/bin/magneticod

Then to get the web server, magneticow, running, start another terminal and then:

sudo docker exec -it contmag /usr/bin/magneticow --no-auth

I am super happy to report that this seems to be working after a lot of messing around.

However, as from the origonal repo, and related press coverage, I would have expected it to be easier to run?!

Can this be simplifed at all? In the origonal repo they simple state the you can run make docker that it sets everything up and runs both serives, however it never worked for me.

addNode function occupies too much memory and does not release it

During use, it was found that the addNode function occupied a large amount of memory over time and was not released, eventually leading to system memory exhaustion.

git : ac5125f

pprof:
addNodeMem

I think the problem is caused by slicing.
append

I am not sure if it is appropriate to use the copy() function to solve this problem through online query.

Wrong condition or golang specific behavior

Why is the checked length equal to 1 here, if the second element is also used?

if len(peerAddrs) = 1 then ms.incomingInfoHashes[infoHash] = peerAddrs[1:] will cause an error or nothing (because empty slice)?

I think the check needs to be corrected to len(peerAddrs) < 2

if len(peerAddrs) < 1 {
    return
}

magnetico/metadata/sink.go

Lines 93 to 106 in afacc2b

infoHash := res.InfoHash()
peerAddrs := res.PeerAddrs()
if _, exists := ms.incomingInfoHashes[infoHash]; exists {
return
} else if len(peerAddrs) > 0 {
peer := peerAddrs[0]
ms.incomingInfoHashes[infoHash] = peerAddrs[1:]
go NewLeech(infoHash, &peer, ms.PeerID, LeechEventHandlers{
OnSuccess: ms.flush,
OnError: ms.onLeechError,
}).Do(time.Now().Add(ms.deadline))
}

similar behavior occurs further:

magnetico/metadata/sink.go

Lines 141 to 145 in afacc2b

if len(ms.incomingInfoHashes[infoHash]) > 0 {
peer := ms.incomingInfoHashes[infoHash][0]
ms.incomingInfoHashes[infoHash] = ms.incomingInfoHashes[infoHash][1:]
go NewLeech(infoHash, &peer, ms.PeerID, LeechEventHandlers{

SQLite support

Hi, and many thanks for taking care of magnetico!

I'm a long time user of it (since the python version in fact), and still using an SQLite database, because I found that performance and storage space of PostgreSQL doesn't fit my need.

I saw that you removed SQLite in 5ed7d99

Do you plan to support it, at least for scraping the DHT?Β I guess that you removed it because it didn't fit your needs for the web interface, but… it's just a guessΒ :)

Torrents stop adding after a while

After running for a while the leechers are all used up and will not allow addition of new leeches.
You can test this by adding some debug output and running with --leech-max-n=1.

The issue lies in the Sink which leaves zero-length peer lists in the ms.incomingInfoHashes when it handles the last peer of an infohash. This should be cleared by onError.

I.e a delete is needed here:

return

However, adding that breaks the current tests due to race-conditions.

Enhancement: OpenTracker support in magnetico

Have a nice day at work!

I noticed that you are actively developing the "magnetico" project.

Importing info-hashes from the specified tracker (OpenTracker) is very important to me.

If possible, add an alternative behavior for "magneticoD".

For tests, I can provide my home OpenTracker, which I use. There aren't many torrents there, but this should be enough to check.

Please, additionally read my correspondence with the author of "magnetico":

My letter to Bora:

Good day!

I am an application administrator and I'm not strong in development.
"Magneticow" works very good, however, "magneticod" works only for global DHT. I need to configure the "magneticod" to work "only for local network".

I have "OpenTracker" ( source from https://erdgeist.org/arts/software/opentracker/ ) and several "Transmission" clients running on my local network.
"Curl" can request a list of announced "Info-hashes" from "OpenTracker".
For example:

Help me set up the "magneticod" for my purposes.
How to run "magneticod" for index my "OpenTracker"?

Thanks for any help provided. Have a good day!


Reply from Bora:

Hi,

No worries at all. In fact, you reminded me to do something that I've been postponing for a long time and I just archived the project today.
Regarding your request, I would have gladly helped if it was simple but I am afraid it isn't. I really cannot see how you can trawl a DHT of localhosts only, except that you can change the bootstrapping nodes (you need to hosts those yourself of course) and add some iptables rules to ensure that magnetico doesn't try to connect hosts outside of your local/private network. I would think it's doable, but would require lots of tuning I reckon. Hope it helps!

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.