@@ -285,6 +316,9 @@ export default {
return {
acls: [],
fetchLoading: false,
+ protocolNumbers: [],
+ icmpTypes: [],
+ icmpCodes: [],
tags: [],
selectedAcl: null,
tagsModalVisible: false,
@@ -296,6 +330,7 @@ export default {
},
created () {
this.initForm()
+ this.fetchNetworkProtocols()
this.fetchData()
},
watch: {
@@ -310,6 +345,8 @@ export default {
this.formRef = ref()
this.form = reactive({})
this.rules = reactive({})
+ this.form.icmptype = -1
+ this.form.icmpcode = -1
},
csv ({ data = null, columnDelimiter = ',', lineDelimiter = '\n' }) {
let result = null
@@ -351,6 +388,35 @@ export default {
return result
},
+ fetchNetworkProtocols () {
+ api('listNetworkProtocols', {
+ option: 'protocolnumber'
+ }).then(json => {
+ this.protocolNumbers = json.listnetworkprotocolsresponse?.networkprotocol || []
+ })
+ api('listNetworkProtocols', {
+ option: 'icmptype'
+ }).then(json => {
+ this.icmpTypes.push({ index: -1, description: this.$t('label.all') })
+ const results = json.listnetworkprotocolsresponse?.networkprotocol || []
+ for (const result of results) {
+ this.icmpTypes.push(result)
+ }
+ })
+ this.icmpCodes.push({ code: -1, description: this.$t('label.all') })
+ },
+ updateIcmpCodes (val) {
+ this.form.icmpcode = -1
+ this.icmpCodes = []
+ this.icmpCodes.push({ code: -1, description: this.$t('label.all') })
+ const icmpType = this.icmpTypes.find(icmpType => icmpType.index === val)
+ if (icmpType && icmpType.details) {
+ const icmpTypeDetails = icmpType.details
+ for (const k of Object.keys(icmpTypeDetails)) {
+ this.icmpCodes.push({ code: parseInt(k), description: icmpTypeDetails[k] })
+ }
+ }
+ },
fetchData () {
this.fetchLoading = true
api('listNetworkACLs', { aclid: this.resource.id }).then(json => {
@@ -476,8 +542,15 @@ export default {
self.form.cidrlist = acl.cidrlist
self.form.action = acl.action
self.form.protocol = acl.protocol
+ if (!['tcp', 'udp', 'icmp', 'all'].includes(acl.protocol)) {
+ self.form.protocol = 'protocolnumber'
+ self.form.protocolnumber = parseInt(acl.protocol)
+ }
self.form.startport = acl.startport
self.form.endport = acl.endport
+ self.form.icmptype = parseInt(acl.icmptype)
+ this.updateIcmpCodes(self.form.icmptype)
+ self.form.icmpcode = acl.icmpcode
self.form.traffictype = acl.traffictype
self.form.reason = acl.reason
}, 200)
@@ -497,9 +570,9 @@ export default {
data.endport = values.endport || ''
}
- if (values.protocol === 'icmp') {
- data.icmptype = values.icmptype || -1
- data.icmpcode = values.icmpcode || -1
+ if (values.protocol === 'icmp' || (values.protocol === 'protocolnumber' && values.protocolnumber === 1)) {
+ data.icmptype = values.icmptype
+ data.icmpcode = values.icmpcode
}
if (values.protocol === 'protocolnumber') {
diff --git a/ui/src/views/network/EgressRulesTab.vue b/ui/src/views/network/EgressRulesTab.vue
index a0fb7085534..9d315416e2a 100644
--- a/ui/src/views/network/EgressRulesTab.vue
+++ b/ui/src/views/network/EgressRulesTab.vue
@@ -63,11 +63,32 @@