예제 #1
0
void HTTPTracker::doAnnounce(const KURL & u)
{
    Out(SYS_TRK|LOG_NOTICE) << "Doing tracker request to url : " << u.prettyURL() << endl;
    KIO::MetaData md;
    setupMetaData(md);
    KIO::StoredTransferJob* j = KIO::storedGet(u,false,false);
    // set the meta data
    j->setMetaData(md);
    KIO::Scheduler::scheduleJob(j);

    connect(j,SIGNAL(result(KIO::Job* )),this,SLOT(onAnnounceResult( KIO::Job* )));

    active_job = j;
    requestPending();
}
예제 #2
0
void HTTPTracker::scrape()
{
    if (!url.isValid())
    {
        Out(SYS_TRK|LOG_NOTICE) << "Invalid tracker url, canceling scrape" << endl;
        return;
    }

    if (!url.fileName(false).startsWith("announce"))
    {
        Out(SYS_TRK|LOG_NOTICE) << "Tracker " << url << " does not support scraping" << endl;
        return;
    }

    KURL scrape_url = url;
    scrape_url.setFileName(url.fileName(false).replace("announce","scrape"));

    QString epq = scrape_url.encodedPathAndQuery();
    const SHA1Hash & info_hash = tor->getInfoHash();
    if (scrape_url.queryItems().count() > 0)
        epq += "&info_hash=" + info_hash.toURLString();
    else
        epq += "?info_hash=" + info_hash.toURLString();
    scrape_url.setEncodedPathAndQuery(epq);

    Out(SYS_TRK|LOG_NOTICE) << "Doing scrape request to url : " << scrape_url.prettyURL() << endl;
    KIO::MetaData md;
    setupMetaData(md);

    KIO::StoredTransferJob* j = KIO::storedGet(scrape_url,false,false);
    // set the meta data
    j->setMetaData(md);
    KIO::Scheduler::scheduleJob(j);

    connect(j,SIGNAL(result(KIO::Job* )),this,SLOT(onScrapeResult( KIO::Job* )));
}