mirror of
https://github.com/netcccyun/dnsmgr.git
synced 2024-11-16 03:32:28 +08:00
fix
This commit is contained in:
parent
8d653b872a
commit
8f257664ae
|
@ -16,10 +16,11 @@ class Dmonitor extends BaseController
|
|||
$switch_count = Db::name('dmlog')->where('date', '>=', date("Y-m-d H:i:s",strtotime("-1 days")))->count();
|
||||
$fail_count = Db::name('dmlog')->where('date', '>=', date("Y-m-d H:i:s",strtotime("-1 days")))->where('action', 1)->count();
|
||||
|
||||
$run_state = config_get('run_time', null, true) ? (time()-strtotime(config_get('run_time')) > 10 ? 0 : 1) : 0;
|
||||
$run_time = config_get('run_time', null, true);
|
||||
$run_state = $run_time ? (time()-strtotime($run_time) > 10 ? 0 : 1) : 0;
|
||||
View::assign('info', [
|
||||
'run_count' => config_get('run_count', null, true) ?? 0,
|
||||
'run_time' => config_get('run_time', null, true) ?? '无',
|
||||
'run_time' => $run_time ?? '无',
|
||||
'run_state' => $run_state,
|
||||
'run_error' => config_get('run_error', null, true),
|
||||
'switch_count' => $switch_count,
|
||||
|
@ -257,7 +258,8 @@ class Dmonitor extends BaseController
|
|||
|
||||
public function status()
|
||||
{
|
||||
$run_state = config_get('run_time', null, true) ? (time()-strtotime(config_get('run_time')) > 10 ? 0 : 1) : 0;
|
||||
$run_time = config_get('run_time', null, true);
|
||||
$run_state = $run_time ? (time()-strtotime($run_time) > 10 ? 0 : 1) : 0;
|
||||
return $run_state == 1 ? 'ok' : 'error';
|
||||
}
|
||||
}
|
|
@ -4,10 +4,20 @@ namespace app\lib;
|
|||
|
||||
class CheckUtils
|
||||
{
|
||||
public static function curl($url, $timeout)
|
||||
public static function curl($url, $timeout, $ip = null)
|
||||
{
|
||||
$status = true;
|
||||
$errmsg = null;
|
||||
$urlarr = parse_url($url);
|
||||
if (!empty($ip) && !filter_var($urlarr['host'], FILTER_VALIDATE_IP)) {
|
||||
if (!filter_var($ip, FILTER_VALIDATE_IP)) {
|
||||
$ip = gethostbyname($ip);
|
||||
}
|
||||
if (!empty($ip) && filter_var($ip, FILTER_VALIDATE_IP)) {
|
||||
$port = isset($urlarr['port']) ? $urlarr['port'] : ($urlarr['scheme'] == 'https' ? 443 : 80);
|
||||
$resolve = $urlarr['host'] . ':' . $port . ':' . $ip;
|
||||
}
|
||||
}
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
|
@ -20,6 +30,10 @@ class CheckUtils
|
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
if(!empty($resolve)){
|
||||
curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);
|
||||
curl_setopt($ch, CURLOPT_RESOLVE, [$resolve]);
|
||||
}
|
||||
curl_exec($ch);
|
||||
$errno = curl_errno($ch);
|
||||
if ($errno) {
|
||||
|
|
|
@ -28,7 +28,7 @@ class TaskRunner
|
|||
public function execute($row)
|
||||
{
|
||||
if($row['checktype'] == 2){
|
||||
$result = CheckUtils::curl($row['checkurl'], $row['timeout']);
|
||||
$result = CheckUtils::curl($row['checkurl'], $row['timeout'], $row['main_value']);
|
||||
}else if($row['checktype'] == 1){
|
||||
$result = CheckUtils::tcp($row['main_value'], $row['tcpport'], $row['timeout']);
|
||||
}else{
|
||||
|
|
|
@ -112,7 +112,8 @@ class huawei implements DnsInterface {
|
|||
//添加解析记录
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
$Name = $this->getHost($Name);
|
||||
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => [$Value], 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
|
||||
$records = explode(',', $Value);
|
||||
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => $records, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
|
||||
if($Type == 'MX')$param['weight'] = intval($MX);
|
||||
$data = $this->send_reuqest('POST', '/v2.1/zones/'.$this->domainid.'/recordsets', null, $params);
|
||||
return is_array($data) ? $data['id'] : false;
|
||||
|
@ -121,7 +122,8 @@ class huawei implements DnsInterface {
|
|||
//修改解析记录
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
$Name = $this->getHost($Name);
|
||||
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => [$Value], 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
|
||||
$records = explode(',', $Value);
|
||||
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => $records, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
|
||||
if($Type == 'MX')$param['weight'] = intval($MX);
|
||||
$data = $this->send_reuqest('PUT', '/v2.1/zones/'.$this->domainid.'/recordsets/'.$RecordId, null, $params);
|
||||
return is_array($data);
|
||||
|
|
|
@ -86,7 +86,7 @@ CREATE TABLE `dnsmgr_dmtask` (
|
|||
`backup_value` varchar(128) DEFAULT NULL,
|
||||
`checktype` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`checkurl` varchar(512) DEFAULT NULL,
|
||||
`tcpport` tinyint(5) DEFAULT NULL,
|
||||
`tcpport` int(5) DEFAULT NULL,
|
||||
`frequency` tinyint(5) NOT NULL,
|
||||
`cycle` tinyint(5) NOT NULL DEFAULT 3,
|
||||
`timeout` tinyint(5) NOT NULL DEFAULT 2,
|
||||
|
|
|
@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS `dnsmgr_dmtask` (
|
|||
`backup_value` varchar(128) DEFAULT NULL,
|
||||
`checktype` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`checkurl` varchar(512) DEFAULT NULL,
|
||||
`tcpport` tinyint(5) DEFAULT NULL,
|
||||
`tcpport` int(5) DEFAULT NULL,
|
||||
`frequency` tinyint(5) NOT NULL,
|
||||
`cycle` tinyint(5) NOT NULL DEFAULT 3,
|
||||
`timeout` tinyint(5) NOT NULL DEFAULT 2,
|
||||
|
|
Loading…
Reference in New Issue
Block a user