Browse Source

Change back to the original names for the announce address

Only allow ip's through that match the currenrly selected network interface and address
adaptive-webui-19844
Sjoerd van der Berg 9 years ago
parent
commit
c7c71d3c88
  1. 20
      src/base/bittorrent/session.cpp
  2. 14
      src/base/preferences.cpp
  3. 8
      src/base/preferences.h
  4. 30
      src/gui/advancedsettings.cpp
  5. 3
      src/gui/advancedsettings.h

20
src/base/bittorrent/session.cpp

@ -633,7 +633,7 @@ void Session::setSessionSettings()
// Include overhead in transfer limits // Include overhead in transfer limits
sessionSettings.rate_limit_ip_overhead = pref->includeOverheadInLimits(); sessionSettings.rate_limit_ip_overhead = pref->includeOverheadInLimits();
// IP address to announce to trackers // IP address to announce to trackers
sessionSettings.announce_ip = Utils::String::toStdString(pref->getAnnounceAddress()); sessionSettings.announce_ip = Utils::String::toStdString(pref->getNetworkAddress());
// Super seeding // Super seeding
sessionSettings.strict_super_seeding = pref->isSuperSeedingEnabled(); sessionSettings.strict_super_seeding = pref->isSuperSeedingEnabled();
// * Max Half-open connections // * Max Half-open connections
@ -1658,17 +1658,12 @@ const QStringList Session::getListeningIPs()
Logger* const logger = Logger::instance(); Logger* const logger = Logger::instance();
QStringList IPs; QStringList IPs;
//Take the override addresss
const QString networkAddr = pref->getNetworkAddress();
if ( !networkAddr.isEmpty()) {
IPs.append( networkAddr);
return IPs;
}
const QString ifaceName = pref->getNetworkInterface(); const QString ifaceName = pref->getNetworkInterface();
const QString ifaceAddr = pref->getNetworkInterfaceAddress();
const bool listenIPv6 = pref->getListenIPv6(); const bool listenIPv6 = pref->getListenIPv6();
if (ifaceName.isEmpty()) { //No interface name or address defined just use an empty list
if (ifaceName.isEmpty() && ifaceAddr.isEmpty()) {
IPs.append(QString()); IPs.append(QString());
return IPs; return IPs;
} }
@ -1695,6 +1690,13 @@ const QStringList Session::getListeningIPs()
if ((!listenIPv6 && (protocol == QAbstractSocket::IPv6Protocol)) if ((!listenIPv6 && (protocol == QAbstractSocket::IPv6Protocol))
|| (listenIPv6 && (protocol == QAbstractSocket::IPv4Protocol))) || (listenIPv6 && (protocol == QAbstractSocket::IPv4Protocol)))
continue; continue;
//If an iface address has been defined only allow ip's that match it to go through
if (!ifaceAddr.isEmpty()) {
if (ipString != ifaceAddr) {
continue;
}
}
IPs.append(ipString); IPs.append(ipString);
} }

14
src/base/preferences.cpp

@ -1349,12 +1349,12 @@ QString Preferences::getNetworkInterfaceName() const
return value("Preferences/Connection/InterfaceName").toString(); return value("Preferences/Connection/InterfaceName").toString();
} }
void Preferences::setNetworkAddress(const QString& iface) void Preferences::setNetworkInterfaceAddress(const QString& addr)
{ {
setValue("Preferences/Connection/InterfaceAddress", iface); setValue("Preferences/Connection/InterfaceAddress", addr);
} }
QString Preferences::getNetworkAddress() const QString Preferences::getNetworkInterfaceAddress() const
{ {
return value("Preferences/Connection/InterfaceAddress").toString(); return value("Preferences/Connection/InterfaceAddress").toString();
} }
@ -1374,14 +1374,14 @@ void Preferences::setListenIPv6(bool enable)
setValue("Preferences/Connection/InterfaceListenIPv6", enable); setValue("Preferences/Connection/InterfaceListenIPv6", enable);
} }
QString Preferences::getAnnounceAddress() const QString Preferences::getNetworkAddress() const
{ {
return value("Preferences/Connection/AnnounceAddress").toString(); return value("Preferences/Connection/InetAddress").toString();
} }
void Preferences::setAnnounceAddress(const QString& addr) void Preferences::setNetworkAddress(const QString& addr)
{ {
setValue("Preferences/Connection/AnnounceAddress", addr); setValue("Preferences/Connection/InetAddress", addr);
} }
bool Preferences::isAnonymousModeEnabled() const bool Preferences::isAnonymousModeEnabled() const

8
src/base/preferences.h

@ -363,14 +363,14 @@ public:
void setMaxHalfOpenConnections(int value); void setMaxHalfOpenConnections(int value);
QString getNetworkInterface() const; QString getNetworkInterface() const;
void setNetworkInterface(const QString& iface); void setNetworkInterface(const QString& iface);
QString getNetworkAddress() const; QString getNetworkInterfaceAddress() const;
void setNetworkAddress(const QString& iface); void setNetworkInterfaceAddress(const QString& addr);
QString getNetworkInterfaceName() const; QString getNetworkInterfaceName() const;
void setNetworkInterfaceName(const QString& iface); void setNetworkInterfaceName(const QString& iface);
bool getListenIPv6() const; bool getListenIPv6() const;
void setListenIPv6(bool enable); void setListenIPv6(bool enable);
QString getAnnounceAddress() const; QString getNetworkAddress() const;
void setAnnounceAddress(const QString& addr); void setNetworkAddress(const QString& addr);
bool isAnonymousModeEnabled() const; bool isAnonymousModeEnabled() const;
void enableAnonymousMode(bool enabled); void enableAnonymousMode(bool enabled);
bool isSuperSeedingEnabled() const; bool isSuperSeedingEnabled() const;

