Small changes;
Added "is_dynamic" setting; Changed stuff with Database (I guess i was sleeping when i programmed that part...).
This commit is contained in:
parent
b4c0511f82
commit
f757db71a4
|
@ -242,7 +242,7 @@ namespace UDPT
|
||||||
sqlite3_stmt *stmt;
|
sqlite3_stmt *stmt;
|
||||||
sqlite3_prepare(this->db, "INSERT INTO torrents (info_hash,created) VALUES (?,?)", -1, &stmt, NULL);
|
sqlite3_prepare(this->db, "INSERT INTO torrents (info_hash,created) VALUES (?,?)", -1, &stmt, NULL);
|
||||||
sqlite3_bind_blob(stmt, 1, info_hash, 20, NULL);
|
sqlite3_bind_blob(stmt, 1, info_hash, 20, NULL);
|
||||||
sqlite3_bind_int(stmt, 1, time(NULL));
|
sqlite3_bind_int(stmt, 2, time(NULL));
|
||||||
sqlite3_step(stmt);
|
sqlite3_step(stmt);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ namespace UDPT
|
||||||
return (r == SQLITE_OK);
|
return (r == SQLITE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQLite3Driver::isTorrentAllowed(uint8_t info_hash[20])
|
bool SQLite3Driver::isTorrentAllowed(uint8_t *info_hash)
|
||||||
{
|
{
|
||||||
if (this->isDynamic())
|
if (this->isDynamic())
|
||||||
return true;
|
return true;
|
||||||
|
@ -275,8 +275,9 @@ namespace UDPT
|
||||||
sqlite3_bind_blob(stmt, 1, info_hash, 20, NULL);
|
sqlite3_bind_blob(stmt, 1, info_hash, 20, NULL);
|
||||||
sqlite3_step(stmt);
|
sqlite3_step(stmt);
|
||||||
|
|
||||||
int n = sqlite3_column_int(stmt, 1);
|
int n = sqlite3_column_int(stmt, 0);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
|
|
||||||
return (n == 1);
|
return (n == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,10 +103,11 @@ int main(int argc, char *argv[])
|
||||||
settings->set (strDATABASE, "driver", "sqlite3");
|
settings->set (strDATABASE, "driver", "sqlite3");
|
||||||
settings->set (strDATABASE, "file", "tracker.db");
|
settings->set (strDATABASE, "file", "tracker.db");
|
||||||
|
|
||||||
|
settings->set (strTRACKER, "is_dynamic", "0");
|
||||||
settings->set (strTRACKER, "port", "6969"); // UDP PORT
|
settings->set (strTRACKER, "port", "6969"); // UDP PORT
|
||||||
settings->set (strTRACKER, "threads", "5");
|
settings->set (strTRACKER, "threads", "5");
|
||||||
settings->set (strTRACKER, "allow_remotes", "yes");
|
settings->set (strTRACKER, "allow_remotes", "1");
|
||||||
settings->set (strTRACKER, "allow_iana_ips", "yes");
|
settings->set (strTRACKER, "allow_iana_ips", "1");
|
||||||
settings->set (strTRACKER, "announce_interval", "1800");
|
settings->set (strTRACKER, "announce_interval", "1800");
|
||||||
settings->set (strTRACKER, "cleanup_interval", "120");
|
settings->set (strTRACKER, "cleanup_interval", "120");
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,8 @@ namespace UDPT
|
||||||
s_allow_remotes, // remotes allowed?
|
s_allow_remotes, // remotes allowed?
|
||||||
s_allow_iana_ip, // IANA IPs allowed?
|
s_allow_iana_ip, // IANA IPs allowed?
|
||||||
s_int_announce, // announce interval
|
s_int_announce, // announce interval
|
||||||
s_int_cleanup; // cleanup interval
|
s_int_cleanup, // cleanup interval
|
||||||
|
s_is_dynamic;
|
||||||
|
|
||||||
sc_tracker = settings->getClass("tracker");
|
sc_tracker = settings->getClass("tracker");
|
||||||
|
|
||||||
|
@ -81,6 +82,7 @@ namespace UDPT
|
||||||
s_allow_iana_ip = sc_tracker->get ("allow_iana_ips");
|
s_allow_iana_ip = sc_tracker->get ("allow_iana_ips");
|
||||||
s_int_announce = sc_tracker->get ("announce_interval");
|
s_int_announce = sc_tracker->get ("announce_interval");
|
||||||
s_int_cleanup = sc_tracker-> get ("cleanup_interval");
|
s_int_cleanup = sc_tracker-> get ("cleanup_interval");
|
||||||
|
s_is_dynamic = sc_tracker->get("is_dynamic");
|
||||||
|
|
||||||
if (_isTrue(s_allow_remotes) == 1)
|
if (_isTrue(s_allow_remotes) == 1)
|
||||||
n_settings |= UDPT_ALLOW_REMOTE_IP;
|
n_settings |= UDPT_ALLOW_REMOTE_IP;
|
||||||
|
@ -88,6 +90,11 @@ namespace UDPT
|
||||||
if (_isTrue(s_allow_iana_ip) != 0)
|
if (_isTrue(s_allow_iana_ip) != 0)
|
||||||
n_settings |= UDPT_ALLOW_IANA_IP;
|
n_settings |= UDPT_ALLOW_IANA_IP;
|
||||||
|
|
||||||
|
if (_isTrue(s_is_dynamic) == 1)
|
||||||
|
this->isDynamic = true;
|
||||||
|
else
|
||||||
|
this->isDynamic = false;
|
||||||
|
|
||||||
this->announce_interval = (s_int_announce == "" ? 1800 : atoi (s_int_announce.c_str()));
|
this->announce_interval = (s_int_announce == "" ? 1800 : atoi (s_int_announce.c_str()));
|
||||||
this->cleanup_interval = (s_int_cleanup == "" ? 120 : atoi (s_int_cleanup.c_str()));
|
this->cleanup_interval = (s_int_cleanup == "" ? 120 : atoi (s_int_cleanup.c_str()));
|
||||||
this->port = (s_port == "" ? 6969 : atoi (s_port.c_str()));
|
this->port = (s_port == "" ? 6969 : atoi (s_port.c_str()));
|
||||||
|
@ -169,7 +176,8 @@ namespace UDPT
|
||||||
|
|
||||||
this->sock = sock;
|
this->sock = sock;
|
||||||
|
|
||||||
this->conn = new Data::SQLite3Driver (this->o_settings->getClass("database"), true);
|
this->conn = new Data::SQLite3Driver (this->o_settings->getClass("database"),
|
||||||
|
this->isDynamic);
|
||||||
|
|
||||||
this->isRunning = true;
|
this->isRunning = true;
|
||||||
cout << "Starting maintenance thread (1/" << ((int)this->thread_count) << ")" << endl;
|
cout << "Starting maintenance thread (1/" << ((int)this->thread_count) << ")" << endl;
|
||||||
|
|
|
@ -137,6 +137,7 @@ namespace UDPT
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
uint8_t thread_count;
|
uint8_t thread_count;
|
||||||
bool isRunning;
|
bool isRunning;
|
||||||
|
bool isDynamic;
|
||||||
HANDLE *threads;
|
HANDLE *threads;
|
||||||
uint32_t announce_interval;
|
uint32_t announce_interval;
|
||||||
uint32_t cleanup_interval;
|
uint32_t cleanup_interval;
|
||||||
|
|
Loading…
Reference in a new issue