diff --git a/bin/ovpn-connect b/bin/ovpn-connect index cf9b845..c6aa96d 100755 --- a/bin/ovpn-connect +++ b/bin/ovpn-connect @@ -15,7 +15,7 @@ try { throw new RuntimeException("Plugin is not enabled"); } /** - * @var Openvpn $instance + * @var Custom $instance */ $config = $instance->getRoutingConfig(); diff --git a/classes/IPluggable.php b/classes/IPluggable.php index c8c4349..60fee4c 100644 --- a/classes/IPluggable.php +++ b/classes/IPluggable.php @@ -4,5 +4,5 @@ interface IPluggable { public function onServerStarted(); public function onInit(PluginContext $context); - public function onSync(); + public function onSync(array $remote_config); } \ No newline at end of file diff --git a/classes/Plugin.php b/classes/Plugin.php index d8089bf..3ab545d 100644 --- a/classes/Plugin.php +++ b/classes/Plugin.php @@ -10,7 +10,7 @@ abstract class Plugin implements IPluggable } - public function onSync() + public function onSync($remote_config) { } diff --git a/plugins/custom/Custom.php b/plugins/custom/Custom.php new file mode 100755 index 0000000..cccdd98 --- /dev/null +++ b/plugins/custom/Custom.php @@ -0,0 +1,25 @@ +#!/usr/bin/php +config = $remote_config["custom"]; + $this->saveConfig(); + + $path = dirname(__DIR__) . "/networks/custom.json"; + file_put_contents($path, json_encode($this->config)); + } + + protected function checkConfig(): void + { + parent::checkConfig(); + } + + +} + diff --git a/plugins/custom/metadata.json b/plugins/custom/metadata.json new file mode 100644 index 0000000..47d6838 --- /dev/null +++ b/plugins/custom/metadata.json @@ -0,0 +1,10 @@ +{ + "class": "Custom", + "config": { + "description": "Custom routes", + "domains": [ + ], + "networks": [ + ] + } +} \ No newline at end of file diff --git a/plugins/custom/plugin.js b/plugins/custom/plugin.js new file mode 100644 index 0000000..e69de29 diff --git a/plugins/named/BindPlugin.php b/plugins/named/BindPlugin.php index 8f4723b..f4e2c9c 100644 --- a/plugins/named/BindPlugin.php +++ b/plugins/named/BindPlugin.php @@ -50,7 +50,7 @@ TXT; $this->restart(); } - public function onSync() + public function onSync($remote_config) { $this->restart(); } diff --git a/plugins/netsync/Netsync.php b/plugins/netsync/Netsync.php index 5bf9be7..0351a05 100644 --- a/plugins/netsync/Netsync.php +++ b/plugins/netsync/Netsync.php @@ -40,10 +40,10 @@ class Netsync extends Plugin $header = @json_decode($output, true); - $result = $header["result"] ?? null; + $remote_config = $header["result"] ?? null; - $networks = $result["networks"] ?? null; - if ($result === null or $networks === null) { + $networks = $remote_config["networks"] ?? null; + if ($remote_config === null or $networks === null) { throw new RuntimeException("Response has invalid data"); } @@ -63,7 +63,7 @@ class Netsync extends Plugin * @var IPluggable $plugin */ - $plugin->onSync(); + $plugin->onSync($remote_config); } } diff --git a/plugins/openvpn/Openvpn.php b/plugins/openvpn/Openvpn.php index a042b47..b2f9a89 100755 --- a/plugins/openvpn/Openvpn.php +++ b/plugins/openvpn/Openvpn.php @@ -36,7 +36,7 @@ class Openvpn extends Plugin $this->restart(); } - public function onSync() + public function onSync($remote_config) { $this->restart(); } diff --git a/plugins/quagga/QuaggaPlugin.php b/plugins/quagga/QuaggaPlugin.php index 4b504bb..6618612 100644 --- a/plugins/quagga/QuaggaPlugin.php +++ b/plugins/quagga/QuaggaPlugin.php @@ -75,7 +75,7 @@ class QuaggaPlugin extends Plugin $this->restart(); } - public function onSync() + public function onSync($remote_config) { $this->restart(); }