HTTP and HTTPS tracker completely broken if use address as the hostname instead of IP
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