luci-app-tor: add config for tor
authorSergey Ponomarev <stokito@gmail.com>
Fri, 9 Feb 2024 01:07:22 +0000 (03:07 +0200)
committerPaul Donald <itsascambutmailmeanyway@gmail.com>
Mon, 12 Feb 2024 13:26:55 +0000 (14:26 +0100)
Currently the UCI for the Tor allows to set only a list of configs to include.
The only way to configure it for a user is to upload its own config and add it to list of included.
We can simplify this with the app.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
applications/luci-app-tor/Makefile
applications/luci-app-tor/htdocs/luci-static/resources/view/tor/tor.js [new file with mode: 0644]
applications/luci-app-tor/root/usr/share/luci/menu.d/luci-app-tor.json
applications/luci-app-tor/root/usr/share/rpcd/acl.d/luci-app-tor.json

index caecd8053497c91738a384893078f6ef9281dcc0..47f2e03317f773ef2178751d0899e386f31b2bf0 100644 (file)
@@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk
 
 LUCI_TITLE:=LuCI app to configure Tor
 LUCI_DEPENDS:=+luci-base +tor +tor-hs
-PKG_VERSION:=1.0.0
+PKG_VERSION:=1.1.0
 PKG_RELEASE:=1
 PKG_MAINTAINER:=Sergey Ponomarev <stokito@gmail.com>
 
diff --git a/applications/luci-app-tor/htdocs/luci-static/resources/view/tor/tor.js b/applications/luci-app-tor/htdocs/luci-static/resources/view/tor/tor.js
new file mode 100644 (file)
index 0000000..dde7ca7
--- /dev/null
@@ -0,0 +1,36 @@
+'use strict';
+'require view';
+'require form';
+'require uci';
+
+
+return view.extend({
+       render: function () {
+               var m, s, o;
+
+               m = new form.Map('tor', _('Tor onion router'),
+                       _('For further information <a %s>check the documentation</a>')
+                               .format('href="https://openwrt.org/docs/guide-user/services/tor/client" target="_blank" rel="noreferrer"')
+               );
+
+               s = m.section(form.NamedSection, 'conf', 'tor');
+
+               o = s.option(form.DynamicList, 'tail_include', _('Include configs'));
+               o.datatype = 'list(string)';
+
+               o = s.option(form.FileUpload, '_custom_config', _('Custom config'));
+               o.default = '/etc/tor/torrc_custom';
+               o.root_directory = '/etc/tor/';
+               o.optional = true;
+               o.write = function(section_id, formvalue) {
+                       let tail_include = uci.get('tor', section_id, 'tail_include');
+                       if (!tail_include.includes(formvalue)) {
+                               tail_include.push(formvalue);
+                               return uci.set('tor', section_id, 'tail_include', tail_include);
+                       }
+               };
+
+
+               return m.render();
+       },
+});
index 19777f6bd09e1f92812d8ad2b3b5e426396f6186..0ea6d1c935868940d422aeb1da342b1873d6a8bf 100644 (file)
                        "type": "view",
                        "path": "tor/tor-hs"
                }
+       },
+       "admin/services/tor/tor": {
+               "title": "Tor Onion router",
+               "order": 30,
+               "action": {
+                       "type": "view",
+                       "path": "tor/tor"
+               }
        }
 }
index 0d109b1c98bef41fcf95c5d2872bfac6be5b0725..8095a17fdab5c9de28c4419d9c92822dd6cf6cc8 100644 (file)
                        "uci": [
                                "tor",
                                "tor-hs"
-                       ]
+                       ],
+                       "file": {
+                               "/etc/tor/*": [ "write" ]
+                       }
                }
        }
 }