support CIDR for whitelist

Signed-off-by: Xerxes-2 <dspxue@gmail.com>
This commit is contained in:
Xerxes-2
2022-11-23 02:42:36 +11:00
parent 1591e0cfe7
commit cf721e9bb3
5 changed files with 39 additions and 3 deletions

View File

@@ -133,7 +133,7 @@ void changeWhiteList({Function()? callback}) async {
final ips =
newWhiteListField.trim().split(RegExp(r"[\s,;\n]+"));
// test ip
final ipMatch = RegExp(r"^\d+\.\d+\.\d+\.\d+$");
final ipMatch = RegExp(r"^\d+\.\d+\.\d+\.\d+(\/\d+)?$");
for (final ip in ips) {
if (!ipMatch.hasMatch(ip)) {
msg = "${translate("Invalid IP")} $ip";