HelloZeroNet / HelloZeroNet/ZeroNet

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

Đang mở
#2,736 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
18.8k
Fork
2.3k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
networking
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.