This commit is contained in:
net909 2024-10-11 20:03:41 +08:00
parent 3b93ee1203
commit 86adfd018a
15 changed files with 135 additions and 53 deletions

View File

@ -407,6 +407,7 @@ class Domain extends BaseController
$value = input('post.value', null, 'trim'); $value = input('post.value', null, 'trim');
$line = input('post.line', null, 'trim'); $line = input('post.line', null, 'trim');
$ttl = input('post.ttl/d', 600); $ttl = input('post.ttl/d', 600);
$weight = input('post.weight/d', 0);
$mx = input('post.mx/d', 1); $mx = input('post.mx/d', 1);
$remark = input('post.remark', null, 'trim'); $remark = input('post.remark', null, 'trim');
@ -415,7 +416,7 @@ class Domain extends BaseController
} }
$dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']); $dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']);
$recordid = $dns->addDomainRecord($name, $type, $value, $line, $ttl, $mx, $remark); $recordid = $dns->addDomainRecord($name, $type, $value, $line, $ttl, $mx, $weight, $remark);
if($recordid){ if($recordid){
$this->add_log($drow['name'], '添加解析', $type.'记录 '.$name.' '.$value.' (线路:'.$line.' TTL:'.$ttl.')'); $this->add_log($drow['name'], '添加解析', $type.'记录 '.$name.' '.$value.' (线路:'.$line.' TTL:'.$ttl.')');
return json(['code'=>0, 'msg'=>'添加解析记录成功!']); return json(['code'=>0, 'msg'=>'添加解析记录成功!']);
@ -438,6 +439,7 @@ class Domain extends BaseController
$value = input('post.value', null, 'trim'); $value = input('post.value', null, 'trim');
$line = input('post.line', null, 'trim'); $line = input('post.line', null, 'trim');
$ttl = input('post.ttl/d', 600); $ttl = input('post.ttl/d', 600);
$weight = input('post.weight/d', 0);
$mx = input('post.mx/d', 1); $mx = input('post.mx/d', 1);
$remark = input('post.remark', null, 'trim'); $remark = input('post.remark', null, 'trim');
@ -446,7 +448,7 @@ class Domain extends BaseController
} }
$dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']); $dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']);
$recordid = $dns->updateDomainRecord($recordid, $name, $type, $value, $line, $ttl, $mx, $remark); $recordid = $dns->updateDomainRecord($recordid, $name, $type, $value, $line, $ttl, $mx, $weight, $remark);
if($recordid){ if($recordid){
$this->add_log($drow['name'], '修改解析', $type.'记录 '.$name.' '.$value.' (线路:'.$line.' TTL:'.$ttl.')'); $this->add_log($drow['name'], '修改解析', $type.'记录 '.$name.' '.$value.' (线路:'.$line.' TTL:'.$ttl.')');
return json(['code'=>0, 'msg'=>'修改解析记录成功!']); return json(['code'=>0, 'msg'=>'修改解析记录成功!']);
@ -608,7 +610,7 @@ class Domain extends BaseController
$success = 0; $fail = 0; $success = 0; $fail = 0;
foreach($recordinfo as $record){ foreach($recordinfo as $record){
$recordid = $dns->updateDomainRecord($record['recordid'], $record['name'], $type, $value, $record['line'], $record['ttl'], $record['mx'], $record['remark']); $recordid = $dns->updateDomainRecord($record['recordid'], $record['name'], $type, $value, $record['line'], $record['ttl'], $record['mx'], $record['weight'], $record['remark']);
if($recordid){ if($recordid){
$this->add_log($drow['name'], '修改解析', $type.'记录 '.$record['name'].' '.$value.' (线路:'.$record['line'].' TTL:'.$record['ttl'].')'); $this->add_log($drow['name'], '修改解析', $type.'记录 '.$record['name'].' '.$value.' (线路:'.$record['line'].' TTL:'.$record['ttl'].')');
$success++; $success++;
@ -629,7 +631,7 @@ class Domain extends BaseController
$success = 0; $fail = 0; $success = 0; $fail = 0;
foreach($recordinfo as $record){ foreach($recordinfo as $record){
$recordid = $dns->updateDomainRecord($record['recordid'], $record['name'], $record['type'], $record['value'], $line, $record['ttl'], $record['mx'], $record['remark']); $recordid = $dns->updateDomainRecord($record['recordid'], $record['name'], $record['type'], $record['value'], $line, $record['ttl'], $record['mx'], $record['weight'], $record['remark']);
if($recordid){ if($recordid){
$this->add_log($drow['name'], '修改解析', $record['type'].'记录 '.$record['name'].' '.$record['value'].' (线路:'.$line.' TTL:'.$record['ttl'].')'); $this->add_log($drow['name'], '修改解析', $record['type'].'记录 '.$record['name'].' '.$record['value'].' (线路:'.$line.' TTL:'.$record['ttl'].')');
$success++; $success++;

View File

@ -16,6 +16,7 @@ class DnsHelper
'status' => true, //是否支持启用暂停 'status' => true, //是否支持启用暂停
'redirect' => true, //是否支持域名转发 'redirect' => true, //是否支持域名转发
'log' => true, //是否支持查看日志 'log' => true, //是否支持查看日志
'weight' => false, //是否支持权重
], ],
'dnspod' => [ 'dnspod' => [
'name' => '腾讯云', 'name' => '腾讯云',
@ -27,6 +28,7 @@ class DnsHelper
'status' => true, 'status' => true,
'redirect' => true, 'redirect' => true,
'log' => true, 'log' => true,
'weight' => true,
], ],
'huawei' => [ 'huawei' => [
'name' => '华为云', 'name' => '华为云',
@ -38,6 +40,7 @@ class DnsHelper
'status' => true, 'status' => true,
'redirect' => false, 'redirect' => false,
'log' => false, 'log' => false,
'weight' => true,
], ],
'baidu' => [ 'baidu' => [
'name' => '百度云', 'name' => '百度云',
@ -49,6 +52,7 @@ class DnsHelper
'status' => false, 'status' => false,
'redirect' => false, 'redirect' => false,
'log' => false, 'log' => false,
'weight' => false,
], ],
'west' => [ 'west' => [
'name' => '西部数码', 'name' => '西部数码',
@ -60,6 +64,7 @@ class DnsHelper
'status' => true, 'status' => true,
'redirect' => false, 'redirect' => false,
'log' => false, 'log' => false,
'weight' => false,
], ],
'huoshan' => [ 'huoshan' => [
'name' => '火山引擎', 'name' => '火山引擎',
@ -71,6 +76,7 @@ class DnsHelper
'status' => true, 'status' => true,
'redirect' => false, 'redirect' => false,
'log' => false, 'log' => false,
'weight' => true,
], ],
'dnsla' => [ 'dnsla' => [
'name' => 'DNSLA', 'name' => 'DNSLA',
@ -82,6 +88,7 @@ class DnsHelper
'status' => true, 'status' => true,
'redirect' => true, 'redirect' => true,
'log' => false, 'log' => false,
'weight' => true,
], ],
'cloudflare' => [ 'cloudflare' => [
'name' => 'Cloudflare', 'name' => 'Cloudflare',
@ -93,6 +100,7 @@ class DnsHelper
'status' => false, 'status' => false,
'redirect' => false, 'redirect' => false,
'log' => false, 'log' => false,
'weight' => false,
], ],
]; ];

View File

@ -16,9 +16,9 @@ interface DnsInterface
function getDomainRecordInfo($RecordId); function getDomainRecordInfo($RecordId);
function addDomainRecord($Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = 1, $Remark = null); function addDomainRecord($Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = 1, $Weight = null, $Remark = null);
function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = 1, $Remark = null); function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = 1, $Weight = null, $Remark = null);
function updateDomainRecordRemark($RecordId, $Remark); function updateDomainRecordRemark($RecordId, $Remark);

View File

@ -28,7 +28,7 @@ class OptimizeService
}elseif($api == 1){ }elseif($api == 1){
$url = 'https://api.hostmonit.com/get_license?license='.$key; $url = 'https://api.hostmonit.com/get_license?license='.$key;
}else{ }else{
$url = 'https://www.182682.xyz/api/cf2dns/get_license?license='.$key; $url = 'https://www.wetest.vip/api/cf2dns/get_license?license='.$key;
} }
$response = get_curl($url); $response = get_curl($url);
$arr = json_decode($response, true); $arr = json_decode($response, true);
@ -48,7 +48,7 @@ class OptimizeService
}elseif($api == 1){ }elseif($api == 1){
$url = 'https://api.hostmonit.com/get_optimization_ip'; $url = 'https://api.hostmonit.com/get_optimization_ip';
}else{ }else{
$url = 'https://www.182682.xyz/api/cf2dns/'; $url = 'https://www.wetest.vip/api/cf2dns/';
if($cdn_type == 1){ if($cdn_type == 1){
$url .= 'get_cloudflare_ip'; $url .= 'get_cloudflare_ip';
}elseif($cdn_type == 2){ }elseif($cdn_type == 2){

View File

@ -135,7 +135,7 @@ class aliyun implements DnsInterface {
} }
//添加解析记录 //添加解析记录
public function addDomainRecord($Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = null, $Remark = null){ public function addDomainRecord($Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = null, $Weight = null, $Remark = null){
$param = ['Action' => 'AddDomainRecord', 'DomainName' => $this->domain, 'RR' => $Name, 'Type' => $Type, 'Value' => $Value, 'Line' => $this->convertLineCode($Line), 'TTL' => intval($TTL)]; $param = ['Action' => 'AddDomainRecord', 'DomainName' => $this->domain, 'RR' => $Name, 'Type' => $Type, 'Value' => $Value, 'Line' => $this->convertLineCode($Line), 'TTL' => intval($TTL)];
if($MX){ if($MX){
$param['Priority'] = intval($MX); $param['Priority'] = intval($MX);
@ -148,7 +148,7 @@ class aliyun implements DnsInterface {
} }
//修改解析记录 //修改解析记录
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = null, $Remark = null){ public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = null, $Weight = null, $Remark = null){
$param = ['Action' => 'UpdateDomainRecord', 'RecordId' => $RecordId, 'RR' => $Name, 'Type' => $Type, 'Value' => $Value, 'Line' => $this->convertLineCode($Line), 'TTL' => intval($TTL)]; $param = ['Action' => 'UpdateDomainRecord', 'RecordId' => $RecordId, 'RR' => $Name, 'Type' => $Type, 'Value' => $Value, 'Line' => $this->convertLineCode($Line), 'TTL' => intval($TTL)];
if($MX){ if($MX){
$param['Priority'] = intval($MX); $param['Priority'] = intval($MX);

View File

@ -85,38 +85,40 @@ class baidu implements DnsInterface {
//获取解析记录详细信息 //获取解析记录详细信息
public function getDomainRecordInfo($RecordId){ public function getDomainRecordInfo($RecordId){
$data = $this->send_reuqest('GET', '/v2.1/zones/'.$this->domainid.'/recordsets/'.$RecordId); $query = ['id' => $RecordId];
if($data){ $data = $this->send_reuqest('GET', '/v1/dns/zone/'.$this->domain.'/record', $query);
if($data && !empty($data['records'])){
$data = $data['records'][0];
return [ return [
'RecordId' => $data['id'], 'RecordId' => $data['id'],
'Domain' => rtrim($data['zone_name'], '.'), 'Domain' => rtrim($data['zone_name'], '.'),
'Name' => str_replace('.'.$data['zone_name'], '', $data['name']), 'Name' => str_replace('.'.$data['zone_name'], '', $data['name']),
'Type' => $data['type'], 'Type' => $data['type'],
'Value' => $data['records'], 'Value' => $data['value'],
'Line' => $data['line'], 'Line' => $data['line'],
'TTL' => $data['ttl'], 'TTL' => $data['ttl'],
'MX' => $data['weight'], 'MX' => $data['priority'],
'Status' => $data['status'] == 'ACTIVE' ? '1' : '0', 'Status' => $data['status'] == 'running' ? '1' : '0',
'Weight' => $data['weight'], 'Weight' => null,
'Remark' => $data['description'], 'Remark' => $data['description'],
'UpdateTime' => $data['updated_at'], 'UpdateTime' => null,
]; ];
} }
return false; return false;
} }
//添加解析记录 //添加解析记录
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$params = ['rr' => $Name, 'type' => $this->convertType($Type), 'value' => $Value, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark]; $params = ['rr' => $Name, 'type' => $this->convertType($Type), 'value' => $Value, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
if($Type == 'MX')$param['priority'] = intval($MX); if($Type == 'MX')$params['priority'] = intval($MX);
$query = ['clientToken' => getSid()]; $query = ['clientToken' => getSid()];
return $this->send_reuqest('POST', '/v1/dns/zone/'.$this->domain.'/record', $query, $params); return $this->send_reuqest('POST', '/v1/dns/zone/'.$this->domain.'/record', $query, $params);
} }
//修改解析记录 //修改解析记录
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$params = ['rr' => $Name, 'type' => $this->convertType($Type), 'value' => $Value, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark]; $params = ['rr' => $Name, 'type' => $this->convertType($Type), 'value' => $Value, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
if($Type == 'MX')$param['priority'] = intval($MX); if($Type == 'MX')$params['priority'] = intval($MX);
$query = ['clientToken' => getSid()]; $query = ['clientToken' => getSid()];
return $this->send_reuqest('PUT', '/v1/dns/zone/'.$this->domain.'/record/'.$RecordId, $query, $params); return $this->send_reuqest('PUT', '/v1/dns/zone/'.$this->domain.'/record/'.$RecordId, $query, $params);
} }

View File

@ -112,17 +112,25 @@ class cloudflare implements DnsInterface {
} }
//添加解析记录 //添加解析记录
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $Weight = null, $MX = 1, $Remark = null){
$param = ['name' => $Name, 'type' => $this->convertType($Type), 'content' => $Value, 'proxied' => $Line=='1', 'ttl' => intval($TTL), 'comment' => $Remark]; $param = ['name' => $Name, 'type' => $this->convertType($Type), 'content' => $Value, 'proxied' => $Line=='1', 'ttl' => intval($TTL), 'comment' => $Remark];
if($Type == 'MX')$param['priority'] = intval($MX); if($Type == 'MX')$param['priority'] = intval($MX);
if($Type == 'CAA' || $Type == 'SRV'){
unset($param['content']);
$param['data'] = $this->convertValue($Value, $Type);
}
$data = $this->send_reuqest('POST', '/zones/'.$this->domainid.'/dns_records', $param); $data = $this->send_reuqest('POST', '/zones/'.$this->domainid.'/dns_records', $param);
return is_array($data) ? $data['result']['id'] : false; return is_array($data) ? $data['result']['id'] : false;
} }
//修改解析记录 //修改解析记录
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $Weight = null, $MX = 1, $Remark = null){
$param = ['name' => $Name, 'type' => $this->convertType($Type), 'content' => $Value, 'proxied' => $Line=='1', 'ttl' => intval($TTL), 'comment' => $Remark]; $param = ['name' => $Name, 'type' => $this->convertType($Type), 'content' => $Value, 'proxied' => $Line=='1', 'ttl' => intval($TTL), 'comment' => $Remark];
if($Type == 'MX')$param['priority'] = intval($MX); if($Type == 'MX')$param['priority'] = intval($MX);
if($Type == 'CAA' || $Type == 'SRV'){
unset($param['content']);
$param['data'] = $this->convertValue($Value, $Type);
}
$data = $this->send_reuqest('PATCH', '/zones/'.$this->domainid.'/dns_records/'.$RecordId, $param); $data = $this->send_reuqest('PATCH', '/zones/'.$this->domainid.'/dns_records/'.$RecordId, $param);
return is_array($data); return is_array($data);
} }
@ -175,6 +183,34 @@ class cloudflare implements DnsInterface {
return $type; return $type;
} }
private function convertValue($value, $type){
if($type == 'SRV'){
$arr = explode(' ', $value);
if(count($arr) > 3){
$data = [
'priority' => intval($arr[0]),
'weight' => intval($arr[1]),
'port' => intval($arr[2]),
'target' => $arr[3],
];
}else{
$data = [
'weight' => intval($arr[0]),
'port' => intval($arr[1]),
'target' => $arr[2],
];
}
}elseif($type == 'CAA'){
$arr = explode(' ', $value);
$data = [
'flags' => intval($arr[0]),
'tag' => $arr[1],
'value' => trim($arr[2], '"'),
];
}
return $data;
}
private function send_reuqest($method, $path, $params = null){ private function send_reuqest($method, $path, $params = null){
$url = $this->baseUrl . $path; $url = $this->baseUrl . $path;

View File

@ -102,21 +102,23 @@ class dnsla implements DnsInterface {
} }
//添加解析记录 //添加解析记录
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$param = ['domainId' => $this->domainid, 'type' => $this->convertType($Type), 'host' => $Name, 'data' => $Value, 'ttl' => intval($TTL), 'lineId' => $Line]; $param = ['domainId' => $this->domainid, 'type' => $this->convertType($Type), 'host' => $Name, 'data' => $Value, 'ttl' => intval($TTL), 'lineId' => $Line];
if($Type == 'MX')$param['preference'] = intval($MX); if($Type == 'MX')$param['preference'] = intval($MX);
if($Type == 'REDIRECT_URL'){$param['type'] = 256;$param['dominant'] = true;} if($Type == 'REDIRECT_URL'){$param['type'] = 256;$param['dominant'] = true;}
elseif($Type == 'FORWARD_URL'){$param['type'] = 256;$param['dominant'] = false;} elseif($Type == 'FORWARD_URL'){$param['type'] = 256;$param['dominant'] = false;}
if($Weight > 0) $param['weight'] = $Weight;
$data = $this->execute('POST', '/api/record', $param); $data = $this->execute('POST', '/api/record', $param);
return is_array($data) ? $data['id'] : false; return is_array($data) ? $data['id'] : false;
} }
//修改解析记录 //修改解析记录
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$param = ['id' => $RecordId, 'type' => $this->convertType($Type), 'host' => $Name, 'data' => $Value, 'ttl' => intval($TTL), 'lineId' => $Line]; $param = ['id' => $RecordId, 'type' => $this->convertType($Type), 'host' => $Name, 'data' => $Value, 'ttl' => intval($TTL), 'lineId' => $Line];
if($Type == 'MX')$param['preference'] = intval($MX); if($Type == 'MX')$param['preference'] = intval($MX);
if($Type == 'REDIRECT_URL'){$param['type'] = 256;$param['dominant'] = true;} if($Type == 'REDIRECT_URL'){$param['type'] = 256;$param['dominant'] = true;}
elseif($Type == 'FORWARD_URL'){$param['type'] = 256;$param['dominant'] = false;} elseif($Type == 'FORWARD_URL'){$param['type'] = 256;$param['dominant'] = false;}
if($Weight > 0) $param['weight'] = $Weight;
$data = $this->execute('PUT', '/api/record', $param); $data = $this->execute('PUT', '/api/record', $param);
return $data!==false; return $data!==false;
} }

