修复部分DNS记录搜索 CF支持暂停解析

This commit is contained in:
net909 2025-04-01 09:47:26 +08:00
parent 4c62084bc6
commit 81a85fce45
8 changed files with 52 additions and 11 deletions

View File

@ -118,7 +118,7 @@ class DnsHelper
'sk' => 'API密钥/令牌',
],
'remark' => 2,
'status' => false,
'status' => true,
'redirect' => false,
'log' => false,
'weight' => false,
@ -161,8 +161,10 @@ class DnsHelper
'dnsla' => ['DEF' => '', 'CT' => '84613316902921216', 'CU' => '84613316923892736', 'CM' => '84613316953252864', 'AB' => ''],
'huoshan' => ['DEF' => 'default', 'CT' => 'telecom', 'CU' => 'unicom', 'CM' => 'mobile', 'AB' => 'oversea'],
'baidu' => ['DEF' => 'default', 'CT' => 'ct', 'CU' => 'cnc', 'CM' => 'cmnet', 'AB' => ''],
'jdcloud' => ['DEF' => '-1', 'CT' => '1', 'CU' => '2', 'CM' => '3', 'AB' => '4'],
'cloudflare' => ['DEF' => '0'],
'namesilo' => ['DEF' => '0'],
'powerdns' => ['DEF' => '0'],
];
public static function getList()

View File

@ -85,7 +85,7 @@ class aliyun implements DeployInterface
$param = [
'Action' => 'ListUserCertificateOrder',
'Keyword' => $certInfo['subject']['CN'],
'OrderType' => 'UPLOAD',
'OrderType' => 'CERT',
];
try {
$data = $client->request($param);

View File

@ -61,8 +61,9 @@ class baidu implements DnsInterface
//获取解析记录列表
public function getDomainRecords($PageNumber = 1, $PageSize = 20, $KeyWord = null, $SubDomain = null, $Value = null, $Type = null, $Line = null, $Status = null)
{
$query = ['rr' => $KeyWord];
$query = [];
if (!isNullOrEmpty($SubDomain)) {
$SubDomain = strtolower($SubDomain);
$query['rr'] = $SubDomain;
}
$data = $this->send_reuqest('GET', '/v1/dns/zone/'.$this->domain.'/record', $query);
@ -84,6 +85,32 @@ class baidu implements DnsInterface
'UpdateTime' => null,
];
}
if (!isNullOrEmpty($SubDomain)) {
$list = array_values(array_filter($list, function ($v) use ($SubDomain) {
return $v['Name'] == $SubDomain;
}));
} else {
if (!isNullOrEmpty($KeyWord)) {
$list = array_values(array_filter($list, function ($v) use ($KeyWord) {
return strpos($v['Name'], $KeyWord) !== false || strpos($v['Value'], $KeyWord) !== false;
}));
}
if (!isNullOrEmpty($Value)) {
$list = array_values(array_filter($list, function ($v) use ($Value) {
return $v['Value'] == $Value;
}));
}
if (!isNullOrEmpty($Type)) {
$list = array_values(array_filter($list, function ($v) use ($Type) {
return $v['Type'] == $Type;
}));
}
if (!isNullOrEmpty($Status)) {
$list = array_values(array_filter($list, function ($v) use ($Status) {
return $v['Status'] == $Status;
}));
}
}
return ['total' => count($list), 'list' => $list];
}
return false;

View File

