diff --git a/backend/app/service/firewall.go b/backend/app/service/firewall.go
index 85b1808073cc..84aa829f92bf 100644
--- a/backend/app/service/firewall.go
+++ b/backend/app/service/firewall.go
@@ -196,6 +196,12 @@ func (u *FirewallService) OperateFirewall(operation string) error {
}
_, _ = cmd.Exec("systemctl restart docker")
return nil
+ case "restart":
+ if err := client.Restart(); err != nil {
+ return err
+ }
+ _, _ = cmd.Exec("systemctl restart docker")
+ return nil
case "disablePing":
return u.updatePingStatus("0")
case "enablePing":
diff --git a/backend/utils/firewall/client.go b/backend/utils/firewall/client.go
index 18ac3825ac44..f2512bcd6517 100644
--- a/backend/utils/firewall/client.go
+++ b/backend/utils/firewall/client.go
@@ -12,6 +12,7 @@ type FirewallClient interface {
Name() string // ufw firewalld
Start() error
Stop() error
+ Restart() error
Reload() error
Status() (string, error) // running not running
Version() (string, error)
diff --git a/backend/utils/firewall/client/firewalld.go b/backend/utils/firewall/client/firewalld.go
index 3ceb23812024..569e286d0693 100644
--- a/backend/utils/firewall/client/firewalld.go
+++ b/backend/utils/firewall/client/firewalld.go
@@ -52,6 +52,14 @@ func (f *Firewall) Stop() error {
return nil
}
+func (f *Firewall) Restart() error {
+ stdout, err := cmd.Exec("systemctl restart firewalld")
+ if err != nil {
+ return fmt.Errorf("restart the firewall failed, err: %s", stdout)
+ }
+ return nil
+}
+
func (f *Firewall) Reload() error {
stdout, err := cmd.Exec("firewall-cmd --reload")
if err != nil {
diff --git a/backend/utils/firewall/client/ufw.go b/backend/utils/firewall/client/ufw.go
index 3a00fedaffa2..ac006e114d34 100644
--- a/backend/utils/firewall/client/ufw.go
+++ b/backend/utils/firewall/client/ufw.go
@@ -64,6 +64,14 @@ func (f *Ufw) Stop() error {
return nil
}
+func (f *Ufw) Restart() error {
+ stdout, err := cmd.Execf("%s systemctl restart ufw.service", cmd.SudoHandleCmd())
+ if err != nil {
+ return fmt.Errorf("restart the firewall failed, err: %s", stdout)
+ }
+ return nil
+}
+
func (f *Ufw) Reload() error {
return nil
}
diff --git a/backend/utils/toolbox/fail2ban.go b/backend/utils/toolbox/fail2ban.go
index 2c9cce169f87..74ecdccbde1c 100644
--- a/backend/utils/toolbox/fail2ban.go
+++ b/backend/utils/toolbox/fail2ban.go
@@ -97,7 +97,7 @@ func (f *Fail2ban) ListBanned() ([]string, error) {
if err != nil {
return lists, err
}
- itemList := strings.Split(stdout, " ")
+ itemList := strings.Split(strings.ReplaceAll(stdout, "\n", ""), " ")
for _, item := range itemList {
if len(item) != 0 {
lists = append(lists, item)
diff --git a/frontend/src/views/container/image/pull/index.vue b/frontend/src/views/container/image/pull/index.vue
index b49a403527ac..7d03697d1678 100644
--- a/frontend/src/views/container/image/pull/index.vue
+++ b/frontend/src/views/container/image/pull/index.vue
@@ -21,7 +21,7 @@
:rules="Rules.requiredSelect"
prop="repoID"
>
-
+
diff --git a/frontend/src/views/container/image/push/index.vue b/frontend/src/views/container/image/push/index.vue
index 658cbca208f9..29fa2352909e 100644
--- a/frontend/src/views/container/image/push/index.vue
+++ b/frontend/src/views/container/image/push/index.vue
@@ -18,7 +18,7 @@
-
+
-
+
diff --git a/frontend/src/views/container/setting/mirror/index.vue b/frontend/src/views/container/setting/mirror/index.vue
index ffb9f1409daa..1370ec0229e7 100644
--- a/frontend/src/views/container/setting/mirror/index.vue
+++ b/frontend/src/views/container/setting/mirror/index.vue
@@ -70,6 +70,9 @@ function checkMirrors(rule: any, value: any, callback: any) {
const reg = /^https?:\/\/[a-zA-Z0-9.-]+$/;
let mirrors = form.mirrors.split('\n');
for (const item of mirrors) {
+ if (item === '') {
+ continue;
+ }
if (!reg.test(item)) {
return callback(new Error(i18n.global.t('commons.rule.mirror')));
}
diff --git a/frontend/src/views/container/setting/registry/index.vue b/frontend/src/views/container/setting/registry/index.vue
index cc9af7777e70..aab5615354dc 100644
--- a/frontend/src/views/container/setting/registry/index.vue
+++ b/frontend/src/views/container/setting/registry/index.vue
@@ -70,6 +70,9 @@ function checkRegistries(rule: any, value: any, callback: any) {
const reg = /^[a-zA-Z0-9]{1}[a-z:A-Z0-9_/.-]{0,150}$/;
let regis = form.registries.split('\n');
for (const item of regis) {
+ if (item === '') {
+ continue;
+ }
if (!reg.test(item)) {
return callback(new Error(i18n.global.t('commons.rule.imageName')));
}
diff --git a/frontend/src/views/setting/safe/allowips/index.vue b/frontend/src/views/setting/safe/allowips/index.vue
index bee3ec064408..de81f58d14a4 100644
--- a/frontend/src/views/setting/safe/allowips/index.vue
+++ b/frontend/src/views/setting/safe/allowips/index.vue
@@ -58,6 +58,9 @@ function checkAddress(rule: any, value: any, callback: any) {
if (form.allowIPs !== '') {
let addrs = form.allowIPs.split('\n');
for (const item of addrs) {
+ if (item === '') {
+ continue;
+ }
if (item === '0.0.0.0') {
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
}
@@ -102,8 +105,14 @@ const onSave = async (formEl: FormInstance | undefined) => {
type: 'info',
}).then(async () => {
loading.value = true;
-
- await updateSetting({ key: 'AllowIPs', value: form.allowIPs.replaceAll('\n', ',') })
+ let ipItems = form.allowIPs.split('\n');
+ let ips = [];
+ for (const item of ipItems) {
+ if (item !== '') {
+ ips.push(item);
+ }
+ }
+ await updateSetting({ key: 'AllowIPs', value: ips.join(',') })
.then(() => {
loading.value = false;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
diff --git a/frontend/src/views/toolbox/fail2ban/ips/index.vue b/frontend/src/views/toolbox/fail2ban/ips/index.vue
index 59c20d541f84..b30495ff82ea 100644
--- a/frontend/src/views/toolbox/fail2ban/ips/index.vue
+++ b/frontend/src/views/toolbox/fail2ban/ips/index.vue
@@ -49,6 +49,9 @@ function checkIPs(rule: any, value: any, callback: any) {
if (form.ips !== '') {
let addr = form.ips.split('\n');
for (const item of addr) {
+ if (item === '') {
+ continue;
+ }
if (item.indexOf('/') !== -1) {
if (checkCidr(item)) {
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
@@ -95,9 +98,16 @@ const onSave = async (formEl: FormInstance | undefined) => {
type: 'info',
},
).then(async () => {
+ let ipItems = form.ips.split('\n');
+ let ips = [];
+ for (const item of ipItems) {
+ if (item !== '') {
+ ips.push(item);
+ }
+ }
let param = {
operate: form.operate,
- ips: form.ips.split('\n'),
+ ips: ips,
};
loading.value = true;
await operatorFail2banSSHD(param)