View File

@ -128,18 +128,18 @@ class dnspod implements DnsInterface {
} }
//添加解析记录 //添加解析记录
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$action = 'CreateRecord'; $action = 'CreateRecord';
$param = ['Domain' => $this->domain, 'SubDomain' => $Name, 'RecordType' => $this->convertType($Type), 'Value' => $Value, 'RecordLine'=>$Line, 'RecordLineId' => $this->convertLineCode($Line), 'TTL' => intval($TTL)]; $param = ['Domain' => $this->domain, 'SubDomain' => $Name, 'RecordType' => $this->convertType($Type), 'Value' => $Value, 'RecordLine'=>$Line, 'RecordLineId' => $this->convertLineCode($Line), 'TTL' => intval($TTL), 'Weight' => $Weight];
if($Type == 'MX')$param['MX'] = intval($MX); if($Type == 'MX')$param['MX'] = intval($MX);
$data = $this->send_reuqest($action, $param); $data = $this->send_reuqest($action, $param);
return is_array($data) ? $data['RecordId'] : false; return is_array($data) ? $data['RecordId'] : false;
} }
//修改解析记录 //修改解析记录
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$action = 'ModifyRecord'; $action = 'ModifyRecord';
$param = ['Domain' => $this->domain, 'RecordId' => intval($RecordId), 'SubDomain' => $Name, 'RecordType' => $this->convertType($Type), 'Value' => $Value, 'RecordLine'=>$Line, 'RecordLineId' => $this->convertLineCode($Line), 'TTL' => intval($TTL)]; $param = ['Domain' => $this->domain, 'RecordId' => intval($RecordId), 'SubDomain' => $Name, 'RecordType' => $this->convertType($Type), 'Value' => $Value, 'RecordLine'=>$Line, 'RecordLineId' => $this->convertLineCode($Line), 'TTL' => intval($TTL), 'Weight' => $Weight];
if($Type == 'MX')$param['MX'] = intval($MX); if($Type == 'MX')$param['MX'] = intval($MX);
$data = $this->send_reuqest($action, $param); $data = $this->send_reuqest($action, $param);
return is_array($data); return is_array($data);

