From 263df70dddc436ffbdb324b5c2443db3c10feab1 Mon Sep 17 00:00:00 2001 From: abeudin Date: Sat, 17 May 2014 18:42:09 +0200 Subject: [PATCH 1/6] add upnp check --- firewall.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/firewall.py b/firewall.py index b5c2a478d..c2d52015e 100644 --- a/firewall.py +++ b/firewall.py @@ -207,7 +207,7 @@ def firewall_upnp(action=None): Add uPnP cron and enable uPnP in firewall.yml, or the opposite. Keyword argument: - action -- enable/disable + action -- enable/disable/check """ firewall = firewall_list(raw=True) @@ -244,6 +244,13 @@ def firewall_upnp(action=None): msignals.display(m18n.n('upnp_disabled'), 'success') + if action == 'check': + if firewall['uPnP']['enabled'] == True: + msignals.display(m18n.n('upnp_active'), 'success') + else: + raise MoulinetteError(errno.EPERM, + m18n.n('upnp_inactive')) + if action: os.system("cp /etc/yunohost/firewall.yml /etc/yunohost/firewall.yml.old") with open('/etc/yunohost/firewall.yml', 'w') as f: From 495e59ef7655da2ce9468c9075b9d0f19c1ed5b3 Mon Sep 17 00:00:00 2001 From: abeudin Date: Sat, 17 May 2014 18:42:48 +0200 Subject: [PATCH 2/6] add upnp check --- actionsmap/yunohost.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actionsmap/yunohost.yml b/actionsmap/yunohost.yml index a3081d40b..7d558470d 100644 --- a/actionsmap/yunohost.yml +++ b/actionsmap/yunohost.yml @@ -852,10 +852,11 @@ firewall: api: GET /firewall/upnp arguments: action: - help: enable/disable + help: enable/disable/check choices: - enable - disable + - check - [] nargs: "*" From 4b1072174de786d212b4ea86a76c05f5a5db33a9 Mon Sep 17 00:00:00 2001 From: abeudin Date: Sat, 17 May 2014 18:44:46 +0200 Subject: [PATCH 3/6] Update en.json --- locales/en.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/locales/en.json b/locales/en.json index 665c81b19..e9e191ab2 100644 --- a/locales/en.json +++ b/locales/en.json @@ -67,6 +67,8 @@ "upnp_port_open_failed" : "Unable to open uPnP ports", "upnp_enabled" : "uPnP successfully enabled", "upnp_disabled" : "uPnP successfully disabled", + "upnp_active" : "uPnP is activate", + "upnp_desactive" : "uPnP is not activate", "firewall_reloaded" : "Firewall successfully reloaded", "hook_choice_invalid" : "Invalid choice '%s'", From 61beb3b9b0be2f81e2ca78395044c619ee02ec9a Mon Sep 17 00:00:00 2001 From: abeudin Date: Sat, 17 May 2014 18:45:29 +0200 Subject: [PATCH 4/6] Update en.json --- locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en.json b/locales/en.json index e9e191ab2..68637868c 100644 --- a/locales/en.json +++ b/locales/en.json @@ -68,7 +68,7 @@ "upnp_enabled" : "uPnP successfully enabled", "upnp_disabled" : "uPnP successfully disabled", "upnp_active" : "uPnP is activate", - "upnp_desactive" : "uPnP is not activate", + "upnp_inactive" : "uPnP is not activate", "firewall_reloaded" : "Firewall successfully reloaded", "hook_choice_invalid" : "Invalid choice '%s'", From 22543aea001466f471c905fb6d4c2ee2bb071a80 Mon Sep 17 00:00:00 2001 From: abeudin Date: Sat, 17 May 2014 18:54:54 +0200 Subject: [PATCH 5/6] Update firewall.py --- firewall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firewall.py b/firewall.py index c2d52015e..f5dc829d0 100644 --- a/firewall.py +++ b/firewall.py @@ -248,7 +248,7 @@ def firewall_upnp(action=None): if firewall['uPnP']['enabled'] == True: msignals.display(m18n.n('upnp_active'), 'success') else: - raise MoulinetteError(errno.EPERM, + raise MoulinetteError(errno.EADV, m18n.n('upnp_inactive')) if action: From 78caf628ac8384730faa7bdd6157a8f01f5012ac Mon Sep 17 00:00:00 2001 From: abeudin Date: Sat, 17 May 2014 18:56:16 +0200 Subject: [PATCH 6/6] Update firewall.py --- firewall.py | 1 - 1 file changed, 1 deletion(-) diff --git a/firewall.py b/firewall.py index f5dc829d0..be12e2401 100644 --- a/firewall.py +++ b/firewall.py @@ -256,7 +256,6 @@ def firewall_upnp(action=None): with open('/etc/yunohost/firewall.yml', 'w') as f: yaml.safe_dump(firewall, f, default_flow_style=False) - return { "enabled": firewall['uPnP']['enabled'] } def firewall_stop():