mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 13:18:06 -06:00
Merge pull request #5096 from Harekiet/kietC
Bind directly to an IP instead of using a network Interface
This commit is contained in:
@@ -1735,9 +1735,11 @@ const QStringList Session::getListeningIPs()
|
||||
QStringList IPs;
|
||||
|
||||
const QString ifaceName = pref->getNetworkInterface();
|
||||
const QString ifaceAddr = pref->getNetworkInterfaceAddress();
|
||||
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());
|
||||
return IPs;
|
||||
}
|
||||
@@ -1764,6 +1766,13 @@ const QStringList Session::getListeningIPs()
|
||||
if ((!listenIPv6 && (protocol == QAbstractSocket::IPv6Protocol))
|
||||
|| (listenIPv6 && (protocol == QAbstractSocket::IPv4Protocol)))
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1339,6 +1339,16 @@ QString Preferences::getNetworkInterfaceName() const
|
||||
return value("Preferences/Connection/InterfaceName").toString();
|
||||
}
|
||||
|
||||
void Preferences::setNetworkInterfaceAddress(const QString& addr)
|
||||
{
|
||||
setValue("Preferences/Connection/InterfaceAddress", addr);
|
||||
}
|
||||
|
||||
QString Preferences::getNetworkInterfaceAddress() const
|
||||
{
|
||||
return value("Preferences/Connection/InterfaceAddress").toString();
|
||||
}
|
||||
|
||||
void Preferences::setNetworkInterfaceName(const QString& iface)
|
||||
{
|
||||
setValue("Preferences/Connection/InterfaceName", iface);
|
||||
|
||||
@@ -361,6 +361,8 @@ public:
|
||||
void setMaxHalfOpenConnections(int value);
|
||||
QString getNetworkInterface() const;
|
||||
void setNetworkInterface(const QString& iface);
|
||||
QString getNetworkInterfaceAddress() const;
|
||||
void setNetworkInterfaceAddress(const QString& addr);
|
||||
QString getNetworkInterfaceName() const;
|
||||
void setNetworkInterfaceName(const QString& iface);
|
||||
bool getListenIPv6() const;
|
||||
|
||||
Reference in New Issue
Block a user