Compare commits

..

6 Commits
1.2 ... 1.2.1

Author SHA1 Message Date
net909
51538495b1 1.2.1 2024-04-22 23:09:09 +08:00
net909
8f257664ae fix 2024-04-22 23:08:21 +08:00
net909
8d653b872a fix 2024-04-20 21:36:11 +08:00
net909
7201476e9c fix 2024-04-20 10:22:22 +08:00
net909
3292f8e9ce 修复运行状态显示 2024-04-19 19:44:52 +08:00
net909
497aabb8e6 readme 2024-04-18 19:38:47 +08:00
11 changed files with 51 additions and 20 deletions

View File

@@ -6,6 +6,7 @@
- 腾讯云
- 华为云
- 西部数码
- DNSLA
- CloudFlare
本系统支持多用户每个用户可分配不同的域名解析权限支持API接口支持获取域名独立DNS控制面板登录链接方便各种IDC系统对接。

View File

@@ -5,6 +5,7 @@ use app\BaseController;
use Exception;
use think\facade\Db;
use think\facade\View;
use think\facade\Cache;
use app\lib\DnsHelper;
class Dmonitor extends BaseController
@@ -15,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') ? (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,
@@ -222,6 +224,7 @@ class Dmonitor extends BaseController
continue;
}
config_set($key, $value);
Cache::delete('configs');
}
return json(['code'=>0, 'msg'=>'succ']);
}
@@ -255,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';
}
}

View File

@@ -72,7 +72,7 @@ class Index extends BaseController
cookie('admin_skin', null);
}
config_set('admin_skin', $skin);
Cache::clear();
Cache::delete('configs');
}else{
cookie('admin_skin', $skin);
}

View File

@@ -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) {

View File

@@ -68,7 +68,7 @@ class DnsHelper
'sk' => 'API密钥'
],
'remark' => 2,
'status' => true,
'status' => false,
'redirect' => false,
'log' => false,
],

View File

@@ -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{

View File

@@ -54,6 +54,7 @@ class huawei implements DnsInterface {
$query = ['type' => $Type, 'line_id' => $Line, 'name' => $KeyWord, 'status' => $Status, 'offset' => $offset, 'limit' => $PageSize];
if(!isNullOrEmpty(($SubDomain))){
$query['name'] = $SubDomain;
$query['search_mode'] = 'equal';
}
$data = $this->send_reuqest('GET', '/v2.1/zones/'.$this->domainid.'/recordsets', $query);
if($data){
@@ -82,7 +83,7 @@ class huawei implements DnsInterface {
//获取子域名解析记录列表
public function getSubDomainRecords($SubDomain, $PageNumber=1, $PageSize=20, $Type = null, $Line = null){
if($SubDomain == '')$SubDomain='@';
$SubDomain = $this->getHost($SubDomain);
return $this->getDomainRecords($PageNumber, $PageSize, null, $SubDomain, $Type, $Line);
}
@@ -110,10 +111,9 @@ class huawei implements DnsInterface {
//添加解析记录
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
if($Name == '@') $Name = '';
else $Name .= '.';
$Name .= $this->domain . '.';
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => [$Value], 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
$Name = $this->getHost($Name);
$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,10 +121,9 @@ class huawei implements DnsInterface {
//修改解析记录
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
if($Name == '@') $Name = '';
else $Name .= '.';
$Name .= $this->domain . '.';
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => [$Value], 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
$Name = $this->getHost($Name);
$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);
@@ -199,6 +198,13 @@ class huawei implements DnsInterface {
return $type;
}
private function getHost($Name){
if($Name == '@') $Name = '';
else $Name .= '.';
$Name .= $this->domain . '.';
return $Name;
}
private function send_reuqest($method, $path, $query = null, $params = null){
if(!empty($query)){
$query = array_filter($query, function($a){ return $a!==null;});
@@ -324,6 +330,9 @@ class huawei implements DnsInterface {
if(isset($arr['error_msg'])){
$this->setError($arr['error_msg']);
return false;
}elseif(isset($arr['message'])){
$this->setError($arr['message']);
return false;
}else{
return $arr;
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -224,7 +224,10 @@ new Vue({
layer.close(ii);
if(data.code == 0){
layer.alert(data.msg, {icon: 1}, function(){
window.history.back();
if(document.referrer.indexOf('task?') > 0)
window.location.href = document.referrer;
else
window.location.href = '/dmonitor/task';
});
}else{
layer.alert(data.msg, {icon: 2});

View File

@@ -30,7 +30,7 @@ return [
// 显示错误信息
'show_error_msg' => false,
'version' => '1003',
'version' => '1004',
'dbversion' => '1003'
];