作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !2420
@@ -822,7 +822,7 @@ if(!function_exists('curlGet')){ @@ -822,7 +822,7 @@ if(!function_exists('curlGet')){
822 */ 822 */
823 function curlGet($url){ 823 function curlGet($url){
824 $ch1 = curl_init(); 824 $ch1 = curl_init();
825 - $timeout = 0; 825 + $timeout = 60;
826 curl_setopt($ch1, CURLOPT_URL, $url); 826 curl_setopt($ch1, CURLOPT_URL, $url);
827 curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); 827 curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
828 curl_setopt($ch1, CURLOPT_ENCODING, ''); 828 curl_setopt($ch1, CURLOPT_ENCODING, '');
@@ -1077,17 +1077,31 @@ if (!function_exists('check_domain_record')) { @@ -1077,17 +1077,31 @@ if (!function_exists('check_domain_record')) {
1077 function check_domain_record($domain, $server_info) 1077 function check_domain_record($domain, $server_info)
1078 { 1078 {
1079 try { 1079 try {
  1080 + $is_record = false;
  1081 +
  1082 + //获取域名解析记录
1080 $records = dns_get_record($domain,DNS_A); 1083 $records = dns_get_record($domain,DNS_A);
1081 - if(count($records) != 1){  
1082 - return false; 1084 + if(count($records) == 1 && ($records[0]['host'] == $server_info['domain'] || $records[0]['ip'] == $server_info['ip'])){
  1085 + $is_record = true;
1083 } 1086 }
1084 1087
1085 - $record = $records[0];  
1086 - if($record['host'] == $server_info['domain'] || $record['ip'] == $server_info['ip']){  
1087 - return $domain;  
1088 - }else{  
1089 - return false; 1088 + if(!$is_record){
  1089 + //解析不正确,再判断是否开启cnd
  1090 + $cnd = curlGet('http://sitebak.globalso.com/get_records?domain=' . $domain);
  1091 + if (isset($cnd['data']) && $cnd['data']) {
  1092 + foreach ($cnd['data'] as $vc) {
  1093 + if ($vc['type'] == 'A' && $vc['content'] == $server_info['ip']) {
  1094 + $is_record = true;
  1095 + break;
  1096 + }elseif ($vc['type'] == 'CNAME' && $vc['content'] == $server_info['domain']){
  1097 + $is_record = true;
  1098 + break;
  1099 + }
  1100 + }
1090 } 1101 }
  1102 + }
  1103 +
  1104 + return $is_record;
1091 }catch (\Exception $e){ 1105 }catch (\Exception $e){
1092 errorLog('dns_get_record',['domain'=>$domain],$e); 1106 errorLog('dns_get_record',['domain'=>$domain],$e);
1093 return false; 1107 return false;
@@ -1373,3 +1387,4 @@ function analysisRoute($pathInfo) @@ -1373,3 +1387,4 @@ function analysisRoute($pathInfo)
1373 } 1387 }
1374 return $router; 1388 return $router;
1375 } 1389 }
  1390 +