diff --git a/networks/lostfilm.json b/networks/lostfilm.json new file mode 100644 index 0000000..12b690c --- /dev/null +++ b/networks/lostfilm.json @@ -0,0 +1,7 @@ +{ + "description": "lostfilm", + "domains": [], + "networks": [ + "104.21.0.0/17" + ] +} \ No newline at end of file diff --git a/plugins/openvpn/Openvpn.php b/plugins/openvpn/Openvpn.php index 94968d3..8e8b349 100755 --- a/plugins/openvpn/Openvpn.php +++ b/plugins/openvpn/Openvpn.php @@ -5,9 +5,24 @@ class Openvpn implements IPluggable { private PluginContext $context; - public function init(PluginContext $context) + public function restart() + { + //restart ovpn + return shell_exec($this->context->getConfig()["ovpn"]["restart_cmd"]); + } + + public function init(PluginContext $context): void { $this->context = $context; + $this->checkConfig(); + } + + private function checkConfig(): void + { + $config = $this->context->getConfig(); + if (!isset($config["ovpn"])) { + $config["ovpn"] = $this->context->getMetadata()["config"]; + } } public function getRoutingConfig(): array diff --git a/plugins/openvpn/metadata.json b/plugins/openvpn/metadata.json index fe1b9d5..97ff5c7 100644 --- a/plugins/openvpn/metadata.json +++ b/plugins/openvpn/metadata.json @@ -1,6 +1,6 @@ { "class": "Openvpn", "config": { - + "restart_cmd": "/etc/init.d/zebra restart" } } \ No newline at end of file diff --git a/plugins/openvpn/plugin.js b/plugins/openvpn/plugin.js new file mode 100644 index 0000000..2954ee3 --- /dev/null +++ b/plugins/openvpn/plugin.js @@ -0,0 +1,20 @@ +import {App} from "/assets/App.js"; +(async function () { + $("#buttons").append(``); + $("#restart-ovpn").click(function () { + if (confirm("Are you sure?")) { + const self = $(this); + self.prop("disabled", true); + (async function () { + try { + alert(await App.RPC.__invoke("openvpn::restart")); + } finally { + setTimeout(() => { + self.prop("disabled", false); + }, 5000); + } + + })(); + } + }); +})(); \ No newline at end of file diff --git a/restart.php b/restart.php new file mode 100644 index 0000000..df4c10f --- /dev/null +++ b/restart.php @@ -0,0 +1,12 @@ +#!/usr/bin/php +