Giter Site home page Giter Site logo

Users not saved about torrust-actix HOT 3 OPEN

power2all avatar power2all commented on August 30, 2024
Users not saved

from torrust-actix.

Comments (3)

Power2All avatar Power2All commented on August 30, 2024

I'm trying to understand how it works. I have persistence, whitelist, keys and users set to true. I've added a hash to whitelist, tried to announce to the tracker, to make it work I have to add a key through the api and then says working and it adds a record in the torrents table, yet nothing is persisted in the keys table. I tried to add a used through the API, says "OK", but also not persisted in the DB.

Can someone help me understand how it works? How to persist users. Now after I add a key and use it, if I stop the client, the key is lost.

I'll look at it tomorrow.
Could be something is not "saving" when persistency is enabled.
I've not looked at this part of the code for some time, since I've been busy with the public tracking system.

from torrust-actix.

Martzy303 avatar Martzy303 commented on August 30, 2024

Thank you @Power2All
These are the steps I did after adding a whitelist hash.
My guess is I'm doing something wrong, but I can't seem to find out what.

  1. Add seeder with announce https://tracker.domain.com:6969/announce/2234567890123456789012345678901234567890 ( 'Invalid Key' )
  2. Add key using API: POST /api/keys/2234567890123456789012345678901234567890/0?token=mytoken ( Now in the client status 'Working' )
  3. Did the same with a leecher https://tracker.domain.com:6969/announce/1234567890123456789012345678901234567890
  4. Trying to add a user using POST https://tracker.domain.com:8080/api/user?token=mytoken and JSON data
{
  "uuid":"11scbeca840-e9f7-44d5-a1e4-51e9aef864a7",
  "key":"1234567890123456789012345678901234567890",
  "uploaded":0,
  "downloaded":0,
  "completed":0,
  "updated":1686302997,
  "active":1
}

Get response

{
    "status": "ok"
}
  1. Then if I list the users /api/users?token=mytoken response is
{
    "status": "json parse error"
}

This is in the console

2024-02-06 14:37:37.000367710 [INFO ][torrust_actix] [KEYS] Checking now for old keys, and remove them.
2024-02-06 14:37:37.000406821 [INFO ][torrust_actix] [KEYS] Keys cleaned up.
2024-02-06 14:37:37.000410662 [INFO ][torrust_actix] [STATS] Torrents: 1 - Updates: 0 - Shadow 0: - Seeds: 1 - Peers: 1 - Completed: 0
2024-02-06 14:37:37.000446561 [INFO ][torrust_actix] [STATS] Whitelists: 1 - Blacklists: 0 - Keys: 0
2024-02-06 14:37:37.000472682 [INFO ][torrust_actix] [STATS TCP IPv4] Connect: 8 - API: 5 - Announce: 3 - Scrape: 0
2024-02-06 14:37:37.000481342 [INFO ][torrust_actix] [STATS TCP IPv6] Connect: 0 - API: 0 - Announce: 0 - Scrape: 0
2024-02-06 14:37:37.000488396 [INFO ][torrust_actix] [STATS UDP IPv4] Connect: 0 - Announce: 0 - Scrape: 0
2024-02-06 14:37:37.000496987 [INFO ][torrust_actix] [STATS UDP IPv6] Connect: 0 - Announce: 0 - Scrape: 0
2024-02-06 14:37:37.017203426 [INFO ][torrust_actix] [SAVING] Starting persistence saving procedure.
2024-02-06 14:37:37.017223960 [INFO ][torrust_actix] [SAVING] Moving Updates to Shadow...
2024-02-06 14:37:37.017236671 [INFO ][torrust_actix] [SAVING] Saving data from Shadow to database...
2024-02-06 14:37:37.017848276 [INFO ][torrust_actix] [SAVING] Clearing shadow, saving procedure finishing...
2024-02-06 14:37:37.017868809 [INFO ][torrust_actix] [SAVING] Torrents saved.
2024-02-06 14:37:37.017878307 [INFO ][torrust_actix] [SAVING] Saving data from Whitelist to database...
2024-02-06 14:37:37.018239529 [INFO ][torrust_actix] [SAVING] Whitelists saved.
2024-02-06 14:37:37.018251263 [INFO ][torrust_actix] [SAVING] Saving data from Keys to database...
2024-02-06 14:37:37.018444375 [INFO ][torrust_actix] [SAVING] Keys saved.
2024-02-06 14:37:37.018453385 [INFO ][torrust_actix] [SAVING] Saving data from Users to database...
2024-02-06 14:37:37.018638536 [INFO ][torrust_actix] [SAVING] Users saved.
2024-02-06 14:37:37.018647615 [INFO ][torrust_actix] [SAVING] Saving persistent data procedure done.

