diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/multiplayer/direct_connect.cpp | 21 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/direct_connect.ui | 23 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/validation.h | 25 |
3 files changed, 38 insertions, 31 deletions
diff --git a/src/yuzu/multiplayer/direct_connect.cpp b/src/yuzu/multiplayer/direct_connect.cpp index cbd52da85..d71cc23a7 100644 --- a/src/yuzu/multiplayer/direct_connect.cpp +++ b/src/yuzu/multiplayer/direct_connect.cpp | |||
| @@ -81,20 +81,13 @@ void DirectConnectWindow::Connect() { | |||
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | } | 83 | } |
| 84 | switch (static_cast<ConnectionType>(ui->connection_type->currentIndex())) { | 84 | if (!ui->ip->hasAcceptableInput()) { |
| 85 | case ConnectionType::TraversalServer: | 85 | NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::IP_ADDRESS_NOT_VALID); |
| 86 | break; | 86 | return; |
| 87 | case ConnectionType::IP: | 87 | } |
| 88 | if (!ui->ip->hasAcceptableInput()) { | 88 | if (!ui->port->hasAcceptableInput()) { |
| 89 | NetworkMessage::ErrorManager::ShowError( | 89 | NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::PORT_NOT_VALID); |
| 90 | NetworkMessage::ErrorManager::IP_ADDRESS_NOT_VALID); | 90 | return; |
| 91 | return; | ||
| 92 | } | ||
| 93 | if (!ui->port->hasAcceptableInput()) { | ||
| 94 | NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::PORT_NOT_VALID); | ||
| 95 | return; | ||
| 96 | } | ||
| 97 | break; | ||
| 98 | } | 91 | } |
| 99 | 92 | ||
| 100 | // Store settings | 93 | // Store settings |
diff --git a/src/yuzu/multiplayer/direct_connect.ui b/src/yuzu/multiplayer/direct_connect.ui index 57d6ec25a..0dd4e6829 100644 --- a/src/yuzu/multiplayer/direct_connect.ui +++ b/src/yuzu/multiplayer/direct_connect.ui | |||
| @@ -27,19 +27,10 @@ | |||
| 27 | <number>0</number> | 27 | <number>0</number> |
| 28 | </property> | 28 | </property> |
| 29 | <item> | 29 | <item> |
| 30 | <widget class="QComboBox" name="connection_type"> | ||
| 31 | <item> | ||
| 32 | <property name="text"> | ||
| 33 | <string>IP Address</string> | ||
| 34 | </property> | ||
| 35 | </item> | ||
| 36 | </widget> | ||
| 37 | </item> | ||
| 38 | <item> | ||
| 39 | <widget class="QWidget" name="ip_container" native="true"> | 30 | <widget class="QWidget" name="ip_container" native="true"> |
| 40 | <layout class="QHBoxLayout" name="ip_layout"> | 31 | <layout class="QHBoxLayout" name="ip_layout"> |
| 41 | <property name="leftMargin"> | 32 | <property name="leftMargin"> |
| 42 | <number>5</number> | 33 | <number>0</number> |
| 43 | </property> | 34 | </property> |
| 44 | <property name="topMargin"> | 35 | <property name="topMargin"> |
| 45 | <number>0</number> | 36 | <number>0</number> |
| @@ -53,17 +44,17 @@ | |||
| 53 | <item> | 44 | <item> |
| 54 | <widget class="QLabel" name="label_2"> | 45 | <widget class="QLabel" name="label_2"> |
| 55 | <property name="text"> | 46 | <property name="text"> |
| 56 | <string>IP</string> | 47 | <string>Server Address</string> |
| 57 | </property> | 48 | </property> |
| 58 | </widget> | 49 | </widget> |
| 59 | </item> | 50 | </item> |
| 60 | <item> | 51 | <item> |
| 61 | <widget class="QLineEdit" name="ip"> | 52 | <widget class="QLineEdit" name="ip"> |
| 62 | <property name="toolTip"> | 53 | <property name="toolTip"> |
| 63 | <string><html><head/><body><p>IPv4 address of the host</p></body></html></string> | 54 | <string><html><head/><body><p>Server address of the host</p></body></html></string> |
| 64 | </property> | 55 | </property> |
| 65 | <property name="maxLength"> | 56 | <property name="maxLength"> |
| 66 | <number>16</number> | 57 | <number>253</number> |
| 67 | </property> | 58 | </property> |
| 68 | </widget> | 59 | </widget> |
| 69 | </item> | 60 | </item> |
| @@ -85,6 +76,12 @@ | |||
| 85 | <property name="placeholderText"> | 76 | <property name="placeholderText"> |
| 86 | <string notr="true" extracomment="placeholder string that tells user default port">24872</string> | 77 | <string notr="true" extracomment="placeholder string that tells user default port">24872</string> |
| 87 | </property> | 78 | </property> |
| 79 | <property name="maximumSize"> | ||
| 80 | <size> | ||
| 81 | <width>65</width> | ||
| 82 | <height>50</height> | ||
| 83 | </size> | ||
| 84 | </property> | ||
| 88 | </widget> | 85 | </widget> |
| 89 | </item> | 86 | </item> |
| 90 | </layout> | 87 | </layout> |
diff --git a/src/yuzu/multiplayer/validation.h b/src/yuzu/multiplayer/validation.h index dd25af280..cbbe6757b 100644 --- a/src/yuzu/multiplayer/validation.h +++ b/src/yuzu/multiplayer/validation.h | |||
| @@ -38,11 +38,28 @@ private: | |||
| 38 | QRegularExpression(QStringLiteral("^[a-zA-Z0-9._ -]{4,20}")); | 38 | QRegularExpression(QStringLiteral("^[a-zA-Z0-9._ -]{4,20}")); |
| 39 | QRegularExpressionValidator nickname; | 39 | QRegularExpressionValidator nickname; |
| 40 | 40 | ||
| 41 | /// ipv4 address only | 41 | /// ipv4 / ipv6 / hostnames |
| 42 | // TODO remove this when we support hostnames in direct connect | ||
| 43 | QRegularExpression ip_regex = QRegularExpression(QStringLiteral( | 42 | QRegularExpression ip_regex = QRegularExpression(QStringLiteral( |
| 44 | "(([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}|" | 43 | // IPv4 regex |
| 45 | "2[0-4][0-9]|25[0-5])")); | 44 | "^((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]?)$|" |
| 45 | // IPv6 regex | ||
| 46 | "^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|" | ||
| 47 | "(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-" | ||
| 48 | "5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|" | ||
| 49 | "(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" | ||
| 50 | "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|" | ||
| 51 | "(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]" | ||
| 52 | "\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" | ||
| 53 | "(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[" | ||
| 54 | "0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" | ||
| 55 | "(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[" | ||
| 56 | "0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" | ||
| 57 | "(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[" | ||
| 58 | "0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" | ||
| 59 | "(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?" | ||
| 60 | "\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?$|" | ||
| 61 | // Hostname regex | ||
| 62 | "^([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\\.)+[a-zA-Z]{2,}$")); | ||
| 46 | QRegularExpressionValidator ip; | 63 | QRegularExpressionValidator ip; |
| 47 | 64 | ||
| 48 | /// port must be between 0 and 65535 | 65 | /// port must be between 0 and 65535 |