yuzu-emu
/
yuzu
Archived
1
0
Fork 0

LDN Hostname Support in Direct Connect

- Added IPv6 & Namespace support in direct connection Regex
- Updated Tooltip for Direct Connect UI
- Removed Dropdown Connection Type in Direct Connect
This commit is contained in:
SoRadGaming 2023-01-18 01:43:39 +11:00 committed by Sorab
parent 28fde29924
commit ad712926d6
3 changed files with 38 additions and 31 deletions

View File

@ -81,21 +81,14 @@ void DirectConnectWindow::Connect() {
} }
} }
} }
switch (static_cast<ConnectionType>(ui->connection_type->currentIndex())) {
case ConnectionType::TraversalServer:
break;
case ConnectionType::IP:
if (!ui->ip->hasAcceptableInput()) { if (!ui->ip->hasAcceptableInput()) {
NetworkMessage::ErrorManager::ShowError( NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::IP_ADDRESS_NOT_VALID);
NetworkMessage::ErrorManager::IP_ADDRESS_NOT_VALID);
return; return;
} }
if (!ui->port->hasAcceptableInput()) { if (!ui->port->hasAcceptableInput()) {
NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::PORT_NOT_VALID); NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::PORT_NOT_VALID);
return; return;
} }
break;
}
// Store settings // Store settings
UISettings::values.multiplayer_nickname = ui->nickname->text(); UISettings::values.multiplayer_nickname = ui->nickname->text();

View File

@ -26,20 +26,11 @@
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<item>
<widget class="QComboBox" name="connection_type">
<item>
<property name="text">
<string>IP Address</string>
</property>
</item>
</widget>
</item>
<item> <item>
<widget class="QWidget" name="ip_container" native="true"> <widget class="QWidget" name="ip_container" native="true">
<layout class="QHBoxLayout" name="ip_layout"> <layout class="QHBoxLayout" name="ip_layout">
<property name="leftMargin"> <property name="leftMargin">
<number>5</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
@ -53,17 +44,17 @@
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>IP</string> <string>Server Address</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="ip"> <widget class="QLineEdit" name="ip">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;IPv4 address of the host&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Server address of the host&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="maxLength"> <property name="maxLength">
<number>16</number> <number>253</number>
</property> </property>
</widget> </widget>
</item> </item>
@ -85,6 +76,12 @@
<property name="placeholderText"> <property name="placeholderText">
<string notr="true" extracomment="placeholder string that tells user default port">24872</string> <string notr="true" extracomment="placeholder string that tells user default port">24872</string>
</property> </property>
<property name="maximumSize">
<size>
<width>65</width>
<height>50</height>
</size>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -38,11 +38,28 @@ private:
QRegularExpression(QStringLiteral("^[a-zA-Z0-9._ -]{4,20}")); QRegularExpression(QStringLiteral("^[a-zA-Z0-9._ -]{4,20}"));
QRegularExpressionValidator nickname; QRegularExpressionValidator nickname;
/// ipv4 address only /// ipv4 / ipv6 / hostnames
// TODO remove this when we support hostnames in direct connect
QRegularExpression ip_regex = QRegularExpression(QStringLiteral( QRegularExpression ip_regex = QRegularExpression(QStringLiteral(
"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|" // IPv4 regex
"2[0-4][0-9]|25[0-5])")); "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|"
// IPv6 regex
"^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|"
"(([0-9A-Fa-f]{1,4}:){6}(:[0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|:)))(%.+)?$|"
// Hostname regex
"^([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\\.)+[a-zA-Z]{2,}$"));
QRegularExpressionValidator ip; QRegularExpressionValidator ip;
/// port must be between 0 and 65535 /// port must be between 0 and 65535