Compare commits

...

2 Commits

Author SHA1 Message Date
Benjamin
7b09aa8cc3 New regex for IP + Hostname validation in multiplayer direct connect 2022-10-13 12:45:30 +02:00
Benjamin
89f81ab46e Allow hostnames in LDN direct connect 2022-09-27 00:07:05 +02:00
2 changed files with 9 additions and 6 deletions

View File

@@ -63,7 +63,7 @@
<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>
</property>
<property name="maxLength">
<number>16</number>
<number>253</number>
</property>
</widget>
</item>

View File

@@ -17,12 +17,15 @@ public:
const QValidator* GetRoomName() const {
return &room_name;
}
const QValidator* GetNickname() const {
return &nickname;
}
const QValidator* GetIP() const {
return &ip;
}
const QValidator* GetPort() const {
return &port;
}
@@ -36,11 +39,11 @@ private:
QRegExp nickname_regex = QRegExp(QStringLiteral("^[a-zA-Z0-9._- ]{4,20}$"));
QRegExpValidator nickname;
/// ipv4 address only
// TODO remove this when we support hostnames in direct connect
QRegExp ip_regex = QRegExp(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}|"
"2[0-4][0-9]|25[0-5])"));
/// Allow ip address and hostname
QRegExp ip_regex =
QRegExp(QStringLiteral("^(?:(?: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]?)$|^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*["
"a-zA-Z0-9])\.)+([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$"));
QRegExpValidator ip;
/// port must be between 0 and 65535