Now I changed it to MySQL, but first I tried SQlite file. It created whitelist, keys and torrents table by itself, but no users table.
After I changed to MySQL, no tables were created, in the console was trowing errors when trying to save torrents and whitelist, I created manually the tables and it worked.
In both SQLite and MySQL I did not have a user table, but also never seen an error in the console.

And this is the config I used

log_level = "info"
log_console_interval = 60
statistics_enabled = true
global_check_interval = 10
db_driver = "mysql"
db_path = "mysql://root:password@localhost:3306/tracker"
persistence = true
persistence_interval = 60
api_key = "mytoken"
whitelist = true
blacklist = false
keys = true
keys_cleanup_interval = 60
users = true
maintenance_mode_enabled = false
interval = 1800
interval_minimum = 1800
peer_timeout = 2700
peers_returned = 200
interval_cleanup = 900
cleanup_chunks = 100000

[[udp_server]]
enabled = false
bind_address = "0.0.0.0:6969"

[[http_server]]
enabled = true
bind_address = "0.0.0.0:6969"
ssl = true
ssl_key = "/home/user/torrust-actix/target/release/privkey.pem"
ssl_cert = "/home/user/torrust-actix/target/release/cert.pem"

[[api_server]]
enabled = true
bind_address = "0.0.0.0:8080"
ssl = true
ssl_key = "/home/user/torrust-actix/target/release/privkey.pem"
ssl_cert = "/home/user/torrust-actix/target/release/cert.pem"

[db_structure]
db_torrents = "torrents"
table_torrents_info_hash = "info_hash"
table_torrents_completed = "completed"
db_whitelist = "whitelist"
table_whitelist_info_hash = "info_hash"
db_blacklist = "blacklist"
table_blacklist_info_hash = "info_hash"
db_keys = "keys"
table_keys_hash = "hash"
table_keys_timeout = "timeout"
db_users = "users"
table_users_uuid = "uuid"
table_users_key = "key"
table_users_uploaded = "uploaded"
table_users_downloaded = "downloaded"
table_users_completed = "completed"
table_users_updated = "updated"
table_users_active = "active"

from torrust-actix.

Power2All avatar Power2All commented on August 30, 2024

Problem might have been found.
The table was not created of an "bug".
Will be fixed anyway on the v3.2.2 release when it's done.
You can use the following query in MySQL to create the table:

CREATE TABLE IF NOT EXISTS `users` ( `uuid` varchar(36) NOT NULL, `key` varchar(40) NULL, `uploaded` int NOT NULL DEFAULT '0', `downloaded` int NOT NULL DEFAULT '0', `completed` int NOT NULL DEFAULT '0', `updated` int NOT NULL DEFAULT '0', `active` int NOT NULL DEFAULT '0', PRIMARY KEY (`uuid`) USING BTREE, UNIQUE KEY `uuid` (`uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

And for SQLite:
CREATE TABLE users (uuid VARCHAR(36) PRIMARY KEY, key VARCHAR(40) NULL, uploaded INTEGER DEFAULT 0 NOT NULL, downloaded INTEGER DEFAULT 0 NOT NULL, completed INTEGER DEFAULT 0 NOT NULL, updated INTEGER DEFAULT 0 NOT NULL, active INTEGER DEFAULT 0 NOT NULL)

from torrust-actix.

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.