30
src/gui/advancedsettings.cpp

@ -45,8 +45,8 @@ enum AdvSettingsRows
QBITTORRENT_HEADER, QBITTORRENT_HEADER,
// network interface // network interface
NETWORK_IFACE, NETWORK_IFACE,
//Optional bind address //Optional network address
NETWORK_ADDRESS, NETWORK_IFACE_ADDRESS,
NETWORK_LISTEN_IPV6, NETWORK_LISTEN_IPV6,
// behavior // behavior
SAVE_RESUME_DATA_INTERVAL, SAVE_RESUME_DATA_INTERVAL,
@ -82,7 +82,7 @@ enum AdvSettingsRows
// tracker // tracker
TRACKER_EXCHANGE, TRACKER_EXCHANGE,
ANNOUNCE_ALL_TRACKERS, ANNOUNCE_ALL_TRACKERS,
ANNOUNCE_ADDRESS, NETWORK_ADDRESS,
ROW_COUNT ROW_COUNT
}; };
@ -145,18 +145,18 @@ void AdvancedSettings::saveAdvancedSettings()
} }
// Listen on IPv6 address // Listen on IPv6 address
pref->setListenIPv6(cb_listen_ipv6.isChecked()); pref->setListenIPv6(cb_listen_ipv6.isChecked());
// Network address // Interface address
QHostAddress ifaceAddr(txt_iface_address.text().trimmed());
if (ifaceAddr.isNull())
pref->setNetworkInterfaceAddress("");
else
pref->setNetworkInterfaceAddress(ifaceAddr.toString());
// Network Announce address
QHostAddress networkAddr(txt_network_address.text().trimmed()); QHostAddress networkAddr(txt_network_address.text().trimmed());
if (networkAddr.isNull()) if (networkAddr.isNull())
pref->setNetworkAddress(""); pref->setNetworkAddress("");
else else
pref->setNetworkAddress(networkAddr.toString()); pref->setNetworkAddress(networkAddr.toString());
// Announce address
QHostAddress announceAddr(txt_announce_address.text().trimmed());
if (announceAddr.isNull())
pref->setAnnounceAddress("");
else
pref->setAnnounceAddress(announceAddr.toString());
// Program notification // Program notification
pref->useProgramNotification(cb_program_notifications.isChecked()); pref->useProgramNotification(cb_program_notifications.isChecked());
@ -283,12 +283,12 @@ void AdvancedSettings::loadAdvancedSettings()
// Listen on IPv6 address // Listen on IPv6 address
cb_listen_ipv6.setChecked(pref->getListenIPv6()); cb_listen_ipv6.setChecked(pref->getListenIPv6());
addRow(NETWORK_LISTEN_IPV6, tr("Listen on IPv6 address (requires restart)"), &cb_listen_ipv6); addRow(NETWORK_LISTEN_IPV6, tr("Listen on IPv6 address (requires restart)"), &cb_listen_ipv6);
// Network address // Network interface address
txt_iface_address.setText(pref->getNetworkInterfaceAddress());
addRow(NETWORK_IFACE_ADDRESS, tr("Optional IP Address to bind to (requires restart)"), &txt_iface_address);
// Announce address
txt_network_address.setText(pref->getNetworkAddress()); txt_network_address.setText(pref->getNetworkAddress());
addRow(NETWORK_ADDRESS, tr("IP Address to bind to( requires restart))"), &txt_network_address); addRow(NETWORK_ADDRESS, tr("IP Address to report to trackers (requires restart)"), &txt_network_address);
// Network address
txt_announce_address.setText(pref->getAnnounceAddress());
addRow(ANNOUNCE_ADDRESS, tr("IP Address to report to trackers (requires restart)"), &txt_announce_address);
// Program notifications // Program notifications
cb_program_notifications.setChecked(pref->useProgramNotification()); cb_program_notifications.setChecked(pref->useProgramNotification());

3
src/gui/advancedsettings.h

@ -63,8 +63,7 @@ private:
cb_super_seeding, cb_program_notifications, cb_tracker_status, cb_super_seeding, cb_program_notifications, cb_tracker_status,
cb_confirm_torrent_recheck, cb_enable_tracker_ext, cb_listen_ipv6, cb_announce_all_trackers; cb_confirm_torrent_recheck, cb_enable_tracker_ext, cb_listen_ipv6, cb_announce_all_trackers;
QComboBox combo_iface; QComboBox combo_iface;
QLineEdit txt_announce_address; QLineEdit txt_iface_address, network_address;
QLineEdit txt_network_address;
// OS dependent settings // OS dependent settings
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) #if defined(Q_OS_WIN) || defined(Q_OS_MAC)

Loading…
Cancel
Save