mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
cfdc1cdb2e
commit
9f8b0fed07
@ -132,22 +132,28 @@ ToxOptionsPtr initToxOptions(const QByteArray& savedata, const ICoreSettings* s)
|
||||
{
|
||||
// IPv6 needed for LAN discovery, but can crash some weird routers. On by default, can be
|
||||
// disabled in options.
|
||||
bool enableIPv6 = s->getEnableIPv6();
|
||||
bool forceTCP = s->getForceTCP();
|
||||
const bool enableIPv6 = s->getEnableIPv6();
|
||||
const bool forceTCP = s->getForceTCP();
|
||||
// LAN requiring UDP is a toxcore limitation, ideally wouldn't be related
|
||||
const bool enableLanDiscovery = s->getEnableLanDiscovery() && !forceTCP;
|
||||
ICoreSettings::ProxyType proxyType = s->getProxyType();
|
||||
quint16 proxyPort = s->getProxyPort();
|
||||
QString proxyAddr = s->getProxyAddr();
|
||||
QByteArray proxyAddrData = proxyAddr.toUtf8();
|
||||
|
||||
if (!enableLanDiscovery) {
|
||||
qWarning() << "Core starting without LAN discovery. Peers can only be found through DHT.";
|
||||
}
|
||||
if (enableIPv6) {
|
||||
qDebug() << "Core starting with IPv6 enabled";
|
||||
} else {
|
||||
} else if(enableLanDiscovery) {
|
||||
qWarning() << "Core starting with IPv6 disabled. LAN discovery may not work properly.";
|
||||
}
|
||||
|
||||
ToxOptionsPtr toxOptions = ToxOptionsPtr(tox_options_new(NULL));
|
||||
tox_options_set_ipv6_enabled(toxOptions.get(), enableIPv6);
|
||||
tox_options_set_udp_enabled(toxOptions.get(), !forceTCP);
|
||||
tox_options_set_local_discovery_enabled(toxOptions.get(), enableLanDiscovery);
|
||||
tox_options_set_start_port(toxOptions.get(), 0);
|
||||
tox_options_set_end_port(toxOptions.get(), 0);
|
||||
|
||||
|
@ -23,6 +23,9 @@ public:
|
||||
virtual bool getForceTCP() const = 0;
|
||||
virtual void setForceTCP(bool enable) = 0;
|
||||
|
||||
virtual bool getEnableLanDiscovery() const = 0;
|
||||
virtual void setEnableLanDiscovery(bool enable) = 0;
|
||||
|
||||
virtual QString getProxyAddr() const = 0;
|
||||
virtual void setProxyAddr(const QString& address) = 0;
|
||||
|
||||
@ -39,6 +42,7 @@ public:
|
||||
|
||||
DECLARE_SIGNAL(enableIPv6Changed, bool enabled);
|
||||
DECLARE_SIGNAL(forceTCPChanged, bool enabled);
|
||||
DECLARE_SIGNAL(enableLanDiscoveryChanged, bool enabled);
|
||||
DECLARE_SIGNAL(proxyTypeChanged, ICoreSettings::ProxyType type);
|
||||
DECLARE_SIGNAL(proxyAddressChanged, const QString& address);
|
||||
DECLARE_SIGNAL(proxyPortChanged, quint16 port);
|
||||
|
@ -192,6 +192,7 @@ void Settings::loadGlobal()
|
||||
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
||||
enableIPv6 = s.value("enableIPv6", true).toBool();
|
||||
forceTCP = s.value("forceTCP", false).toBool();
|
||||
enableLanDiscovery = s.value("enableLanDiscovery", true).toBool();
|
||||
}
|
||||
s.endGroup();
|
||||
|
||||
@ -508,6 +509,7 @@ void Settings::saveGlobal()
|
||||
s.setValue("makeToxPortable", makeToxPortable);
|
||||
s.setValue("enableIPv6", enableIPv6);
|
||||
s.setValue("forceTCP", forceTCP);
|
||||
s.setValue("enableLanDiscovery", enableLanDiscovery);
|
||||
s.setValue("dbSyncType", static_cast<int>(dbSyncType));
|
||||
}
|
||||
s.endGroup();
|
||||
@ -1225,6 +1227,22 @@ void Settings::setForceTCP(bool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
bool Settings::getEnableLanDiscovery() const
|
||||
{
|
||||
QMutexLocker locker{&bigLock};
|
||||
return enableLanDiscovery;
|
||||
}
|
||||
|
||||
void Settings::setEnableLanDiscovery(bool enabled)
|
||||
{
|
||||
QMutexLocker locker{&bigLock};
|
||||
|
||||
if (enabled != enableLanDiscovery) {
|
||||
enableLanDiscovery = enabled;
|
||||
emit enableLanDiscoveryChanged(enableLanDiscovery);
|
||||
}
|
||||
}
|
||||
|
||||
QNetworkProxy Settings::getProxy() const
|
||||
{
|
||||
QNetworkProxy proxy;
|
||||
|
@ -281,6 +281,9 @@ public:
|
||||
bool getForceTCP() const override;
|
||||
void setForceTCP(bool enabled) override;
|
||||
|
||||
bool getEnableLanDiscovery() const override;
|
||||
void setEnableLanDiscovery(bool enabled) override;
|
||||
|
||||
QString getProxyAddr() const override;
|
||||
void setProxyAddr(const QString& address) override;
|
||||
|
||||
@ -294,6 +297,7 @@ public:
|
||||
|
||||
SIGNAL_IMPL(Settings, enableIPv6Changed, bool enabled)
|
||||
SIGNAL_IMPL(Settings, forceTCPChanged, bool enabled)
|
||||
SIGNAL_IMPL(Settings, enableLanDiscoveryChanged, bool enabled)
|
||||
SIGNAL_IMPL(Settings, proxyTypeChanged, ICoreSettings::ProxyType type)
|
||||
SIGNAL_IMPL(Settings, proxyAddressChanged, const QString& address)
|
||||
SIGNAL_IMPL(Settings, proxyPortChanged, quint16 port)
|
||||
@ -583,6 +587,7 @@ private:
|
||||
bool groupAlwaysNotify;
|
||||
|
||||
bool forceTCP;
|
||||
bool enableLanDiscovery;
|
||||
|
||||
ICoreSettings::ProxyType proxyType;
|
||||
QString proxyAddr;
|
||||
|
@ -55,7 +55,10 @@ AdvancedForm::AdvancedForm()
|
||||
Settings& s = Settings::getInstance();
|
||||
bodyUI->cbEnableIPv6->setChecked(s.getEnableIPv6());
|
||||
bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable());
|
||||
bodyUI->cbEnableUDP->setChecked(!s.getForceTCP());
|
||||
const bool udpEnabled = !s.getForceTCP();
|
||||
bodyUI->cbEnableUDP->setChecked(udpEnabled);
|
||||
bodyUI->cbEnableLanDiscovery->setChecked(s.getEnableLanDiscovery());
|
||||
bodyUI->cbEnableLanDiscovery->setEnabled(udpEnabled);
|
||||
bodyUI->proxyAddr->setText(s.getProxyAddr());
|
||||
quint16 port = s.getProxyPort();
|
||||
if (port > 0)
|
||||
@ -172,7 +175,9 @@ void AdvancedForm::on_cbEnableIPv6_stateChanged()
|
||||
|
||||
void AdvancedForm::on_cbEnableUDP_stateChanged()
|
||||
{
|
||||
Settings::getInstance().setForceTCP(!bodyUI->cbEnableUDP->isChecked());
|
||||
const bool enableUdp = bodyUI->cbEnableUDP->isChecked();
|
||||
Settings::getInstance().setForceTCP(!enableUdp);
|
||||
bodyUI->cbEnableLanDiscovery->setEnabled(enableUdp);
|
||||
}
|
||||
|
||||
void AdvancedForm::on_proxyAddr_editingFinished()
|
||||
|
@ -121,6 +121,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<property name="leftMargin">
|
||||
<number>40</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbEnableLanDiscovery">
|
||||
<property name="text">
|
||||
<string>Enable LAN discovery</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user