@ -76,6 +76,8 @@ class cloudflare implements DnsInterface
$list = [];
foreach ($data['result'] as $row) {
$name = $this->domain == $row['name'] ? '@' : str_replace('.'.$this->domain, '', $row['name']);
$status = str_ends_with($name, '_pause') ? '0' : '1';
$name = $status == '0' ? substr($name, 0, -6) : $name;
$list[] = [
'RecordId' => $row['id'],
'Domain' => $this->domain,
@ -85,7 +87,7 @@ class cloudflare implements DnsInterface
'Line' => $row['proxied'] ? '1' : '0',
'TTL' => $row['ttl'],
'MX' => isset($row['priority']) ? $row['priority'] : null,
'Status' => '1',
'Status' => $status,
'Weight' => null,
'Remark' => $row['comment'],
'UpdateTime' => $row['modified_on'],
@ -108,6 +110,8 @@ class cloudflare implements DnsInterface
$data = $this->send_reuqest('GET', '/zones/'.$this->domainid.'/dns_records/'.$RecordId);
if ($data) {
$name = $this->domain == $data['result']['name'] ? '@' : str_replace('.' . $this->domain, '', $data['result']['name']);
$status = str_ends_with($name, '_pause') ? '0' : '1';
$name = $status == '0' ? substr($name, 0, -6) : $name;
return [
'RecordId' => $data['result']['id'],
'Domain' => $this->domain,
@ -117,7 +121,7 @@ class cloudflare implements DnsInterface
'Line' => $data['result']['proxied'] ? '1' : '0',
'TTL' => $data['result']['ttl'],
'MX' => isset($data['result']['priority']) ? $data['result']['priority'] : null,
'Status' => '1',
'Status' => $status,
'Weight' => null,
'Remark' => $data['result']['comment'],
'UpdateTime' => $data['result']['modified_on'],
@ -168,7 +172,9 @@ class cloudflare implements DnsInterface
//设置解析记录状态
public function setDomainRecordStatus($RecordId, $Status)
{
return false;
$info = $this->getDomainRecordInfo($RecordId);
$Name = $Status == '1' ? str_replace('_pause', '', $info['Name']) : $info['Name'] . '_pause';
return $this->updateDomainRecord($RecordId, $Name, $info['Type'], $info['Value'], $info['Line'], $info['TTL'], $info['MX'], $info['Weight'], $info['Remark']);
}
//获取解析记录操作日志

View File

@ -77,7 +77,7 @@ class huoshan implements DnsInterface
{
$query = ['ZID' => intval($this->domainid), 'PageNumber' => $PageNumber, 'PageSize' => $PageSize, 'SearchOrder' => 'desc'];
if (!empty($SubDomain) || !empty($Type) || !empty($Line) || !empty($Value)) {
$query += ['Host' => $SubDomain, 'Value' => $Value, 'Type' => $Type, 'Line' => $Line];
$query += ['Host' => $SubDomain, 'Value' => $Value, 'Type' => $Type, 'Line' => $Line, 'SearchMode' => 'exact'];
} elseif (!empty($KeyWord)) {
$query += ['Host' => $KeyWord];
}

View File

@ -69,9 +69,10 @@ class jdcloud implements DnsInterface
public function getDomainRecords($PageNumber = 1, $PageSize = 20, $KeyWord = null, $SubDomain = null, $Value = null, $Type = null, $Line = null, $Status = null)
{
$query = ['pageNumber' => $PageNumber, 'pageSize' => $PageSize];
if (!empty($SubDomain)) {
if (!isNullOrEmpty($SubDomain)) {
$SubDomain = strtolower($SubDomain);
$query += ['search' => $SubDomain];
} elseif (!empty($KeyWord)) {
} elseif (!isNullOrEmpty($KeyWord)) {
$query += ['search' => $KeyWord];
}
$data = $this->send_request('GET', '/domain/'.$this->domainid.'/ResourceRecord', $query);
@ -96,6 +97,11 @@ class jdcloud implements DnsInterface
'UpdateTime' => date('Y-m-d H:i:s', $row['updateTime']),
];
}
if (!isNullOrEmpty($SubDomain) && !empty($list)) {
$list = array_values(array_filter($list, function ($v) use ($SubDomain) {
return $v['Name'] == $SubDomain;
}));
}
return ['total' => $data['totalCount'], 'list' => $list];
}
return false;

View File

@ -81,7 +81,7 @@ class namesilo implements DnsInterface
}
if(!isNullOrEmpty($SubDomain)){
$list = array_values(array_filter($list, function($v) use ($SubDomain){
return $v['Name'] == $SubDomain;
return strcasecmp($v['Name'], $SubDomain) === 0;
}));
}else{
if(!isNullOrEmpty($KeyWord)){

View File

@ -93,7 +93,7 @@ class powerdns implements DnsInterface
cache('powerdns_' . $this->domainid, $data['rrsets'], 86400);
if (!isNullOrEmpty($SubDomain)) {
$list = array_values(array_filter($list, function ($v) use ($SubDomain) {
return $v['Name'] == $SubDomain;
return strcasecmp($v['Name'], $SubDomain) === 0;
}));
} else {
if (!isNullOrEmpty($KeyWord)) {