mirror of
git://erdgeist.org/opentracker
synced 2025-01-13 16:30:06 +00:00
hooks into scanning functions built
This commit is contained in:
parent
2adf4fb28a
commit
83e339bbe0
@ -126,53 +126,48 @@ e400:
|
||||
if (c[0]!='/') goto e404;
|
||||
while (c[1]=='/') ++c;
|
||||
|
||||
if (!byte_diff(c,9,"announce?"))
|
||||
{
|
||||
data = c;
|
||||
switch( scan_urlencoded_query( &c, data, SCAN_PATH ) ) {
|
||||
case 6: /* scrape ? */
|
||||
if (!byte_diff(c,6,"scrape"))
|
||||
goto 404;
|
||||
break;
|
||||
case 9:
|
||||
if( !byte_diff(c,8,"announce"))
|
||||
goto 404;
|
||||
else {
|
||||
// info_hash, left, port, numwant, compact
|
||||
struct ot_peer peer;
|
||||
ot_hash hash;
|
||||
byte_copy( peer.ip, h->ip, 4);
|
||||
peer.port = 6881;
|
||||
|
||||
c+=9;
|
||||
while( *c!=' ' ) {
|
||||
if(!byte_diff(c,10,"info_hash="))
|
||||
{
|
||||
size_t destlen = 20;
|
||||
// String is expected to be URL encoded, so expect
|
||||
// (%[0-9A-F][0-9A-F]){20}
|
||||
|
||||
int s = scan_urlencoded( c+10, hash, &destlen);
|
||||
if( c[s+10] != '&' )
|
||||
goto e_parse;
|
||||
|
||||
}
|
||||
else if(!byte_diff(c,8,"numwant="))
|
||||
{
|
||||
|
||||
}
|
||||
else if(!byte_diff(c,8,"compact="))
|
||||
{
|
||||
|
||||
}
|
||||
else if(!byte_diff(c,5,"port="))
|
||||
{
|
||||
|
||||
}
|
||||
else if(!byte_diff(c,5,"left="))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
while( *++c!=' ' && *c!='&');
|
||||
while( NOCHAMSCANNEN ) {
|
||||
data = c;
|
||||
switch( scan_urlencoded_query( &c, data, SCAN_SEARCHPATH_PARAM ) ) {
|
||||
case -1: /* error */
|
||||
httperror(h,"404 Not Found","No such file or directory.");
|
||||
goto e404;
|
||||
case 4:
|
||||
if(!byte_diff(c,4,"port"))
|
||||
/* scan int */
|
||||
else if(!byte_diff(c,4,"left"))
|
||||
/* scan int */
|
||||
break;
|
||||
case 7:
|
||||
if(!byte_diff(c,7,"numwant"))
|
||||
/* scan int */
|
||||
else if(!byte_diff(c,7,"compact"))
|
||||
/* scan flag */
|
||||
break;
|
||||
case 9: /* info_hash */
|
||||
if(!byte_diff(c,9,"info_hash"))
|
||||
/* scan 20 bytes */
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!byte_diff(c,7,"scrape?"))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
default: /* neither scrape nor announce */
|
||||
httperror(h,"404 Not Found","No such file or directory.");
|
||||
goto e404;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user