how to detect domain in chinese viewer status

how to detect domain in chinese viewer status
不能写G F W 相关的 怕域名被墙

This code use for check domain in china network status
1. must be upload china servers or web hosting
2. network request must from china send

Test images
checkdomains

< ?php /* view-source:http://1.gfwcheckapi.sinaapp.com/?url=https://www.baidu.com */ //sae_xhprof_start() $url = isset($_GET['url']) ? $_GET['url'] : die('miss url'); $ch = curl_init(); if (!$ch) { die("Couldn't initialize a cURL handle"); } curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $data = curl_exec($ch); $domain = parse_url($url, PHP_URL_HOST); $ip = gethostbyname($domain); //if(!curl_errno($ch)) { $info = curl_getinfo($ch); $array = array( "status" => "OK",
"domain" => $domain,
"ipaddress" => $ip,
"url" => $info['url'],
"status_code" => $info['http_code'],
"header_size" => $info['header_size'],
"request_size" => $info['request_size'],
"total_time" => $info['total_time'],
"namelookup_time" => $info['namelookup_time'],
"connect_time" => $info['connect_time'],
"pretransfer_time" => $info['pretransfer_time'],
"size_upload" => $info['size_upload'],
"size_download" => $info['size_download'],
"speed_download" => $info['speed_download'],
"speed_upload" => $info['speed_upload'],
"download_content_length" => $info['download_content_length'],
"upload_content_length" => $info['upload_content_length'],
"starttransfer_time" => $info['starttransfer_time'],
"redirect_time" => $info['redirect_time'],
"redirect_url" => $info['redirect_url']
);
echo json_encode($array);
//echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];

/*
} else {
echo json_encode(array("status" => "ERROR"));
}
*/

curl_close($ch);
//sae_xhprof_end()
?>

This testing OK
http://1.gfwcheckapi.sinaapp.com/?url=https://www.baidu.com

Response

{"status":"OK","domain":"www.baidu.com","ipaddress":"220.181.111.188","url":"http:\/\/www.baidu.com","status_code":200,"header_size":1042,"request_size":359,"total_time":0.011249,"namelookup_time":2.7e-5,"connect_time":0.000653,"pretransfer_time":0.000655,"size_upload":0,"size_download":97298,"speed_download":8649479,"speed_upload":0,"download_content_length":-1,"upload_content_length":0,"starttransfer_time":0.008031,"redirect_time":0,"redirect_url":""}

The status is OK and nslookup ipaddress 220.181.111.188
and other curl_getinfo value

if test facebook.com this domain has band in chinese network
http://1.gfwcheckapi.sinaapp.com/?url=https://www.facebook.com
so if your check this domain, always 500
this return 500 error not facebook server down or network question
this china firewall has send fake response rest connection

so we test
just check response
if json it’s ok
if 500 this domain has ban in china network

note that this is only for testing purposes http://1.gfwcheckapi.sinaapp.com/
may be canceled at any time
if you need a lot of requests
you must purchase china VPS china host or china dedicated server for testing

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注