mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
remove port when both connection will be closed
This commit is contained in:
parent
da75347810
commit
a019cc9c21
1 changed files with 11 additions and 4 deletions
|
@ -176,7 +176,7 @@ export default {
|
||||||
this.upnpEnabled = data.uPnP.enabled
|
this.upnpEnabled = data.uPnP.enabled
|
||||||
},
|
},
|
||||||
|
|
||||||
async togglePort ({ action, port, protocol, connection }) {
|
async togglePort ({ action, port, protocol, connection, only }) {
|
||||||
const confirmed = await this.$askConfirmation(
|
const confirmed = await this.$askConfirmation(
|
||||||
this.$i18n.t('confirm_firewall_' + action, { port, protocol, connection })
|
this.$i18n.t('confirm_firewall_' + action, { port, protocol, connection })
|
||||||
)
|
)
|
||||||
|
@ -186,11 +186,12 @@ export default {
|
||||||
|
|
||||||
const actionTrad = this.$i18n.t({ allow: 'open', disallow: 'close' }[action])
|
const actionTrad = this.$i18n.t({ allow: 'open', disallow: 'close' }[action])
|
||||||
return api.put(
|
return api.put(
|
||||||
`firewall/${protocol}/${action}/${port}?${connection}_only`,
|
(only ? `firewall/${protocol}/${action}/${port}?${connection}_only` : `firewall/${protocol}/${action}/${port}`),
|
||||||
{},
|
{},
|
||||||
{ key: 'firewall.ports', protocol, action: actionTrad, port, connection },
|
{ key: 'firewall.ports', protocol, action: actionTrad, port, connection },
|
||||||
{ wait: false }
|
{ wait: false }
|
||||||
).then(() => confirmed)
|
).then(() =>
|
||||||
|
this.$refs.view.fetchQueries())
|
||||||
},
|
},
|
||||||
|
|
||||||
async toggleUpnp (value) {
|
async toggleUpnp (value) {
|
||||||
|
@ -213,8 +214,14 @@ export default {
|
||||||
|
|
||||||
onTablePortToggling (port, protocol, connection, index, value) {
|
onTablePortToggling (port, protocol, connection, index, value) {
|
||||||
this.$set(this.protocols[protocol][index], connection, value)
|
this.$set(this.protocols[protocol][index], connection, value)
|
||||||
|
|
||||||
|
const bothConnectionClosed = this.protocols[protocol].some(row => row.port === port && !row[(connection === 'ipv4' ? 'ipv6' : 'ipv4')])
|
||||||
|
|
||||||
const action = value ? 'allow' : 'disallow'
|
const action = value ? 'allow' : 'disallow'
|
||||||
this.togglePort({ action, port, protocol, connection }).then(toggled => {
|
|
||||||
|
const only = (action === 'disallow' && bothConnectionClosed) ? false : true
|
||||||
|
|
||||||
|
this.togglePort({ action, port, protocol, connection, only }).then(toggled => {
|
||||||
// Revert change on cancel
|
// Revert change on cancel
|
||||||
if (!toggled) {
|
if (!toggled) {
|
||||||
this.$set(this.protocols[protocol][index], connection, !value)
|
this.$set(this.protocols[protocol][index], connection, !value)
|
||||||
|
|
Loading…
Reference in a new issue