diff options
author | Guillaume Mazoyer <gmazoyer@gravitons.in> | 2016-06-13 00:00:32 +0200 |
---|---|---|
committer | Guillaume Mazoyer <gmazoyer@gravitons.in> | 2016-06-13 00:00:32 +0200 |
commit | 669fb2ebd03ac5e9b0806acb1c200e71e69b3d47 (patch) | |
tree | 39aa2352c0f14e3f94dcf4c0237e8fc81c9a0bd7 /execute.php | |
parent | 28bf462793fc9c15e70b73d3eb2223f6328abb84 (diff) |
Catch use of disable IP version before instanciating the router object.
Simplify the code and avoid unneeded computation.
Diffstat (limited to 'execute.php')
-rw-r--r-- | execute.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/execute.php b/execute.php index 71dc304..227c6e6 100644 --- a/execute.php +++ b/execute.php @@ -22,6 +22,7 @@ require_once('includes/config.defaults.php'); require_once('config.php'); require_once('routers/router.php'); +require_once('includes/utils.php'); // From where the user *really* comes from. if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { @@ -52,6 +53,20 @@ if (isset($_POST['query']) && !empty($_POST['query']) && // Do the processing $router = Router::instance($hostname, $requester); + // Check if parameter is an IPv6 and if IPv6 is disabled + if (match_ipv6($parameter) && $config['misc']['disable_ipv6']) { + $error = 'IPv6 has been disabled, you can only use IPv4.'; + print(json_encode(array('error' => $error))); + return; + } + + // Check if parameter is an IPv4 and if IPv4 is disabled + if (match_ipv4($parameter) && $config['misc']['disable_ipv4']) { + $error = 'IPv4 has been disabled, you can only use IPv6.'; + print(json_encode(array('error' => $error))); + return; + } + try { $output = $router->send_command($query, $parameter); } catch (Exception $e) { |