mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:06:30 +00:00
UI: IpRange: Allow to wrap addresses by [ ]
This commit is contained in:
parent
4fac0dde3e
commit
6780cbd91a
@ -71,7 +71,10 @@ TEST_F(ConfUtilTest, confWriteRead)
|
||||
|
||||
QByteArray buf;
|
||||
const int confIoSize = confUtil.write(conf, nullptr, envManager, buf);
|
||||
ASSERT_NE(confIoSize, 0);
|
||||
if (confIoSize == 0) {
|
||||
qCritical() << "Error:" << confUtil.errorMessage();
|
||||
ASSERT_NE(confIoSize, 0);
|
||||
}
|
||||
|
||||
// Check the buffer
|
||||
const char *data = buf.constData() + DriverCommon::confIoConfOff();
|
||||
|
@ -129,8 +129,8 @@ TEST_F(NetUtilTest, ip6Ranges)
|
||||
ASSERT_TRUE(ipRange.fromText("2002::/16"));
|
||||
ASSERT_EQ(ipRange.toText(), QString("2002::-2002:ffff:ffff:ffff:ffff:ffff:ffff:ffff\n"));
|
||||
|
||||
ASSERT_TRUE(ipRange.fromText("::2/126\n"
|
||||
"::1/126\n"));
|
||||
ASSERT_TRUE(ipRange.fromText("[::2]/126\n"
|
||||
"[::1]/126\n"));
|
||||
ASSERT_EQ(ipRange.toText(),
|
||||
QString("::1-::3\n"
|
||||
"::2-::3\n"));
|
||||
|
@ -156,13 +156,9 @@ bool IpRange::fromList(const StringViewList &list, bool sort)
|
||||
IpRange::ParseError IpRange::parseIpLine(
|
||||
const QStringView line, ip4range_map_t &ip4RangeMap, int &pair4Size)
|
||||
{
|
||||
static const QRegularExpression ip4Re(R"(^([\d.]+)\s*([\/-]?)\s*(\S*))");
|
||||
static const QRegularExpression ip6Re(R"(^([A-Fa-f\d:]+)\s*([\/-]?)\s*(\S*))");
|
||||
static const QRegularExpression ipRe(R"(^\[?([A-Fa-f\d:.]+)\]?\s*([\/-]?)\s*(\S*))");
|
||||
|
||||
const bool isIPv6 = !line.contains('.');
|
||||
const QRegularExpression &re = isIPv6 ? ip6Re : ip4Re;
|
||||
|
||||
const auto match = StringUtil::match(re, line);
|
||||
const auto match = StringUtil::match(ipRe, line);
|
||||
if (!match.hasMatch()) {
|
||||
setErrorMessage(tr("Bad format"));
|
||||
return ErrorBadFormat;
|
||||
@ -179,6 +175,7 @@ IpRange::ParseError IpRange::parseIpLine(
|
||||
}
|
||||
|
||||
const char maskSep = sepStr.isEmpty() ? '\0' : sepStr.at(0).toLatin1();
|
||||
const bool isIPv6 = ip.contains(':');
|
||||
|
||||
return isIPv6 ? parseIp6Address(ip, mask, maskSep)
|
||||
: parseIp4Address(ip, mask, ip4RangeMap, pair4Size, maskSep);
|
||||
|
@ -171,21 +171,25 @@ QStringList NetUtil::localIpNetworks()
|
||||
{
|
||||
static QStringList list = {
|
||||
"0.0.0.0/32", // non-routable meta-address
|
||||
"10.0.0.0/8",
|
||||
"100.64.0.0/10" // for carrier-grade NAT deployment
|
||||
"10.0.0.0/8", //
|
||||
"100.64.0.0/10", // for carrier-grade NAT deployment
|
||||
"127.0.0.0/8", // Loopback
|
||||
"169.254.0.0/16", // if cannot obtain a network address via DHCP
|
||||
"172.16.0.0/12", "192.168.0.0/16",
|
||||
"172.16.0.0/12", //
|
||||
"192.168.0.0/16", //
|
||||
"239.255.255.250/32", // IP Multicast for DLNA/UPNP
|
||||
"255.255.255.255/32", // IP Broadcast
|
||||
"::/0", // non-routable meta-address
|
||||
"::/128",
|
||||
"::/128", //
|
||||
"::1/128", // Localhost
|
||||
"::ffff:0:0/96", "::ffff:0:0:0/96", "64:ff9b::/96", "100::/64",
|
||||
"::ffff:0:0/96", //
|
||||
"::ffff:0:0:0/96", //
|
||||
"64:ff9b::/96", //
|
||||
"100::/64", //
|
||||
"2001::/32", // Global Unique Addresses (GUA) - Routable IPv6 addresses
|
||||
"2001:20::/28",
|
||||
"2001:20::/28", //
|
||||
"2001:db8::/32", // Documentation prefix used for examples
|
||||
"2002::/16",
|
||||
"2002::/16", //
|
||||
"fc00::/7", // Unique Local Addresses (ULA) - also known as “Private” IPv6 addresses
|
||||
"fe80::/10", // Link Local addresses, only valid inside a single broadcast domain
|
||||
"ff00::/8", // Multicast addresses
|
||||
|
Loading…
Reference in New Issue
Block a user