mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-28 11:04:14 +08:00
fix(forward): Fix the problem of duplicate creation of port forwardin… (#7975)
Refs #7969
This commit is contained in:
parent
872a93aa07
commit
b61dae638b
@ -30,7 +30,8 @@ type PortRuleOperate struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ForwardRuleOperate struct {
|
type ForwardRuleOperate struct {
|
||||||
Rules []struct {
|
ForceDelete bool `json:"forceDelete"`
|
||||||
|
Rules []struct {
|
||||||
Operation string `json:"operation" validate:"required,oneof=add remove"`
|
Operation string `json:"operation" validate:"required,oneof=add remove"`
|
||||||
Num string `json:"num"`
|
Num string `json:"num"`
|
||||||
Protocol string `json:"protocol" validate:"required,oneof=tcp udp tcp/udp"`
|
Protocol string `json:"protocol" validate:"required,oneof=tcp udp tcp/udp"`
|
||||||
|
@ -381,6 +381,10 @@ func (u *FirewallService) OperateForwardRule(req dto.ForwardRuleOperate) error {
|
|||||||
TargetIP: r.TargetIP,
|
TargetIP: r.TargetIP,
|
||||||
TargetPort: r.TargetPort,
|
TargetPort: r.TargetPort,
|
||||||
}, r.Operation); err != nil {
|
}, r.Operation); err != nil {
|
||||||
|
if req.ForceDelete {
|
||||||
|
global.LOG.Error(err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ export const operateFire = (operation: string) => {
|
|||||||
export const operatePortRule = (params: Host.RulePort) => {
|
export const operatePortRule = (params: Host.RulePort) => {
|
||||||
return http.post<Host.RulePort>(`/hosts/firewall/port`, params, TimeoutEnum.T_40S);
|
return http.post<Host.RulePort>(`/hosts/firewall/port`, params, TimeoutEnum.T_40S);
|
||||||
};
|
};
|
||||||
export const operateForwardRule = (params: { rules: Host.RuleForward[] }) => {
|
export const operateForwardRule = (params: { rules: Host.RuleForward[]; forceDelete: boolean }) => {
|
||||||
return http.post<Host.RulePort>(`/hosts/firewall/forward`, params, TimeoutEnum.T_40S);
|
return http.post<Host.RulePort>(`/hosts/firewall/forward`, params, TimeoutEnum.T_40S);
|
||||||
};
|
};
|
||||||
export const operateIPRule = (params: Host.RuleIP) => {
|
export const operateIPRule = (params: Host.RuleIP) => {
|
||||||
|
@ -77,7 +77,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<OpDialog ref="opRef" @search="search" />
|
<OpDialog ref="opRef" @search="search" @submit="onSubmitDelete()">
|
||||||
|
<template #content>
|
||||||
|
<el-form class="mt-4 mb-1" ref="deleteForm" label-position="left">
|
||||||
|
<el-form-item>
|
||||||
|
<el-checkbox v-model="forceDelete" :label="$t('website.forceDelete')" />
|
||||||
|
<span class="input-help">
|
||||||
|
{{ $t('website.forceDeleteHelper') }}
|
||||||
|
</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</template>
|
||||||
|
</OpDialog>
|
||||||
<OperateDialog @search="search" ref="dialogRef" />
|
<OperateDialog @search="search" ref="dialogRef" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -91,6 +102,7 @@ import { operateForwardRule, searchFireRule } from '@/api/modules/host';
|
|||||||
import { Host } from '@/api/interface/host';
|
import { Host } from '@/api/interface/host';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { GlobalStore } from '@/store';
|
import { GlobalStore } from '@/store';
|
||||||
|
import { MsgSuccess } from '@/utils/message';
|
||||||
|
|
||||||
const globalStore = GlobalStore();
|
const globalStore = GlobalStore();
|
||||||
|
|
||||||
@ -107,6 +119,8 @@ const fireName = ref();
|
|||||||
const fireStatusRef = ref();
|
const fireStatusRef = ref();
|
||||||
|
|
||||||
const opRef = ref();
|
const opRef = ref();
|
||||||
|
const forceDelete = ref(false);
|
||||||
|
const operateRules = ref();
|
||||||
|
|
||||||
const data = ref();
|
const data = ref();
|
||||||
const paginationConfig = reactive({
|
const paginationConfig = reactive({
|
||||||
@ -180,6 +194,7 @@ const onDelete = async (row: Host.RuleForward | null) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
operateRules.value = rules;
|
||||||
opRef.value.acceptParams({
|
opRef.value.acceptParams({
|
||||||
title: i18n.global.t('commons.button.delete'),
|
title: i18n.global.t('commons.button.delete'),
|
||||||
names: names,
|
names: names,
|
||||||
@ -187,11 +202,24 @@ const onDelete = async (row: Host.RuleForward | null) => {
|
|||||||
i18n.global.t('firewall.forwardRule'),
|
i18n.global.t('firewall.forwardRule'),
|
||||||
i18n.global.t('commons.button.delete'),
|
i18n.global.t('commons.button.delete'),
|
||||||
]),
|
]),
|
||||||
api: operateForwardRule,
|
api: null,
|
||||||
params: { rules: rules },
|
params: null,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onSubmitDelete = async () => {
|
||||||
|
loading.value = true;
|
||||||
|
await operateForwardRule({ rules: operateRules.value, forceDelete: forceDelete.value })
|
||||||
|
.then(() => {
|
||||||
|
loading.value = false;
|
||||||
|
MsgSuccess(i18n.global.t('commons.msg.deleteSuccess'));
|
||||||
|
search();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const buttons = [
|
const buttons = [
|
||||||
{
|
{
|
||||||
label: i18n.global.t('commons.button.edit'),
|
label: i18n.global.t('commons.button.edit'),
|
||||||
@ -208,6 +236,7 @@ const buttons = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
forceDelete.value = false;
|
||||||
if (fireName.value !== '-') {
|
if (fireName.value !== '-') {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
fireStatusRef.value.acceptParams();
|
fireStatusRef.value.acceptParams();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user