diff --git a/htdocs/luci-static/resources/view/homeproxy/node.js b/htdocs/luci-static/resources/view/homeproxy/node.js index e612256..b201094 100644 --- a/htdocs/luci-static/resources/view/homeproxy/node.js +++ b/htdocs/luci-static/resources/view/homeproxy/node.js @@ -450,7 +450,14 @@ return view.extend({ } } o.onclick = function() { - /* TODO: add corresponding script. */ + var _this = this; + + return fs.exec('/etc/homeproxy/scripts/subscribe.lua').then(function (res) { + return location.reload(); + }).catch(function (err) { + ui.addNotification(null, E('p', _('An error occurred during updating subscriptions: %s').format(err))); + return _this.map.reset(); + }); } o = s.option(form.Button, '_remove_subscriptions', _('Remove all nodes from subscriptions')); diff --git a/root/etc/homeproxy/scripts/subscribe.lua b/root/etc/homeproxy/scripts/subscribe.lua index b62d4ce..a5e0f3b 100755 --- a/root/etc/homeproxy/scripts/subscribe.lua +++ b/root/etc/homeproxy/scripts/subscribe.lua @@ -520,7 +520,7 @@ local function main() local first_server = uci:get_first(uciname, ucisection) if first_server then if not uci:get(uciname, main_server) then - uci:set(uciname, "config", "main_server", first_server[".name"]) + uci:set(uciname, "config", "main_server", first_server) need_restart = true log("Main node is gone, switching to first node.") end @@ -528,7 +528,7 @@ local function main() local udp_server = uci:get(uciname, "config", "main_udp_server", "null") if udp_server ~= "nil" and udp_server ~= "null" then if not uci:get(uciname, udp_server) then - uci:set(uciname, "config", "main_udp_server", first_server[".name"]) + uci:set(uciname, "config", "main_udp_server", first_server) need_restart = true log("UDP node is gone, switching to main node.") end @@ -553,7 +553,7 @@ end if notEmpty(subscription_urls) then xpcall(main, function(e) - log("Errors occurred during updating subscriptions:") + log("An error occurred during updating subscriptions:") log(e) log(debug.traceback()) diff --git a/root/usr/share/rpcd/acl.d/luci-app-homeproxy.json b/root/usr/share/rpcd/acl.d/luci-app-homeproxy.json index 8b35682..3615841 100644 --- a/root/usr/share/rpcd/acl.d/luci-app-homeproxy.json +++ b/root/usr/share/rpcd/acl.d/luci-app-homeproxy.json @@ -3,7 +3,7 @@ "description": "Grant access to homeproxy configuration", "read": { "file": { - "/etc/homeproxy/*": [ "read" ], + "/etc/homeproxy/scripts/subscribe.lua": [ "exec" ], "/usr/bin/which": [ "exec" ], "/bin/mkdir -p /etc/homeproxy/certs/": [ "exec" ] }, @@ -14,7 +14,9 @@ }, "write": { "file": { - "/etc/homeproxy/*": [ "write" ] + "/etc/homeproxy/certs/client_ca.pem": [ "write" ], + "/etc/homeproxy/certs/server_publickey.pem": [ "write" ], + "/etc/homeproxy/certs/server_privatekey.pem": [ "write" ] }, "uci": [ "homeproxy" ] }