Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion dcc-network/qml/NetUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.pragma library
// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later
const VpnTypeEnum = Object.freeze({
"l2tp": 0x01,
Expand All @@ -12,9 +12,13 @@ const VpnTypeEnum = Object.freeze({
})
// ip正则表达式
const ipRegExp = /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))$/
// ip编辑时宽松正则(仅允许数字和点)
const ipEditRegExp = /^[0-9.]*$/
const ipv6RegExp = /^(((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))))$/
// 子网掩码
const maskRegExp = /(254|252|248|240|224|192|128|0)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)/
// 子网掩码编辑时宽松正则(仅允许数字和点)
const maskEditRegExp = /^[0-9.]*$/
// MAC正则表达式
const macRegExp = /([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})/

Expand Down
6 changes: 3 additions & 3 deletions dcc-network/qml/SectionIPv4.qml
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ DccObject {
page: D.LineEdit {
text: addressData.length > index ? addressData[index][0] : "0.0.0.0"
validator: RegularExpressionValidator {
regularExpression: NetUtils.ipRegExp
regularExpression: NetUtils.ipEditRegExp
}
onTextChanged: {
if (showAlert) {
Expand Down Expand Up @@ -372,7 +372,7 @@ DccObject {
page: D.LineEdit {
text: addressData.length > index ? addressData[index][1] : "255.255.255.0"
validator: RegularExpressionValidator {
regularExpression: NetUtils.maskRegExp
regularExpression: NetUtils.maskEditRegExp
}
onTextChanged: {
if (showAlert) {
Expand Down Expand Up @@ -404,7 +404,7 @@ DccObject {
enabled: index === 0
text: index === 0 && addressData.length > index ? addressData[index][2] : ""
validator: RegularExpressionValidator {
regularExpression: NetUtils.ipRegExp
regularExpression: NetUtils.ipEditRegExp
}
onTextChanged: {
if (showAlert) {
Expand Down
Loading