hooks into scanning functions built

dynamic-accesslists
erdgeist 18 years ago
parent 2adf4fb28a
commit 83e339bbe0

@ -126,53 +126,48 @@ e400:
if (c[0]!='/') goto e404; if (c[0]!='/') goto e404;
while (c[1]=='/') ++c; 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 // info_hash, left, port, numwant, compact
struct ot_peer peer; struct ot_peer peer;
ot_hash hash; ot_hash hash;
byte_copy( peer.ip, h->ip, 4); byte_copy( peer.ip, h->ip, 4);
peer.port = 6881; peer.port = 6881;
c+=9; while( NOCHAMSCANNEN ) {
while( *c!=' ' ) { data = c;
if(!byte_diff(c,10,"info_hash=")) switch( scan_urlencoded_query( &c, data, SCAN_SEARCHPATH_PARAM ) ) {
{ case -1: /* error */
size_t destlen = 20; httperror(h,"404 Not Found","No such file or directory.");
// String is expected to be URL encoded, so expect goto e404;
// (%[0-9A-F][0-9A-F]){20} case 4:
if(!byte_diff(c,4,"port"))
int s = scan_urlencoded( c+10, hash, &destlen); /* scan int */
if( c[s+10] != '&' ) else if(!byte_diff(c,4,"left"))
goto e_parse; /* scan int */
break;
} case 7:
else if(!byte_diff(c,8,"numwant=")) if(!byte_diff(c,7,"numwant"))
{ /* scan int */
else if(!byte_diff(c,7,"compact"))
} /* scan flag */
else if(!byte_diff(c,8,"compact=")) break;
{ case 9: /* info_hash */
if(!byte_diff(c,9,"info_hash"))
} /* scan 20 bytes */
else if(!byte_diff(c,5,"port=")) break;
{ }
}
} break;
else if(!byte_diff(c,5,"left=")) default: /* neither scrape nor announce */
{
}
while( *++c!=' ' && *c!='&');
}
}
else if (!byte_diff(c,7,"scrape?"))
{
}
else
{
httperror(h,"404 Not Found","No such file or directory."); httperror(h,"404 Not Found","No such file or directory.");
goto e404; goto e404;
} }

Loading…
Cancel
Save