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));
|
||||
}
|
||||
|
||||
void LookupServerAddress::setPort(quint16 port)
|
||||
{
|
||||
m_port = port;
|
||||
}
|
||||
|
||||
void LookupServerAddress::setOutputAddressPtr(MinecraftServerTargetPtr 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")
|
||||
.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
|
||||
return;
|
||||
}
|
||||
@ -61,28 +56,17 @@ void LookupServerAddress::on_dnsLookupFinished()
|
||||
emit logLine(
|
||||
QString("Failed to resolve server address %1: the DNS lookup succeeded, but no records were returned.\n")
|
||||
.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
|
||||
return;
|
||||
}
|
||||
|
||||
const auto &firstRecord = records.at(0);
|
||||
|
||||
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();
|
||||
}
|
||||
quint16 port = firstRecord.port();
|
||||
|
||||
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);
|
||||
resolve(firstRecord.target(), m_port);
|
||||
m_dnsLookup->name(), firstRecord.target(), QString::number(port)),MessageLevel::MultiMC);
|
||||
resolve(firstRecord.target(), port);
|
||||
}
|
||||
|
||||
void LookupServerAddress::resolve(const QString &address, quint16 port)
|
||||
|
@ -35,7 +35,6 @@ public:
|
||||
}
|
||||
|
||||
void setLookupAddress(const QString &lookupAddress);
|
||||
void setPort(quint16 port);
|
||||
void setOutputAddressPtr(MinecraftServerTargetPtr output);
|
||||
|
||||
private slots:
|
||||
@ -46,6 +45,5 @@ private:
|
||||
|
||||
QDnsLookup *m_dnsLookup;
|
||||
QString m_lookupAddress;
|
||||
quint16 m_port;
|
||||
MinecraftServerTargetPtr m_output;
|
||||
};
|
||||
|
@ -859,12 +859,20 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
|
||||
|
||||
if (m_settings->get("JoinServerOnLaunch").toBool())
|
||||
{
|
||||
// Resolve server address to join on launch
|
||||
auto *step = new LookupServerAddress(pptr);
|
||||
step->setLookupAddress(m_settings->get("JoinServerOnLaunchAddress").toString());
|
||||
step->setPort(m_settings->get("JoinServerOnLaunchPort").toInt());
|
||||
step->setOutputAddressPtr(serverToJoin);
|
||||
process->appendStep(step);
|
||||
quint16 port = m_settings->get("JoinServerOnLaunchPort").toInt();
|
||||
QString address = m_settings->get("JoinServerOnLaunchAddress").toString();
|
||||
|
||||
serverToJoin->port = port;
|
||||
serverToJoin->address = address;
|
||||
|
||||
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
|
||||
|
@ -39,7 +39,7 @@
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="minecraftTab">
|
||||
<attribute name="title">
|
||||
|
Loading…
Reference in New Issue
Block a user