View File

@ -66,6 +66,7 @@ class huawei implements DnsInterface {
$list = []; $list = [];
foreach($data['recordsets'] as $row){ foreach($data['recordsets'] as $row){
if($row['name'] == $row['zone_name']) $row['name'] = '@'; if($row['name'] == $row['zone_name']) $row['name'] = '@';
if($row['type'] == 'MX') list($row['mx'], $row['records']) = explode(' ', $row['records'][0]);
$list[] = [ $list[] = [
'RecordId' => $row['id'], 'RecordId' => $row['id'],
'Domain' => rtrim($row['zone_name'], '.'), 'Domain' => rtrim($row['zone_name'], '.'),
@ -74,7 +75,7 @@ class huawei implements DnsInterface {
'Value' => $row['records'], 'Value' => $row['records'],
'Line' => $row['line'], 'Line' => $row['line'],
'TTL' => $row['ttl'], 'TTL' => $row['ttl'],
'MX' => $row['weight'], 'MX' => isset($row['mx']) ? $row['mx'] : null,
'Status' => $row['status'] == 'ACTIVE' ? '1' : '0', 'Status' => $row['status'] == 'ACTIVE' ? '1' : '0',
'Weight' => $row['weight'], 'Weight' => $row['weight'],
'Remark' => $row['description'], 'Remark' => $row['description'],
@ -96,6 +97,7 @@ class huawei implements DnsInterface {
$data = $this->send_reuqest('GET', '/v2.1/zones/'.$this->domainid.'/recordsets/'.$RecordId); $data = $this->send_reuqest('GET', '/v2.1/zones/'.$this->domainid.'/recordsets/'.$RecordId);
if($data){ if($data){
if($data['name'] == $data['zone_name']) $data['name'] = '@'; if($data['name'] == $data['zone_name']) $data['name'] = '@';
if($data['type'] == 'MX') list($data['mx'], $data['records']) = explode(' ', $data['records'][0]);
return [ return [
'RecordId' => $data['id'], 'RecordId' => $data['id'],
'Domain' => rtrim($data['zone_name'], '.'), 'Domain' => rtrim($data['zone_name'], '.'),
@ -104,7 +106,7 @@ class huawei implements DnsInterface {
'Value' => $data['records'], 'Value' => $data['records'],
'Line' => $data['line'], 'Line' => $data['line'],
'TTL' => $data['ttl'], 'TTL' => $data['ttl'],
'MX' => $data['weight'], 'MX' => isset($data['mx']) ? $data['mx'] : null,
'Status' => $data['status'] == 'ACTIVE' ? '1' : '0', 'Status' => $data['status'] == 'ACTIVE' ? '1' : '0',
'Weight' => $data['weight'], 'Weight' => $data['weight'],
'Remark' => $data['description'], 'Remark' => $data['description'],
@ -115,23 +117,25 @@ class huawei implements DnsInterface {
} }
//添加解析记录 //添加解析记录
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$Name = $this->getHost($Name); $Name = $this->getHost($Name);
if($Type == 'TXT' && substr($Value, 0, 1) != '"') $Value = '"'.$Value.'"'; if($Type == 'TXT' && substr($Value, 0, 1) != '"') $Value = '"'.$Value.'"';
$records = explode(',', $Value); $records = explode(',', $Value);
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => $records, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark]; $params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => $records, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
if($Type == 'MX')$param['weight'] = intval($MX); if($Type == 'MX') $params['records'][0] = intval($MX) . ' ' . $Value;
if($Weight > 0) $params['weight'] = intval($Weight);
$data = $this->send_reuqest('POST', '/v2.1/zones/'.$this->domainid.'/recordsets', null, $params); $data = $this->send_reuqest('POST', '/v2.1/zones/'.$this->domainid.'/recordsets', null, $params);
return is_array($data) ? $data['id'] : false; return is_array($data) ? $data['id'] : false;
} }
//修改解析记录 //修改解析记录
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$Name = $this->getHost($Name); $Name = $this->getHost($Name);
if($Type == 'TXT' && substr($Value, 0, 1) != '"') $Value = '"'.$Value.'"'; if($Type == 'TXT' && substr($Value, 0, 1) != '"') $Value = '"'.$Value.'"';
$records = explode(',', $Value); $records = explode(',', $Value);
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => $records, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark]; $params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => $records, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
if($Type == 'MX')$param['weight'] = intval($MX); if($Type == 'MX') $params['records'][0] = intval($MX) . ' ' . $Value;
if($Weight > 0) $params['weight'] = intval($Weight);
$data = $this->send_reuqest('PUT', '/v2.1/zones/'.$this->domainid.'/recordsets/'.$RecordId, null, $params); $data = $this->send_reuqest('PUT', '/v2.1/zones/'.$this->domainid.'/recordsets/'.$RecordId, null, $params);
return is_array($data); return is_array($data);
} }

View File

@ -73,6 +73,7 @@ class huoshan implements DnsInterface {
if($data){ if($data){
$list = []; $list = [];
foreach($data['Records'] as $row){ foreach($data['Records'] as $row){
if($row['Type'] == 'MX') list($row['MX'], $row['Value']) = explode(' ', $row['Value']);
$list[] = [ $list[] = [
'RecordId' => $row['RecordID'], 'RecordId' => $row['RecordID'],
'Domain' => $this->domain, 'Domain' => $this->domain,
@ -81,7 +82,7 @@ class huoshan implements DnsInterface {
'Value' => $row['Value'], 'Value' => $row['Value'],
'Line' => $row['Line'], 'Line' => $row['Line'],
'TTL' => $row['TTL'], 'TTL' => $row['TTL'],
'MX' => $row['Weight'], 'MX' => isset($row['MX']) ? $row['MX'] : null,
'Status' => $row['Enable'] ? '1' : '0', 'Status' => $row['Enable'] ? '1' : '0',
'Weight' => $row['Weight'], 'Weight' => $row['Weight'],
'Remark' => $row['Remark'], 'Remark' => $row['Remark'],
@ -103,6 +104,7 @@ class huoshan implements DnsInterface {
$data = $this->send_reuqest('GET', 'QueryRecord', ['RecordID' => $RecordId]); $data = $this->send_reuqest('GET', 'QueryRecord', ['RecordID' => $RecordId]);
if($data){ if($data){
if($data['name'] == $data['zone_name']) $data['name'] = '@'; if($data['name'] == $data['zone_name']) $data['name'] = '@';
if($data['Type'] == 'MX') list($data['MX'], $data['Value']) = explode(' ', $data['Value']);
return [ return [
'RecordId' => $data['RecordID'], 'RecordId' => $data['RecordID'],
'Domain' => $this->domain, 'Domain' => $this->domain,
@ -111,7 +113,7 @@ class huoshan implements DnsInterface {
'Value' => $data['Value'], 'Value' => $data['Value'],
'Line' => $data['Line'], 'Line' => $data['Line'],
'TTL' => $data['TTL'], 'TTL' => $data['TTL'],
'MX' => $data['Weight'], 'MX' => isset($data['MX']) ? $data['MX'] : null,
'Status' => $data['Enable'] ? '1' : '0', 'Status' => $data['Enable'] ? '1' : '0',
'Weight' => $data['Weight'], 'Weight' => $data['Weight'],
'Remark' => $data['Remark'], 'Remark' => $data['Remark'],
@ -122,17 +124,19 @@ class huoshan implements DnsInterface {
} }
//添加解析记录 //添加解析记录
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$params = ['ZID' => intval($this->domainid), 'Host' => $Name, 'Type' => $this->convertType($Type), 'Value' => $Value, 'Line'=>$Line, 'TTL' => intval($TTL), 'Remark' => $Remark]; $params = ['ZID' => intval($this->domainid), 'Host' => $Name, 'Type' => $this->convertType($Type), 'Value' => $Value, 'Line'=>$Line, 'TTL' => intval($TTL), 'Remark' => $Remark];
if($Type == 'MX')$param['Weight'] = intval($MX); if($Type == 'MX') $params['Value'] = intval($MX) . ' ' . $Value;
if($Weight > 0) $params['Weight'] = $Weight;
$data = $this->send_reuqest('POST', 'CreateRecord', $params); $data = $this->send_reuqest('POST', 'CreateRecord', $params);
return is_array($data) ? $data['RecordID'] : false; return is_array($data) ? $data['RecordID'] : false;
} }
//修改解析记录 //修改解析记录
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$params = ['RecordID' => $RecordId, 'Host' => $Name, 'Type' => $this->convertType($Type), 'Value' => $Value, 'Line'=>$Line, 'TTL' => intval($TTL), 'Remark' => $Remark]; $params = ['RecordID' => $RecordId, 'Host' => $Name, 'Type' => $this->convertType($Type), 'Value' => $Value, 'Line'=>$Line, 'TTL' => intval($TTL), 'Remark' => $Remark];
if($Type == 'MX')$param['Weight'] = intval($MX); if($Type == 'MX') $params['Value'] = intval($MX) . ' ' . $Value;
if($Weight > 0) $params['Weight'] = $Weight;
$data = $this->send_reuqest('POST', 'UpdateRecord', $params); $data = $this->send_reuqest('POST', 'UpdateRecord', $params);
return is_array($data); return is_array($data);
} }

View File

@ -91,14 +91,14 @@ class west implements DnsInterface {
} }
//添加解析记录 //添加解析记录
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$param = ['act' => 'adddnsrecord', 'domain' => $this->domain, 'host' => $Name, 'type' => $this->convertType($Type), 'value' => $Value, 'level' => $MX, 'ttl' => intval($TTL), 'line' => $Line]; $param = ['act' => 'adddnsrecord', 'domain' => $this->domain, 'host' => $Name, 'type' => $this->convertType($Type), 'value' => $Value, 'level' => $MX, 'ttl' => intval($TTL), 'line' => $Line];
$data = $this->execute('/domain/', $param); $data = $this->execute('/domain/', $param);
return is_array($data) ? $data['id'] : false; return is_array($data) ? $data['id'] : false;
} }
//修改解析记录 //修改解析记录
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
$param = ['act' => 'moddnsrecord', 'domain' => $this->domain, 'id' => $RecordId, 'type' => $this->convertType($Type), 'value' => $Value, 'level' => $MX, 'ttl' => intval($TTL), 'line' => $Line]; $param = ['act' => 'moddnsrecord', 'domain' => $this->domain, 'id' => $RecordId, 'type' => $this->convertType($Type), 'value' => $Value, 'level' => $MX, 'ttl' => intval($TTL), 'line' => $Line];
$data = $this->execute('/domain/', $param); $data = $this->execute('/domain/', $param);
return is_array($data); return is_array($data);

View File

@ -63,6 +63,12 @@ td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:360px;
<input type="text" class="form-control" name="ttl" value="600" placeholder="指解析结果在DNS服务器中的缓存时间" required min="{$minTTL}"> <input type="text" class="form-control" name="ttl" value="600" placeholder="指解析结果在DNS服务器中的缓存时间" required min="{$minTTL}">
</div> </div>
</div> </div>
{if $dnsconfig.weight}<div class="form-group" style="display:none" id="weight">
<label class="col-sm-3 control-label no-padding-right">权重</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="weight" value="" placeholder="留空则不使用权重">
</div>
</div>{/if}
{if $dnsconfig.remark == 2}<div class="form-group"> {if $dnsconfig.remark == 2}<div class="form-group">
<label class="col-sm-3 control-label no-padding-right">备注</label> <label class="col-sm-3 control-label no-padding-right">备注</label>
<div class="col-sm-9"> <div class="col-sm-9">
@ -231,6 +237,7 @@ var recordLine = {$recordLine|json_encode|raw};
var dnsconfig = {$dnsconfig|json_encode|raw}; var dnsconfig = {$dnsconfig|json_encode|raw};
var defaultLine = recordLine[0].id; var defaultLine = recordLine[0].id;
var sidePagination = dnsconfig.type == 'baidu' ? 'client' : 'server'; var sidePagination = dnsconfig.type == 'baidu' ? 'client' : 'server';
var showWeight = dnsconfig.weight;
$(document).ready(function(){ $(document).ready(function(){
updateToolbar(); updateToolbar();
let defaultPageSize = getCookie('record_pagesize') ? getCookie('record_pagesize') : 15; let defaultPageSize = getCookie('record_pagesize') ? getCookie('record_pagesize') : 15;
@ -283,6 +290,11 @@ $(document).ready(function(){
field: 'TTL', field: 'TTL',
title: 'TTL' title: 'TTL'
}, },
{
field: 'Weight',
visible: showWeight,
title: '权重'
},
{ {
field: 'Remark', field: 'Remark',
visible: dnsconfig.remark > 0, visible: dnsconfig.remark > 0,
@ -333,13 +345,23 @@ $(document).ready(function(){
}, },
}); });
$("select[name=type]").change(function(){ var typeChange = function(){
if($(this).val() == 'MX'){ if($(this).val() == 'MX'){
$("#mx_type").show(); $("#mx_type").show();
}else{ }else{
$("#mx_type").hide(); $("#mx_type").hide();
} }
}); if(showWeight){
if($(this).val() == 'A' || $(this).val() == 'CNAME' || $(this).val() == 'AAAA'){
$("#weight").show();
}else{
$("#weight").hide();
}
}
};
$("#form-store select[name=type]").change(typeChange);
$("#form-store2 select[name=type]").change(typeChange);
$("#form-store").bootstrapValidator(); $("#form-store").bootstrapValidator();
$("#form-store2").bootstrapValidator(); $("#form-store2").bootstrapValidator();
@ -387,10 +409,11 @@ function addframe(){
$("#form-store input[name=recordid]").val(''); $("#form-store input[name=recordid]").val('');
$("#form-store input[name=name]").val(''); $("#form-store input[name=name]").val('');
$("#form-store select[name=type]").val('A'); $("#form-store select[name=type]").val('A');
$("select[name=type]").change(); $("#form-store select[name=type]").change();
initLine(); initLine();
$("#form-store input[name=value]").val(''); $("#form-store input[name=value]").val('');
$("#form-store input[name=ttl]").val('600'); $("#form-store input[name=ttl]").val('600');
$("#form-store input[name=weight]").val('');
$("#form-store input[name=remark]").val(''); $("#form-store input[name=remark]").val('');
$("#form-store").data("bootstrapValidator").resetForm(); $("#form-store").data("bootstrapValidator").resetForm();
} }
@ -402,7 +425,7 @@ function editframe(recordid){
$("#form-store input[name=recordid]").val(recordid); $("#form-store input[name=recordid]").val(recordid);
$("#form-store input[name=name]").val(row.Name); $("#form-store input[name=name]").val(row.Name);
$("#form-store select[name=type]").val(row.Type); $("#form-store select[name=type]").val(row.Type);
$("select[name=type]").change(); $("#form-store select[name=type]").change();
initLine(); initLine();
if($('#form-store select[name=line] option[value="'+row.Line+'"]').length > 0){ if($('#form-store select[name=line] option[value="'+row.Line+'"]').length > 0){
$("#form-store select[name=line]").val(row.Line); $("#form-store select[name=line]").val(row.Line);
@ -413,6 +436,7 @@ function editframe(recordid){
$("#form-store input[name=value]").val(row.Value); $("#form-store input[name=value]").val(row.Value);
$("#form-store input[name=mx]").val(row.MX); $("#form-store input[name=mx]").val(row.MX);
$("#form-store input[name=ttl]").val(row.TTL); $("#form-store input[name=ttl]").val(row.TTL);
$("#form-store input[name=weight]").val(row.Weight);
$("#form-store input[name=remark]").val(row.Remark); $("#form-store input[name=remark]").val(row.Remark);
$("#form-store").data("bootstrapValidator").resetForm(); $("#form-store").data("bootstrapValidator").resetForm();
} }
@ -533,14 +557,14 @@ function operation(action){
if(action == 'edit'){ if(action == 'edit'){
var records = []; var records = [];
$.each(rows, function(index, item){ $.each(rows, function(index, item){
records.push({recordid:item.RecordId, name:item.Name, line:item.Line, mx:item.MX, ttl:item.TTL, remark:item.Remark}); records.push({recordid:item.RecordId, name:item.Name, line:item.Line, mx:item.MX, ttl:item.TTL, weight:item.Weight, remark:item.Remark});
}) })
batch_edit(records) batch_edit(records)
return; return;
}else if(action == 'editline'){ }else if(action == 'editline'){
var records = []; var records = [];
$.each(rows, function(index, item){ $.each(rows, function(index, item){
records.push({recordid:item.RecordId, name:item.Name, type:item.Type, value:item.Value, mx:item.MX, ttl:item.TTL, remark:item.Remark}); records.push({recordid:item.RecordId, name:item.Name, type:item.Type, value:item.Value, mx:item.MX, ttl:item.TTL, weight:item.Weight, remark:item.Remark});
}) })
batch_edit_line(records) batch_edit_line(records)
return; return;
@ -589,7 +613,7 @@ function batch_edit(records){
$("#form-store2 input[name=recordid]").val(row.RecordId); $("#form-store2 input[name=recordid]").val(row.RecordId);
$("#form-store2 input[name=name]").val(row.Name); $("#form-store2 input[name=name]").val(row.Name);
$("#form-store2 select[name=type]").val(row.Type); $("#form-store2 select[name=type]").val(row.Type);
$("select[name=type]").change(); $("#form-store2 select[name=type]").change();
$("#form-store2 input[name=value]").val(row.Value); $("#form-store2 input[name=value]").val(row.Value);
$("#form-store2").data("bootstrapValidator").resetForm(); $("#form-store2").data("bootstrapValidator").resetForm();
} }

View File

@ -13,7 +13,7 @@
<div class="panel panel-warning"> <div class="panel panel-warning">
<div class="panel-heading"><h3 class="panel-title">使用说明</h3></div> <div class="panel-heading"><h3 class="panel-title">使用说明</h3></div>
<div class="panel-body"> <div class="panel-body">
<p><li>数据接口:<a href="https://www.182682.xyz/" target="_blank" rel="noreferrer">182682.xyz</a> 数据接口支持CloudFlare、CloudFront、Gcore<a href="https://stock.hostmonit.com/" target="_blank" rel="noreferrer">HostMonit</a> 只支持CloudFlare<a href="https://345673.xyz/" target="_blank" rel="noreferrer">345673.xyz</a> 只支持CloudFlare。</li></p> <p><li>数据接口:<a href="https://www.wetest.vip/" target="_blank" rel="noreferrer">wetest.vip</a> 数据接口支持CloudFlare、CloudFront、Gcore<a href="https://stock.hostmonit.com/" target="_blank" rel="noreferrer">HostMonit</a> 只支持CloudFlare。</li></p>
<p><li>接口密钥默认o1zrmHAF为免费KEY可永久免费使用。</li></p> <p><li>接口密钥默认o1zrmHAF为免费KEY可永久免费使用。</li></p>
<p><li>计划任务将以下命令添加到计划任务周期设置为15分钟以上</li></p> <p><li>计划任务将以下命令添加到计划任务周期设置为15分钟以上</li></p>
<p><code>cd {:app()->getRootPath()} && php think opiptask</code></p> <p><code>cd {:app()->getRootPath()} && php think opiptask</code></p>
@ -27,7 +27,7 @@
<form onsubmit="return saveSetting(this)" method="post" class="form-horizontal" role="form"> <form onsubmit="return saveSetting(this)" method="post" class="form-horizontal" role="form">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">数据接口</label> <label class="col-sm-3 control-label">数据接口</label>
<div class="col-sm-9"><select class="form-control" name="optimize_ip_api" default="{:config_get('optimize_ip_api')}"><option value="0">182682.xyz</option><option value="1">HostMonit</option><option value="2">345673.xyz</option></select></div> <div class="col-sm-9"><select class="form-control" name="optimize_ip_api" default="{:config_get('optimize_ip_api')}"><option value="0">wetest.vip</option><option value="1">HostMonit</option></select></div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">接口密钥</label> <label class="col-sm-3 control-label">接口密钥</label>

View File

@ -31,7 +31,7 @@ return [
'show_error_msg' => true, 'show_error_msg' => true,
'exception_tmpl' => \think\facade\App::getAppPath() . 'view/exception.tpl', 'exception_tmpl' => \think\facade\App::getAppPath() . 'view/exception.tpl',
'version' => '1015', 'version' => '1017',
'dbversion' => '1011' 'dbversion' => '1011'
]; ];