summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-01-30 20:11:54 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-01-30 20:11:54 +0100
commita6565a01376af755c1b0fc2c62b4a4f8d8b952bf (patch)
tree3eb74e6509398d07d51129670c82825d2eff4076
parentnew www, c mods (diff)
downloadtravnik-a6565a01376af755c1b0fc2c62b4a4f8d8b952bf.tar
travnik-a6565a01376af755c1b0fc2c62b4a4f8d8b952bf.tar.gz
travnik-a6565a01376af755c1b0fc2c62b4a4f8d8b952bf.tar.bz2
travnik-a6565a01376af755c1b0fc2c62b4a4f8d8b952bf.tar.lz
travnik-a6565a01376af755c1b0fc2c62b4a4f8d8b952bf.tar.xz
travnik-a6565a01376af755c1b0fc2c62b4a4f8d8b952bf.tar.zst
travnik-a6565a01376af755c1b0fc2c62b4a4f8d8b952bf.zip
Diffstat (limited to '')
-rw-r--r--misc/links.txt4
-rw-r--r--src/dht.c25
-rw-r--r--www/index.php8
3 files changed, 27 insertions, 10 deletions
diff --git a/misc/links.txt b/misc/links.txt
index adb898e..ce4647b 100644
--- a/misc/links.txt
+++ b/misc/links.txt
@@ -1 +1,5 @@
https://www.europol-europa.eu/police2peer <= torrent nr. 44a058d498dd1880d82570b7e5b7ea729472f529
+
+dht crawlerji po internetu:
+http://btdig.com (captcha)
+http://146.19.24.47:8000/ = https://yhgyhg{28..30}.buzz/ (CF)
diff --git a/src/dht.c b/src/dht.c
index c20b6ed..83fcb68 100644
--- a/src/dht.c
+++ b/src/dht.c
@@ -1354,16 +1354,24 @@ void remove_torrent (struct dht * d, struct torrent * t) {
/**
* what to do when there are too many torrents and their peers stored, used in add_peer and add_torrent
*
- * removes last added torrent that wasn't manually added
+ * removes last added torrents that aren't ->type and aren't ->dl until there's space
*
* @param d [in] libhandle
*/
void oom (struct dht * d) {
struct torrent * drop = d->last_torrent;
- while (drop && (drop->type || drop->dl))
+ while (d->torrents_num >= d->torrents_max || d->peers_num >= d->peers_max) {
+ if (!drop)
+ break;
+ while (drop && (drop->type || drop->dl))
+ drop = drop->prev;
+ struct torrent * old = drop;
+ remove_torrent(d, old);
+ if (!drop)
+ break;
drop = drop->prev;
- remove_torrent(d, drop);
+ }
}
/**
@@ -1383,8 +1391,7 @@ struct torrent * add_torrent (struct dht * d, struct torrent * t) {
torrent_free(t);
return found;
}
- if (d->torrents_num >= d->torrents_max)
- oom(d);
+ oom(d);
if (d->torrents)
d->torrents->prev = t;
else
@@ -1462,8 +1469,7 @@ struct peer * add_peer (struct dht * d, struct torrent * t, struct peer * p) {
p->next = t->peers;
t->peers = p;
d->peers_num++;
- if (d->peers_num >= d->peers_max)
- oom(d);
+ oom(d);
return p;
}
@@ -2323,8 +2329,11 @@ void periodic (struct dht * d) {
torrent_ll_assert(d->torrents);
struct torrent * t = d->torrents;
while (t) {
- if (t->ttl && seconds() > t->ttl)
+ if (t->ttl && seconds() > t->ttl) {
+ disconnect(t);
+ t->ttl = 0;
t->type = 0;
+ }
if (t->type & (peers | announce)) {
struct node * n = t->nodes;
int sent = 0;
diff --git a/www/index.php b/www/index.php
index 1fd25a2..e37fe7f 100644
--- a/www/index.php
+++ b/www/index.php
@@ -16,7 +16,7 @@
<h3>rezultati</h3>
<pre>
<?php
-$q = "find .. -name '*.torrent' | xargs grep -lie " . escapeshellarg($_REQUEST["i"]);
+$q = "find .. -maxdepth 2 -name '*.torrent' | xargs grep -lie " . escapeshellarg($_REQUEST["i"]);
echo htmlspecialchars($q);
?>
</pre>
@@ -26,7 +26,11 @@ foreach (explode(PHP_EOL, shell_exec($q)) as $f) {
if (trim($f) == "")
continue;
$t = TorrentFile::load($f);
- echo "<li> <a href=info.php?h=" . $t->getInfoHash() . ">" . htmlspecialchars($t->getName()) . "</a></li>";
+ $m = [];
+ preg_match("|/([a-fA-F0-9]*).torrent|", $f, $m);
+ if (count($m) < 2)
+ var_dump([$f, $m]);
+ echo "<li> <a href=info.php?h=" . $m[1] . ">" . htmlspecialchars($t->getName()) . "</a></li>";
}
?>
</ul>