summaryrefslogtreecommitdiffstats
path: root/modules-available/dnbd3/inc/dnbd3util.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2019-03-07 15:23:42 +0100
committerSimon Rettberg2019-03-07 15:23:42 +0100
commit9a8569775996b4b2441b69e06a09b9ab8284519e (patch)
tree4712384eedcb4a67eace6eff9f2c78dabec616df /modules-available/dnbd3/inc/dnbd3util.inc.php
parent[locationinfo] Introduce timeouts for curl operations (diff)
downloadslx-admin-9a8569775996b4b2441b69e06a09b9ab8284519e.tar.gz
slx-admin-9a8569775996b4b2441b69e06a09b9ab8284519e.tar.xz
slx-admin-9a8569775996b4b2441b69e06a09b9ab8284519e.zip
[dnbd3] Support specifying port, IPv6 addresses
Diffstat (limited to 'modules-available/dnbd3/inc/dnbd3util.inc.php')
-rw-r--r--modules-available/dnbd3/inc/dnbd3util.inc.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/modules-available/dnbd3/inc/dnbd3util.inc.php b/modules-available/dnbd3/inc/dnbd3util.inc.php
index 33581b77..35fad8b3 100644
--- a/modules-available/dnbd3/inc/dnbd3util.inc.php
+++ b/modules-available/dnbd3/inc/dnbd3util.inc.php
@@ -52,12 +52,11 @@ class Dnbd3Util {
// Now query them all
$NOW = time();
foreach ($servers as $server) {
- $port = 5003;
- $data = Dnbd3Rpc::query($server['addr'], $port, true, false, false, true);
+ $data = Dnbd3Rpc::query($server['addr'], true, false, false, true);
if ($data === Dnbd3Rpc::QUERY_UNREACHABLE) {
- $error = 'No (HTTP) reply on port ' . $port;
+ $error = 'No (HTTP) reply from ' . $server['addr'];
} elseif ($data === Dnbd3Rpc::QUERY_NOT_200) {
- $error = 'No HTTP 200 OK on port ' . $port;
+ $error = 'No HTTP 200 OK from ' . $server['addr'];
} elseif ($data === Dnbd3Rpc::QUERY_NOT_JSON) {
$error = 'Reply to status query is not JSON';
} elseif (!is_array($data) || !isset($data['runId'])) {
@@ -247,4 +246,19 @@ class Dnbd3Util {
);
}
+ public static function matchAddress($server)
+ {
+ if (!preg_match('/^(?:\[(?<v6a>[a-f0-9:]+)\]|(?<v6b>[a-f0-9:]+)|(?<v4>[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))(?<port>:\d+)?$/i',
+ $server, $out)) {
+ return false;
+ }
+ foreach (['v6a', 'v6b'] as $k) {
+ if (isset($out[$k])) {
+ $out['v6'] = $out[$k];
+ unset($out[$k]);
+ }
+ }
+ return $out;
+ }
+
}