NOISSUE Use Vanilla logic for resolving servers
This commit is contained in:
parent
0ccd7223fd
commit
d97f13b4aa
@ -16,11 +16,6 @@ void LookupServerAddress::setLookupAddress(const QString &lookupAddress)
|
|||||||
m_dnsLookup->setName(QString("_minecraft._tcp.%1").arg(lookupAddress));
|
m_dnsLookup->setName(QString("_minecraft._tcp.%1").arg(lookupAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LookupServerAddress::setPort(quint16 port)
|
|
||||||
{
|
|
||||||
m_port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LookupServerAddress::setOutputAddressPtr(MinecraftServerTargetPtr output)
|
void LookupServerAddress::setOutputAddressPtr(MinecraftServerTargetPtr output)
|
||||||
{
|
{
|
||||||
m_output = std::move(output);
|
m_output = std::move(output);
|
||||||
@ -50,7 +45,7 @@ void LookupServerAddress::on_dnsLookupFinished()
|
|||||||
{
|
{
|
||||||
emit logLine(QString("Failed to resolve server address (this is NOT an error!) %1: %2\n")
|
emit logLine(QString("Failed to resolve server address (this is NOT an error!) %1: %2\n")
|
||||||
.arg(m_dnsLookup->name(), m_dnsLookup->errorString()), MessageLevel::MultiMC);
|
.arg(m_dnsLookup->name(), m_dnsLookup->errorString()), MessageLevel::MultiMC);
|
||||||
resolve(m_lookupAddress, m_port); // Technically the task failed, however, we don't abort the launch
|
resolve(m_lookupAddress, 25565); // Technically the task failed, however, we don't abort the launch
|
||||||
// and leave it up to minecraft to fail (or maybe not) when connecting
|
// and leave it up to minecraft to fail (or maybe not) when connecting
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -61,28 +56,17 @@ void LookupServerAddress::on_dnsLookupFinished()
|
|||||||
emit logLine(
|
emit logLine(
|
||||||
QString("Failed to resolve server address %1: the DNS lookup succeeded, but no records were returned.\n")
|
QString("Failed to resolve server address %1: the DNS lookup succeeded, but no records were returned.\n")
|
||||||
.arg(m_dnsLookup->name()), MessageLevel::Warning);
|
.arg(m_dnsLookup->name()), MessageLevel::Warning);
|
||||||
resolve(m_lookupAddress, m_port); // Technically the task failed, however, we don't abort the launch
|
resolve(m_lookupAddress, 25565); // Technically the task failed, however, we don't abort the launch
|
||||||
// and leave it up to minecraft to fail (or maybe not) when connecting
|
// and leave it up to minecraft to fail (or maybe not) when connecting
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &firstRecord = records.at(0);
|
const auto &firstRecord = records.at(0);
|
||||||
|
quint16 port = firstRecord.port();
|
||||||
if (firstRecord.port() != m_port && m_port != 0)
|
|
||||||
{
|
|
||||||
emit logLine(
|
|
||||||
QString("DNS record for %1 suggested %2 as server port, but user supplied %3. Using user override,"
|
|
||||||
" but the port may be wrong!\n").arg(m_dnsLookup->name(), QString::number(firstRecord.port()), QString::number(m_port)),
|
|
||||||
MessageLevel::Warning);
|
|
||||||
}
|
|
||||||
else if (m_port == 0)
|
|
||||||
{
|
|
||||||
m_port = firstRecord.port();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit logLine(QString("Resolved server address %1 to %2 with port %3\n").arg(
|
emit logLine(QString("Resolved server address %1 to %2 with port %3\n").arg(
|
||||||
m_dnsLookup->name(), firstRecord.target(), QString::number(m_port)),MessageLevel::MultiMC);
|
m_dnsLookup->name(), firstRecord.target(), QString::number(port)),MessageLevel::MultiMC);
|
||||||
resolve(firstRecord.target(), m_port);
|
resolve(firstRecord.target(), port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LookupServerAddress::resolve(const QString &address, quint16 port)
|
void LookupServerAddress::resolve(const QString &address, quint16 port)
|
||||||
|
@ -35,7 +35,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setLookupAddress(const QString &lookupAddress);
|
void setLookupAddress(const QString &lookupAddress);
|
||||||
void setPort(quint16 port);
|
|
||||||
void setOutputAddressPtr(MinecraftServerTargetPtr output);
|
void setOutputAddressPtr(MinecraftServerTargetPtr output);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -46,6 +45,5 @@ private:
|
|||||||
|
|
||||||
QDnsLookup *m_dnsLookup;
|
QDnsLookup *m_dnsLookup;
|
||||||
QString m_lookupAddress;
|
QString m_lookupAddress;
|
||||||
quint16 m_port;
|
|
||||||
MinecraftServerTargetPtr m_output;
|
MinecraftServerTargetPtr m_output;
|
||||||
};
|
};
|
||||||
|
@ -859,12 +859,20 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
|
|||||||
|
|
||||||
if (m_settings->get("JoinServerOnLaunch").toBool())
|
if (m_settings->get("JoinServerOnLaunch").toBool())
|
||||||
{
|
{
|
||||||
// Resolve server address to join on launch
|
quint16 port = m_settings->get("JoinServerOnLaunchPort").toInt();
|
||||||
auto *step = new LookupServerAddress(pptr);
|
QString address = m_settings->get("JoinServerOnLaunchAddress").toString();
|
||||||
step->setLookupAddress(m_settings->get("JoinServerOnLaunchAddress").toString());
|
|
||||||
step->setPort(m_settings->get("JoinServerOnLaunchPort").toInt());
|
serverToJoin->port = port;
|
||||||
step->setOutputAddressPtr(serverToJoin);
|
serverToJoin->address = address;
|
||||||
process->appendStep(step);
|
|
||||||
|
if(port == 25565)
|
||||||
|
{
|
||||||
|
// Resolve server address to join on launch
|
||||||
|
auto *step = new LookupServerAddress(pptr);
|
||||||
|
step->setLookupAddress(address);
|
||||||
|
step->setOutputAddressPtr(serverToJoin);
|
||||||
|
process->appendStep(step);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// run pre-launch command if that's needed
|
// run pre-launch command if that's needed
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
<enum>QTabWidget::Rounded</enum>
|
<enum>QTabWidget::Rounded</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>4</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="minecraftTab">
|
<widget class="QWidget" name="minecraftTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
Loading…
Reference in New Issue
Block a user