58 if (!
value.contains(QLatin1Char(
':')) && !
value.contains(ValidatorIpPrivate::regex)) {
65 static const std::vector<std::pair<QHostAddress, int>> ipv4Private(
68 {QHostAddress(QStringLiteral(
"10.0.0.0")), 8},
73 {QHostAddress(QStringLiteral(
"169.254.0.0")), 16},
77 {QHostAddress(QStringLiteral(
"172.16.0.0")), 12},
81 {QHostAddress(QStringLiteral(
"192.168.0.0")), 12}});
84 static const std::vector<std::pair<QHostAddress, int>> ipv4Reserved(
87 {QHostAddress(QStringLiteral(
"0.0.0.0")), 8},
91 {QHostAddress(QStringLiteral(
"100.64.0.0")), 10},
95 {QHostAddress(QStringLiteral(
"127.0.0.1")), 8},
99 {QHostAddress(QStringLiteral(
"192.0.0.0")), 24},
103 {QHostAddress(QStringLiteral(
"192.0.2.0")), 24},
107 {QHostAddress(QStringLiteral(
"192.88.99.0")), 24},
111 {QHostAddress(QStringLiteral(
"198.18.0.0")), 15},
115 {QHostAddress(QStringLiteral(
"198.51.100.0")), 24},
119 {QHostAddress(QStringLiteral(
"203.0.113.0")), 24},
123 {QHostAddress(QStringLiteral(
"240.0.0.0")), 4},
127 {QHostAddress(QStringLiteral(
"255.255.255.255")), 32}});
130 static const std::vector<std::pair<QHostAddress, int>> ipv6Private(
132 {QHostAddress(QStringLiteral(
"fc00::")), 7},
135 {QHostAddress(QStringLiteral(
"fe80::")), 10}});
138 static const std::vector<std::pair<QHostAddress, int>> ipv6Reserved(
140 {QHostAddress(QStringLiteral(
"::")), 128},
143 {QHostAddress(QStringLiteral(
"::1")), 128},
146 {QHostAddress(QStringLiteral(
"::ffff:0:0")), 96},
150 {QHostAddress(QStringLiteral(
"100::")), 64},
154 {QHostAddress(QStringLiteral(
"64:ff9b::")), 96},
157 {QHostAddress(QStringLiteral(
"2001::")), 32},
160 {QHostAddress(QStringLiteral(
"2001:10::")), 28},
163 {QHostAddress(QStringLiteral(
"2001:20::")), 28},
166 {QHostAddress(QStringLiteral(
"2001:db8::")), 32},
169 {QHostAddress(QStringLiteral(
"2002::")), 16}});
173 if (a.setAddress(
value)) {
177 if (a.protocol() == QAbstractSocket::IPv4Protocol) {
179 if (constraints.testFlag(
IPv6Only)) {
186 for (
const std::pair<QHostAddress, int> &subnet : ipv4Private) {
187 if (a.isInSubnet(subnet.first, subnet.second)) {
197 for (
const std::pair<QHostAddress, int> &subnet : ipv4Reserved) {
198 if (a.isInSubnet(subnet.first, subnet.second)) {
207 if (a.isInSubnet(QHostAddress(QStringLiteral(
"224.0.0.0")), 4)) {
214 if (constraints.testFlag(
IPv4Only)) {
221 for (
const std::pair<QHostAddress, int> &subnet : ipv6Private) {
222 if (a.isInSubnet(subnet.first, subnet.second)) {
232 for (
const std::pair<QHostAddress, int> &subnet : ipv6Reserved) {
233 if (a.isInSubnet(subnet.first, subnet.second)) {
242 if (a.isInSubnet(QHostAddress(QStringLiteral(
"ff00::")), 8)) {
QString qtTrId(const char *id, int n=-1) const