diff --git a/app/src/views/tool/ToolFirewall.vue b/app/src/views/tool/ToolFirewall.vue index 2ba645c2..7829a7ab 100644 --- a/app/src/views/tool/ToolFirewall.vue +++ b/app/src/views/tool/ToolFirewall.vue @@ -115,8 +115,8 @@ export default { // Ports form data actionChoices: [ - { value: 'open', text: this.$i18n.t('open') }, - { value: 'close', text: this.$i18n.t('close') } + { value: 'allow', text: this.$i18n.t('open') }, + { value: 'disallow', text: this.$i18n.t('close') } ], connectionChoices: [ { value: 'ipv4', text: this.$i18n.t('ipv4') }, @@ -128,7 +128,7 @@ export default { { value: 'Both', text: this.$i18n.t('both') } ], form: { - action: 'open', + action: 'allow', port: undefined, connection: 'ipv4', protocol: 'TCP' @@ -176,27 +176,17 @@ export default { this.upnpEnabled = data.uPnP.enabled }, - togglePort ({ action, port, protocol, connection }) { - return new Promise((resolve, reject) => { - this.$askConfirmation( - this.$i18n.t('confirm_firewall_' + action, { port, protocol, connection }) - ).then(confirmed => { - if (confirmed) { - const method = action === 'open' ? 'post' : 'delete' - api[method]( - `/firewall/port?${connection}_only`, - { port, protocol }, - { wait: false } - ).then(() => { - resolve(confirmed) - }).catch(error => { - reject(error) - }) - } else { - resolve(confirmed) - } - }) - }) + async togglePort ({ action, port, protocol, connection }) { + const confirmed = await this.$askConfirmation( + this.$i18n.t('confirm_firewall_' + action, { port, protocol, connection }) + ) + if (!confirmed) { + return Promise.resolve(confirmed) + } + return api.put( + `firewall/${protocol}/${action}/${port}?${connection}_only`, + { wait: false } + ).then(() => confirmed) }, async toggleUpnp (value) { @@ -204,7 +194,7 @@ export default { const confirmed = await this.$askConfirmation(this.$i18n.t('confirm_upnp_' + action)) if (!confirmed) return - api.get('firewall/upnp?action=' + action, null, { websocket: true, wait: true }).then(() => { + api.put('firewall/upnp/' + action).then(() => { // FIXME Couldn't test when it works. this.$refs.view.fetchQueries() }).catch(err => { @@ -215,7 +205,7 @@ export default { onTablePortToggling (port, protocol, connection, index, value) { this.$set(this.protocols[protocol][index], connection, value) - const action = value ? 'open' : 'close' + const action = value ? 'allow' : 'disallow' this.togglePort({ action, port, protocol, connection }).then(toggled => { // Revert change on cancel if (!toggled) {