-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Announce to all trackers if IP changed #15001
Announce to all trackers if IP changed #15001
Conversation
- Add a timer in BitTorrent::Session to send a public ip address request to http://api64.ipify.org every 30 mins. - Once public ip address change is detected, force announce to all trackers. - This new feature is optional, can be toggled during running time, default is false.
…orceReannounce." This reverts commit d8c9972.
This reverts commit d892f0c.
This reverts commit 276179a.
This reverts commit 724a385.
…ublic-ip-change-detected' into pr-announce-to-all-trackers-if-public-ip-change-detected # Conflicts: # src/base/bittorrent/session.cpp # src/base/bittorrent/session.h # src/gui/advancedsettings.cpp # src/gui/advancedsettings.h
…d and set*Enabled style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last comment from me.
src/base/bittorrent/session.cpp
Outdated
.arg(toString(p->external_address)), Log::INFO); | ||
.arg(externalIP), Log::INFO); | ||
|
||
if (isReannounceWhenAddressChangedEnabled() && !m_lastExternalIP.isEmpty() && m_lastExternalIP != externalIP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rewrite it as the following :
if (m_lastExternalIP != externalIP)
{
if (!m_lastExternalIP.isEmpty() && isReannounceWhenAddressChangedEnabled())
reannounceToAllTrackers();
m_lastExternalIP = externalIP;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Cool, just checking. I got a little scared after seeing your approval already, but now it makes sense :) |
@zhuangzi926 |
Update
2021.05.22
m_isReannouncdWhenAddressChangedEnabled
init in session.cpp2021.05.20
*ReannounceWhenAddressChanged
to*ReannounceWhenAddressChangedEnabled
2021.05.18
Motivation
Try to implement this feature request: issue #14545.
Considering many users run qbt behind NATs, it's quiet cumbersome for them to tolerate frequent torrent not available issue because of public IP change.
So I came up with this direct idea to
regularly detect public ipcatch external IP change alert from libtorrent, and announce it to all trackers if change happens.Brief of this PR
Add a timer inBitTorrent::Session
to send a public ip address request to http://api64.ipify.org every 30 mins.Once public ip address change is detected, force announce to all trackers.Update dyndns service register url to the latest one.About external/public IP detection
Although it's known that libtorrent can get extern ip through communications with trackers and peers, it seems that libtorrent only catches this ip change alert but not try to reannounce to improve efficiency. Moreover, the interval of external ip detection behavior by libtorrent is uncertain and unpredicatable(to some extent) for downstream apps like qbt, it would probably be better to implement this logic by qbt itself.I have found identical codes insrc/base/net/dnsupdater.cpp
, which uses a timer to ask public dns provider to update domain-ip binding if ip changed. Reimplemention of this logic inBitTorrent::Session
might introduce incompatibility problems, which may need assistance from professional reviewers.It is now known that libtorrent catches external IP change alert in an interval of 5 minutes, and qbt regularly reannounce(if ignore tracker settings) every 30 minutes. So it would be better if we implement this feature request by adding an option to force reannounce when external IP or listening port changes(before this PR qbt just catches these alerts but sends nothing). There is no need to introduce a new QTimer or external IP request from another third party.
Control this feature by GUI users
GUI control to set ip detection interval and switch on/off this new feature are needed for our end-users.I'm not good at coping with codes insrc/gui
, hoping other contributors might help with this new feature.GUI checkboxes for both desktop and web ui are implemented following 5161758.