Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Clearing the code base before actualization
  • Loading branch information
Exileum committed Mar 5, 2023
1 parent 6ca475c commit 2c5994c
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 134 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
build/
config.log
ocelot.conf
88 changes: 0 additions & 88 deletions CHANGES

This file was deleted.

10 changes: 3 additions & 7 deletions config.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <iostream>
#include <fstream>
#include <string>
#include "config.h"
#include "misc_functions.h"

Expand Down Expand Up @@ -75,16 +74,13 @@ void config::init() {
add("schedule_interval", 3u);

// MySQL
add("mysql_db", "gazelle");
add("mysql_db", "torrentpier");
add("mysql_host", "localhost");
add("mysql_username", "");
add("mysql_password", "");

// Site communication
add("site_host", "127.0.0.1");
add("site_path", "");
add("site_password", "00000000000000000000000000000000");
add("report_password", "00000000000000000000000000000000");
// Statistical capture
add("report_password", "0000000000");

// Debugging
add("readonly", false);
Expand Down
16 changes: 11 additions & 5 deletions config.cpp.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "config.h"

config::config() {
// Internal stuff
host = "127.0.0.1";
port = 2710;
max_connections = 512;
Expand All @@ -10,18 +11,23 @@ config::config() {
schedule_interval = 3;
max_middlemen = 5000;

// Tracker requests
announce_interval = 1800;
peers_timeout = 2700; //Announce interval * 1.5
peers_timeout = 2700; // announce interval * 1.5

// Timers
reap_peers_interval = 1800;
del_reason_lifetime = 604800;

// MySQL
mysql_db = "gazelle";
mysql_db = "torrentpier";
mysql_host = "127.0.0.1:3306";
mysql_username = "***";
mysql_password = "***";
site_password = "**********"; // MUST BE 10 CHARS
// Key to use for /report?get=stats and /report?get=user&key=<passkey> requests
report_password = "**********"; // MUST BE 10 CHARS

// Statistical capture
report_password = "**********"; // 10-chars key for /report?get=stats and /report?get=user&key=<passkey>

// Debugging
readonly = false;
}
17 changes: 7 additions & 10 deletions ocelot.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,23 @@ max_connections = 128
max_middlemen = 20000
max_read_buffer = 4096
connection_timeout = 10
# Keepalive is mostly useful if the tracker runs behind reverse proxies
keepalive_timeout = 0

announce_interval = 1800
max_request_size = 4096
numwant_limit = 50
request_log_size = 500

mysql_host =
mysql_username =
mysql_password =
mysql_db =

# The passwords must be 32 characters and match the Gazelle config
report_password = 00000000000000000000000000000000
site_password = 00000000000000000000000000000000

peers_timeout = 7200
del_reason_lifetime = 86400
reap_peers_interval = 1800
schedule_interval = 3

mysql_host =
mysql_username =
mysql_password =
mysql_db =

report_password = 0000000000

readonly = false
10 changes: 3 additions & 7 deletions site_comm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ site_comm::site_comm(config * conf) : t_active(false) {
}

void site_comm::load_config(config * conf) {
site_host = conf->get_str("site_host");
site_path = conf->get_str("site_path");
site_password = conf->get_str("site_password");
readonly = conf->get_bool("readonly");
}

Expand Down Expand Up @@ -79,7 +76,6 @@ void site_comm::do_flush_tokens()
boost::asio::io_service io_service;

tcp::resolver resolver(io_service);
tcp::resolver::query query(site_host, "http");
tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
tcp::resolver::iterator end;

Expand All @@ -95,9 +91,9 @@ void site_comm::do_flush_tokens()

boost::asio::streambuf request;
std::ostream request_stream(&request);
request_stream << "GET " << site_path << "/tools.php?key=" << site_password
request_stream << "GET " << "/tools.php?key="
<< "&type=expiretoken&action=ocelot&tokens=" << token_queue.front() << " HTTP/1.0\r\n"
<< "Host: " << site_host << "\r\n"
<< "Host: " << "\r\n"
<< "Accept: */*\r\n"
<< "Connection: close\r\n\r\n";

Expand All @@ -123,7 +119,7 @@ void site_comm::do_flush_tokens()
std::lock_guard<std::mutex> lock(expire_queue_lock);
token_queue.pop();
} else {
std::cout << "Response returned with status code " << status_code << " when trying to expire a token!" << std::endl;;
std::cout << "Response returned with status code " << status_code << " when trying to expire a token!" << std::endl;
}
}
} catch (std::exception &e) {
Expand Down
3 changes: 0 additions & 3 deletions site_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ using boost::asio::ip::tcp;

class site_comm {
private:
std::string site_host;
std::string site_path;
std::string site_password;
std::mutex expire_queue_lock;
std::string expire_token_buffer;
std::queue<std::string> token_queue;
Expand Down
13 changes: 0 additions & 13 deletions worker.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#include <iostream>
#include <string>
#include <map>
#include <sstream>
#include <list>
#include <vector>
#include <set>
#include <algorithm>
#include <mutex>
#include <thread>

#include "ocelot.h"
Expand All @@ -33,7 +30,6 @@ void worker::load_config(config * conf) {
peers_timeout = conf->get_uint("peers_timeout");
numwant_limit = conf->get_uint("numwant_limit");
keepalive_enabled = conf->get_uint("keepalive_timeout") != 0;
site_password = conf->get_str("site_password");
report_password = conf->get_str("report_password");
}

Expand All @@ -45,7 +41,6 @@ void worker::reload_lists() {
status = PAUSED;
db->load_torrents(torrents_list);
db->load_users(users_list);
//db->load_whitelist(whitelist);
status = OPEN;
}

Expand Down Expand Up @@ -222,14 +217,6 @@ std::string worker::work(const std::string &input, std::string &ip, client_opts_
return error("Invalid action", client_opts);
}

if (action == UPDATE) {
if (passkey == site_password) {
return update(params, client_opts);
} else {
return error("Authentication failure", client_opts);
}
}

if (action == REPORT) {
if (passkey == report_password) {
std::lock_guard<std::mutex> ul_lock(db->user_list_mutex);
Expand Down
1 change: 0 additions & 1 deletion worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class worker {
unsigned int peers_timeout;
unsigned int numwant_limit;
bool keepalive_enabled;
std::string site_password;
std::string report_password;

std::mutex del_reasons_lock;
Expand Down

0 comments on commit 2c5994c

Please sign in to comment.