HelloZeroNet / HelloZeroNet/ZeroNet

HTTP and HTTPS tracker completely broken if use address as the hostname instead of IP

未关闭
#2,736 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
18.8k
派生
2.3k
PR 合并指标
30 天内没有已合并 PR

描述

Hello all.

## The issue

Everything tested on **r4555**.

If you have opened the port and you define the tracker address as `open.acgnxtracker.com` instead of IP address you will send to the tracker your opened port as `1` (means not-connectable) instead of your correct port.

I have disabled TOR, Bootstrap, AnnounceLocal, AnnounceShare, AnnounceZero and I was wondering, why after 1 hour I have exactly 0 peers for ZeroHello, ZeroName?

---

## How to reproduce?

Please check that line
https://github.com/HelloZeroNet/ZeroNet/blob/454c0b2e7e000fda7000cba49027541fbf327b96/plugins/AnnounceBitTorrent/AnnounceBitTorrentPlugin.py#L104

I have put that lines below to debug:
```
self.site.log.debug("SiteAnnouncerPlugin - Calculated port: %s" % port)
self.site.log.debug("SiteAnnouncerPlugin - Tracker IP type: %s" % helper.getIpType(tracker_ip))
self.site.log.debug("SiteAnnouncerPlugin - Opened Services: %s" % self.getOpenedServiceTypes())
self.site.log.debug("SiteAnnouncerPlugin - Server Port: %s" % self.fileserver_port)
self.site.log.debug("SiteAnnouncerPlugin - tracker_ip: %s" % tracker_ip)
```

And got:
```
[2021-02-20 16:47:56,377] DEBUG Site:XXXXXX..XXXX SiteAnnouncerPlugin - Calculated port: 1
[2021-02-20 16:47:56,377] DEBUG Site:XXXXXX..XXXX SiteAnnouncerPlugin - Tracker IP type: unknown
[2021-02-20 16:47:56,377] DEBUG Site:XXXXXX..XXXX SiteAnnouncerPlugin - Opened Services: ['ipv4']
[2021-02-20 16:47:56,377] DEBUG Site:XXXXXX..XXXX SiteAnnouncerPlugin - Server Port: 12345
[2021-02-20 16:47:56,377] DEBUG Site:XXXXXX..XXXX SiteAnnouncerPlugin - tracker_ip: open.acgnxtracker.com
```

## What does it mean?

Function `helper.getIpType("open.acgnxtracker.com")` returns `unknown` because `open.acgnxtracker.com` is a hostname not IP address. Is unknown so we send to tracker `port=1` instead of `port=12345`.

In Config.py we have configured 3 trackers:
```
"http://h4.trakx.nibba.trade:80/announce", # US/VA
"http://open.acgnxtracker.com:80/announce", # DE
"http://tracker.bt4g.com:2095/announce", # Cloudflare
```

When you try to send a request to the tracker you will see almost all of the ports equal 1 - so most of the servers through HTTP/S trackers are not reachable.

---

BTW

https://github.com/HelloZeroNet/ZeroNet/blob/454c0b2e7e000fda7000cba49027541fbf327b96/plugins/AnnounceBitTorrent/AnnounceBitTorrentPlugin.py#L103

If you skip port number e.g. `http://open.acgnxtracker.com/announce` you will get the error:
```
Tracker http://open.acgnxtracker.com/announce announce failed: ValueError: not enough values to unpack (expected 2, got 1)
```

I think we should add default port 80 if HTTP and 443 if https

贡献指南

这个仓库没有索引到贡献指南

调研方向

Start in plugins/AnnounceBitTorrent/AnnounceBitTorrentPlugin.py around lines 103-104, then inspect helper.getIpType and the tracker URL port parsing. Reproduce the hostname and omitted-port cases described in the issue. Done means HTTP and HTTPS tracker hostnames produce the configured server port, and URLs without explicit ports no longer raise the reported unpacking error.

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
networking
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。