From 20aab09a5f55ab1dbe9e3f05827749814a56d53b Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Sun, 29 Oct 2023 20:46:10 -0400 Subject: [PATCH] added POST to proxies endpoint --- www/api/controllers/proxies.php | 15 +++++++++++++++ www/api/endpoints.json | 25 +++++++++++++++++++++++++ www/api/index.php | 1 + 3 files changed, 41 insertions(+) diff --git a/www/api/controllers/proxies.php b/www/api/controllers/proxies.php index 64b52ad7c..81a2c4034 100644 --- a/www/api/controllers/proxies.php +++ b/www/api/controllers/proxies.php @@ -22,6 +22,21 @@ function LoadProxyList() return $proxies; } +function PostProxies() +{ + $proxies = $_POST; + if (!empty($proxies)) { + WriteProxyFile($proxies); + + //Trigger a JSON Configuration Backup + GenerateBackupViaAPI('Proxies were added.'); + + return json($proxies); + } else { + http_response_code(400); // Bad Request + } +} + function WriteProxyFile($proxies) { global $settings; diff --git a/www/api/endpoints.json b/www/api/endpoints.json index adef5e0d0..cfe8980f8 100644 --- a/www/api/endpoints.json +++ b/www/api/endpoints.json @@ -2050,6 +2050,31 @@ "192.168.1.146", "192.168.1.148" ] + }, + "POST": { + "desc": "Post a list of IP addresses that this FPP instance can proxy", + "output": [ + "192.168.1.2", + "192.168.1.146", + "192.168.1.148" + ] + } + } + }, + { + "endpoint": "proxies/:ProxyIp", + "methods": { + "POST": { + "desc": "Add an IP address to this FPP instance can proxy", + "output": [ + "192.168.1.2" + ] + }, + "DELETE": { + "desc": "Delete an IP address from FPP proxy list", + "output": [ + + ] } } }, diff --git a/www/api/index.php b/www/api/index.php index 9c4fc6066..6cf40ca51 100644 --- a/www/api/index.php +++ b/www/api/index.php @@ -120,6 +120,7 @@ // which are added after the above endpoints via addPluginEndpoints() below. dispatch_get('/proxies', 'GetProxies'); +dispatch_post('/proxies', 'PostProxies'); dispatch_post('/proxies/:ProxyIp', 'AddProxy'); dispatch_delete('/proxies/:ProxyIp', 'DeleteProxy');