update
This commit is contained in:
@@ -95,6 +95,30 @@ class ServerService
|
||||
}
|
||||
}
|
||||
|
||||
public function listRecords(string $domain): array
|
||||
{
|
||||
if (empty($domain)) {
|
||||
return ['error' => true, 'message' => 'Invalid domain'];
|
||||
}
|
||||
|
||||
try {
|
||||
$response = Http::withoutVerifying()
|
||||
->withBasicAuth($this->server->username, Crypt::decryptString($this->server->password))
|
||||
->timeout(15)
|
||||
->get(
|
||||
BaseHelper::url($this->server->ip_address) . $this->entry_points['record'],
|
||||
['domain' => $domain]
|
||||
)->throw();
|
||||
|
||||
$this->resetServer();
|
||||
|
||||
return ['error' => false, 'data' => $response->json() ?? []];
|
||||
} catch (RequestException $e) {
|
||||
Log::error($e->getMessage());
|
||||
return ['error' => true, 'message' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
public function updateRecord(int $record_id = 0): array
|
||||
{
|
||||
if (empty($record_id)) {
|
||||
@@ -146,7 +170,7 @@ class ServerService
|
||||
}
|
||||
}
|
||||
|
||||
public function checkConnection(array $data = []): bool
|
||||
public function checkConnection(array $data = []): array|false
|
||||
{
|
||||
if (empty($data['username']) || empty($data['password']) || empty($data['ip_address'])) {
|
||||
return false;
|
||||
@@ -158,14 +182,14 @@ class ServerService
|
||||
->timeout(10)
|
||||
->get(BaseHelper::url($data['ip_address']) . $this->entry_points['server']);
|
||||
|
||||
return $response->successful();
|
||||
return $response->successful() ? $response->json() : false;
|
||||
} catch (RequestException $e) {
|
||||
Log::error($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkConnectionByServer(DnsServer $server): bool
|
||||
public function checkConnectionByServer(DnsServer $server): array|false
|
||||
{
|
||||
try {
|
||||
return $this->checkConnection([
|
||||
|
||||
Reference in New Issue
Block a user