diff options
-rw-r--r-- | apis/debugrequest.php | 18 | ||||
-rw-r--r-- | inc/property.inc.php | 9 |
2 files changed, 27 insertions, 0 deletions
diff --git a/apis/debugrequest.php b/apis/debugrequest.php new file mode 100644 index 00000000..d9f1a169 --- /dev/null +++ b/apis/debugrequest.php @@ -0,0 +1,18 @@ +<?php + +$debug_settings = Property::getRemoteDebuggingConfig(); +if ($debug_settings["status"] !== "enabled") { + http_response_code(403); + exit; +} + +$debug_request = json_decode(file_get_contents("php://input")); + +$validclient = Database::queryFirst("SELECT * FROM machine WHERE machineuuid = :uuid AND clientip = :ip", array(":uuid" => $debug_request["uuid"], ":ip" => $_SERVER["REMOTE_ADDR"])); +if ($validclient == false) { + http_response_code(400); +} else { + http_response_code(200); + $data = json_encode(array("uuid" => $debug_request["uuid"], "ip" => $_SERVER["REMOTE_ADDR"], "port" => $debug_request["port"])); + Taskmanager::submit('relay', $data, true); +} diff --git a/inc/property.inc.php b/inc/property.inc.php index 9adfbda3..0eb700e3 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -191,4 +191,13 @@ class Property return self::get('default-ipxe'); } + public static function getRemoteDebugConfig() + { + return self::get('remote-debug-config'); + } + + public static function setRemoteDebugConfig($value) + { + return self::set('remote-debug-config', $value); + } } |