mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2024-12-05 21:38:26 +08:00
fix: 修改端口转发校验规则 (#5711)
This commit is contained in:
parent
577dfadb9a
commit
8d1322af37
@ -306,6 +306,21 @@ func (u *FirewallService) OperateForwardRule(req dto.ForwardRuleOperate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
rules, _ := client.ListForward()
|
||||
for _, rule := range rules {
|
||||
for _, reqRule := range req.Rules {
|
||||
if reqRule.Operation == "remove" {
|
||||
continue
|
||||
}
|
||||
if reqRule.TargetIP == "" {
|
||||
reqRule.TargetIP = "127.0.0.1"
|
||||
}
|
||||
if reqRule.Port == rule.Port && reqRule.TargetPort == rule.TargetPort && reqRule.TargetIP == rule.TargetIP {
|
||||
return constant.ErrRecordExist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort.SliceStable(req.Rules, func(i, j int) bool {
|
||||
n1, _ := strconv.Atoi(req.Rules[i].Num)
|
||||
n2, _ := strconv.Atoi(req.Rules[j].Num)
|
||||
|
@ -58,7 +58,7 @@ import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { Host } from '@/api/interface/host';
|
||||
import { operateForwardRule } from '@/api/modules/host';
|
||||
import { checkCidr, checkIpV4V6, checkPort, deepCopy } from '@/utils/util';
|
||||
import { checkCidr, checkIp, checkPort, deepCopy } from '@/utils/util';
|
||||
|
||||
const loading = ref();
|
||||
const oldRule = ref<Host.RuleForward>();
|
||||
@ -89,14 +89,14 @@ const handleClose = () => {
|
||||
|
||||
const rules = reactive({
|
||||
protocol: [Rules.requiredSelect],
|
||||
port: [{ validator: checkPortRule, trigger: 'blur' }],
|
||||
targetPort: [{ validator: checkPortRule, trigger: 'blur' }],
|
||||
port: [{ validator: checkPortRule, trigger: 'blur', required: true }],
|
||||
targetPort: [{ validator: checkPortRule, trigger: 'blur', required: true }],
|
||||
targetIP: [{ validator: checkAddress, trigger: 'blur' }],
|
||||
});
|
||||
|
||||
function checkPortRule(rule: any, value: string, callback: any) {
|
||||
if (!value) {
|
||||
return callback();
|
||||
return callback(new Error(i18n.global.t('firewall.portFormatError')));
|
||||
}
|
||||
if (checkPort(value)) {
|
||||
return callback(new Error(i18n.global.t('firewall.portFormatError')));
|
||||
@ -114,7 +114,7 @@ function checkAddress(rule: any, value: string, callback: any) {
|
||||
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||
}
|
||||
} else {
|
||||
if (checkIpV4V6(item)) {
|
||||
if (checkIp(item)) {
|
||||
return callback(new Error(i18n.global.t('firewall.addressFormatError')));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user