将Bittorrent HTTP请求发送到Ubuntu跟踪器

时间:2018-03-08 18:52:30

标签: http http-get bittorrent

我从这里下载了ubuntu 17.10的torrent文件: https://www.ubuntu.com/download/alternative-downloads

这里面是什么:

public class VendingMachineChangeCalculator {
    public static void main(String[] args) {    
        Scanner takeit = new Scanner(System.in);
        System.out.println("Enter a whole number from 1 to 99"
            + "\nI will find a combination of coins that equals"
            +"the amount of change ");
        int money = 0;
        System.out.println("Please enter number: ");
        money = takeit.nextInt();

    if(money>0 && money<=99) {
        System.out.println("You have: ");

        int quarter, dime, nickel, penny;

        quarter = money/25;
        money = money %25;

        dime = money/10;
        money = money %10;

        nickel = money/5;
        money = money%5;
        penny = money;

        System.out.println(quarter + " quarters");
        System.out.println(dime + " dimes");
        System.out.println(nickel + " nickles");
        System.out.println(penny + " pennies");

        System.out.print("Good job, enter a new valid integer: ");
        money = takeit.nextInt();                       
}
 else  {System.out.print("Invalid entry, please try again: ");
 money = takeit.nextInt();
 } 
    takeit.close();
    }
 }

我尝试过:

我已发送:(仅限torrent-hash)

  

http://torrent.ubuntu.com:6969/announce?info_hash=%f0%7e%0b%05%84%74%5b%7b%cb%35%e9%80%97%48%8d%34%e6%86%23%d0

并收到:

  你给我发了垃圾 - 不是长度为20

我发送了:( torrent torrent-hash和我的peer-id)

  

http://torrent.ubuntu.com:6969/announce?info_hash=%f0%7e%0b%05%84%74%5b%7b%cb%35%e9%80%97%48%8d%34%e6%86%23%d0&peer_id=%2D%41%5A%35%37%35%30%2D%54%70%6B%58%74%74%5A%4C%66%70%53%48

并收到:

  

你给我发了垃圾 - 用基数为10的long()文字无效:&#39;&#39;

我错过了什么?规范没有指定任何示例。

规格:

https://wiki.theory.org/index.php/BitTorrentSpecification#Tracker_HTTP.2FHTTPS_Protocol

1 个答案:

答案 0 :(得分:4)

宣布错过强制性密钥端口已上传已下载已离开
这些键加上 info_hash peer_id ,必须在每个宣布中。

此外,虽然每个宣布中都不强制使用事件键,但 第一个宣布到跟踪器必须包含' event = started '。

尝试:

  

http://torrent.ubuntu.com:6969/announce?info_hash=%f0%7e%0b%05%84%74%5b%7b%cb%35%e9%80%97%48%8d%34%e6%86%23%d0&peer_id=%2D%41%5A%35%37%35%30%2D%54%70%6B%58%74%74%5A%4C%66%70%53%48&port=6881&uploaded=0&downloaded=0&left=1502576640&event=started

并且跟踪器回复:

  

您的客户已过时,请升级

哦,还有更多要修复......

从我的答案:Why does tracker server NOT understand my request? (Bittorrent protocol)

  

这是因为请求字符串中没有 compact = 1    现在大多数跟踪器需要。传统方式效率太低。

所以,将 compact = 1 添加到宣布

  

http://torrent.ubuntu.com:6969/announce?info_hash=%f0%7e%0b%05%84%74%5b%7b%cb%35%e9%80%97%48%8d%34%e6%86%23%d0&peer_id=%2D%41%5A%35%37%35%30%2D%54%70%6B%58%74%74%5A%4C%66%70%53%48&port=6881&uploaded=0&downloaded=0&left=1502576640&event=started&compact=1

并且跟踪器回复:

  

d8:completei2134e10:incompletei100e8:intervali1800e5:peers300:[二进制数据...] e

成功!