mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-07-15 08:48:08 +00:00
Update index.php
This commit is contained in:
parent
3c2d4b1845
commit
e43ee02b3b
30
index.php
30
index.php
|
@ -288,7 +288,26 @@ function relay_get_loaded_extensions() {
|
|||
|
||||
function relay_dns_get_record($params) {
|
||||
$hostname = $params['hostname'];
|
||||
return dns_get_record($hostname);
|
||||
|
||||
$data = dns_get_record($hostname);
|
||||
if (!$data) {
|
||||
return array(
|
||||
"success" => false,
|
||||
"error" => array(
|
||||
"status" => 502,
|
||||
"code" => -1,
|
||||
"message" => $hostname . " is not found in DNS records"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return array(
|
||||
"success" => true,
|
||||
"result" => array(
|
||||
"status" => 200,
|
||||
"data" => $data
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
function relay_get_geolocation() {
|
||||
|
@ -391,11 +410,16 @@ if ($context['jsonrpc'] == "2.0") {
|
|||
break;
|
||||
|
||||
case "relay_dns_get_record":
|
||||
echo jsonrpc2_result_encode(relay_dns_get_record($context['params']), $context['id']);
|
||||
$result = relay_dns_get_record($context['params']);
|
||||
if ($result['success']) {
|
||||
echo jsonrpc2_result_encode($result['result'], $context['id']);
|
||||
} else {
|
||||
echo jsonrpc2_error_encode($result['error'], $context['id']);
|
||||
}
|
||||
break;
|
||||
|
||||
case "relay_get_geolocation":
|
||||
$result = jsonrpc2_result_encode(relay_get_geolocation(), $context['id']);
|
||||
$result = relay_get_geolocation();
|
||||
if ($result['success']) {
|
||||
echo jsonrpc2_result_encode($result['result'], $context['id']);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user