62 if (!
value.contains(QLatin1Char(
':')) && !
value.contains(QRegularExpression(QStringLiteral(
63 "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$")))) {
70 static const std::vector<std::pair<QHostAddress, int>> ipv4Private(
73 {QHostAddress(QStringLiteral(
"10.0.0.0")), 8},
78 {QHostAddress(QStringLiteral(
"169.254.0.0")), 16},
82 {QHostAddress(QStringLiteral(
"172.16.0.0")), 12},
86 {QHostAddress(QStringLiteral(
"192.168.0.0")), 12}});
89 static const std::vector<std::pair<QHostAddress, int>> ipv4Reserved(
92 {QHostAddress(QStringLiteral(
"0.0.0.0")), 8},
96 {QHostAddress(QStringLiteral(
"100.64.0.0")), 10},
100 {QHostAddress(QStringLiteral(
"127.0.0.1")), 8},
104 {QHostAddress(QStringLiteral(
"192.0.0.0")), 24},
108 {QHostAddress(QStringLiteral(
"192.0.2.0")), 24},
112 {QHostAddress(QStringLiteral(
"192.88.99.0")), 24},
116 {QHostAddress(QStringLiteral(
"198.18.0.0")), 15},
120 {QHostAddress(QStringLiteral(
"198.51.100.0")), 24},
124 {QHostAddress(QStringLiteral(
"203.0.113.0")), 24},
128 {QHostAddress(QStringLiteral(
"240.0.0.0")), 4},
132 {QHostAddress(QStringLiteral(
"255.255.255.255")), 32}});
135 static const std::vector<std::pair<QHostAddress, int>> ipv6Private(
137 {QHostAddress(QStringLiteral(
"fc00::")), 7},
140 {QHostAddress(QStringLiteral(
"fe80::")), 10}});
143 static const std::vector<std::pair<QHostAddress, int>> ipv6Reserved(
145 {QHostAddress(QStringLiteral(
"::")), 128},
148 {QHostAddress(QStringLiteral(
"::1")), 128},
151 {QHostAddress(QStringLiteral(
"::ffff:0:0")), 96},
155 {QHostAddress(QStringLiteral(
"100::")), 64},
159 {QHostAddress(QStringLiteral(
"64:ff9b::")), 96},
162 {QHostAddress(QStringLiteral(
"2001::")), 32},
165 {QHostAddress(QStringLiteral(
"2001:10::")), 28},
168 {QHostAddress(QStringLiteral(
"2001:20::")), 28},
171 {QHostAddress(QStringLiteral(
"2001:db8::")), 32},
174 {QHostAddress(QStringLiteral(
"2002::")), 16}});
178 if (a.setAddress(
value)) {
182 if (a.protocol() == QAbstractSocket::IPv4Protocol) {
184 if (constraints.testFlag(
IPv6Only)) {
191 for (
const std::pair<QHostAddress, int> &subnet : ipv4Private) {
192 if (a.isInSubnet(subnet.first, subnet.second)) {
202 for (
const std::pair<QHostAddress, int> &subnet : ipv4Reserved) {
203 if (a.isInSubnet(subnet.first, subnet.second)) {
212 if (a.isInSubnet(QHostAddress(QStringLiteral(
"224.0.0.0")), 4)) {
219 if (constraints.testFlag(
IPv4Only)) {
226 for (
const std::pair<QHostAddress, int> &subnet : ipv6Private) {
227 if (a.isInSubnet(subnet.first, subnet.second)) {
237 for (
const std::pair<QHostAddress, int> &subnet : ipv6Reserved) {
238 if (a.isInSubnet(subnet.first, subnet.second)) {
247 if (a.isInSubnet(QHostAddress(QStringLiteral(
"ff00::")), 8)) {
QString translate(const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const