rendered paste bodyalias abc_wserv {
socklisten abc_wserv $$1
}
on *:socklisten:abc_wserv:{
sockaccept abc_wclient. $+ $rand(1,99999999)
}
on *:sockread:abc_wclient.*:{
var %read
sockread %read
echo -a $sock($sockname).ip says: %read
if (GET * HTTP/1.1 iswm %read) {
sockmark $sockname $gettok(%read, 2, 32)
echo -a $sock($sockname).ip markd wit $sock($sockname).mark
}
if (!%read) {
sockpause $sockname
if ($sock($sockname).mark == / $+ %abc.id) {
echo -a $sock($sockname).ip sendin torrent shtz
sockwrite -n $sockname HTTP/1.1 200 OK
sockwrite -n $sockname Content-Disposition: attachment; filename=" $+ $nopath(%abc.torrentfile) $+ "
sockwrite -n $sockname Content-Type: application/x-bittorrent
sockwrite -n $sockname
sockmark $sockname 0
.timer $+ $sockname -m 0 50 abc_wsend $sockname
}
else {
sockclose $sockname
}
}
}
alias -l abc_wsend {
if (!$sock($1)) {
echo -a no socket ahaha ERROR $sock($1) $1
.timer $+ $1 off
halt
}
if ($sock($1).mark > $file(%abc.torrentfile).size) {
if (!$sock($1).sq) {
echo -a $sock($1).ip closed apon completion
sockclose $1
.timer $+ $1 off
}
halt
}
if ($sock($1).sq < 8192) {
bread $shortfn(%abc.torrentfile) $sock($1).mark 8192 &x
sockwrite $1 &x
sockmark $1 $calc($sock($1).mark + 8192)
}
}