fix: 解决禁 ping 状态获取失败的问题 (#557)

This commit is contained in:
ssongliu 2023-04-10 12:58:13 +08:00 committed by GitHub
parent 8603d4347b
commit 4a4c2b24dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -43,7 +43,7 @@ func (f *Firewall) Start() error {
}
func (f *Firewall) PingStatus() (string, error) {
stdout, _ := cmd.Exec("firewall-cmd --query-rich-rule='rule protocol value=icmp drop'")
stdout, _ := cmd.Exec("firewall-cmd --zone=public --query-rich-rule='rule protocol value=icmp drop'")
if stdout == "yes\n" {
return constant.StatusEnable, nil
}

View File

@ -47,6 +47,7 @@ import { ref } from 'vue';
const baseInfo = ref<Host.FirewallBase>({ status: '', name: '', version: '', pingStatus: '' });
const onPing = ref('Disable');
const oldStatus = ref();
const acceptParams = (): void => {
loadBaseInfo(true);
@ -58,6 +59,7 @@ const loadBaseInfo = async (search: boolean) => {
.then((res) => {
baseInfo.value = res.data;
onPing.value = baseInfo.value.pingStatus;
oldStatus.value = onPing.value;
emit('update:name', baseInfo.value.name);
emit('update:status', baseInfo.value.status);
if (search) {
@ -118,8 +120,7 @@ const onPingOperate = async (operation: string) => {
});
})
.catch(() => {
emit('update:loading', true);
loadBaseInfo(false);
onPing.value = oldStatus.value;
});
};