Changeset View
Changeset View
Standalone View
Standalone View
libs/editor/settings/wireguardpeerwidget.cpp
Show First 20 Lines • Show All 193 Lines • ▼ Show 20 Line(s) | 185 | { | |||
---|---|---|---|---|---|
194 | if (valid != d->allowedIPsValid) { | 194 | if (valid != d->allowedIPsValid) { | ||
195 | d->allowedIPsValid = valid; | 195 | d->allowedIPsValid = valid; | ||
196 | slotWidgetChanged(); | 196 | slotWidgetChanged(); | ||
197 | } | 197 | } | ||
198 | } | 198 | } | ||
199 | 199 | | |||
200 | WireGuardPeerWidget::EndPointValid WireGuardPeerWidget::isEndpointValid(QString &address, QString &port) | 200 | WireGuardPeerWidget::EndPointValid WireGuardPeerWidget::isEndpointValid(QString &address, QString &port) | ||
201 | { | 201 | { | ||
202 | // Create a Reg Expression validator to do simple check for a valid qualified domain name | 202 | // Create a Reg Expression validator to do a simple check for a valid qualified domain name | ||
203 | // which checks to see that there are between 2 and 63 strings of at least 2 characters each | 203 | // which checks to see that there are between 2 and 63 strings of at least 1 character each | ||
204 | // separated by '.', so "ab.cc" is valid but "a.cc" is not. The full string must also be less | 204 | // separated by '.'. The full string must also be less than 255 characters long. | ||
205 | // than 255 characters long. | 205 | static QRegExpValidator fqdnValidator(QRegExp(QLatin1String("(?=.{3,254}$)([a-zA-Z0-9][a-zA-Z0-9-]{0,62}\\.){1,63}[a-zA-Z]{1,63}")), nullptr); | ||
206 | static QRegExpValidator fqdnValidator(QRegExp(QLatin1String("(?=.{5,254}$)([a-zA-Z0-9][a-zA-Z0-9-]{1,62}\\.){1,63}[a-zA-Z]{2,63}")), nullptr); | | |||
207 | static SimpleIpV4AddressValidator ipv4Validator; | 206 | static SimpleIpV4AddressValidator ipv4Validator; | ||
208 | static SimpleIpV6AddressValidator ipv6Validator; | 207 | static SimpleIpV6AddressValidator ipv6Validator; | ||
209 | int pos = 0; | 208 | int pos = 0; | ||
210 | 209 | | |||
211 | bool addressValid = QValidator::Acceptable == fqdnValidator.validate(address, pos) | 210 | bool addressValid = QValidator::Acceptable == fqdnValidator.validate(address, pos) | ||
212 | || QValidator::Acceptable == ipv4Validator.validate(address, pos) | 211 | || QValidator::Acceptable == ipv4Validator.validate(address, pos) | ||
213 | || QValidator::Acceptable == ipv6Validator.validate(address, pos); | 212 | || QValidator::Acceptable == ipv6Validator.validate(address, pos); | ||
214 | bool bothEmpty = address.isEmpty() && port.isEmpty(); | 213 | bool bothEmpty = address.isEmpty() && port.isEmpty(); | ||
▲ Show 20 Lines • Show All 161 Lines • Show Last 20 Lines |