forked from greatagent/ga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-last-kown-good.inc.php
66 lines (61 loc) · 2.43 KB
/
get-last-kown-good.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
# greatagent-ga - Software suite for breakthrough GFW
# greatagent-ga - Software suite for breakthrough GFW
#
# get-last-kown-good.inc.php - Grabbing last-known-good file from SmartHosts and Huhamhire-Hosts
echo "\r\n";
echo "Grabbing last-known-good file from SmartHosts and Huhamhire-Hosts:\r\n";
/* FUNCTION */
require_once("gservers-common.inc.php");
echo "Grabbing SmartHosts hosts:\r\n";
$googleip1=array();
$host=request("GET /svn/trunk/hosts HTTP/1.1\r\nHost:{host}\r\nConnection: close\r\n\r\n","smarthosts.googlecode.com");
$host=explode("\n",str_replace("\r\n","\n",$host));
foreach($host as $hostkey=>$hoststring){
//talk.google.com is special case. We cannot use it as G-Server
if(preg_match('/(.*?)\ttalk\.google\.com$/',$hoststring,$hostmatch)){
}elseif(preg_match('/(.*?)\t.*?\.google\.com$/',$hoststring,$hostmatch)){
if(filter_var($hostmatch[1],FILTER_VALIDATE_IP)){
$googleip1[]=$hostmatch[1];
}
}elseif(preg_match('/(.*?)\t.*?\.google\.com\.hk$/',$hoststring,$hostmatch)){
if(filter_var($hostmatch[1],FILTER_VALIDATE_IP)){
$googleip2[]=$hostmatch[1];
}
}
}
$googleip1=array_unique($googleip1);
echo "SmartHosts=".implode(",",$googleip1)."\r\n";
echo "Grabbing Huhamhire-Hosts hosts:\r\n";
$googleip2=array();
$host=request("GET /git-history/HostsUtl-Hostsdata/ipv4_mods/google(cn).hosts HTTP/1.1\r\nHost:{host}\r\nConnection: close\r\n\r\n","huhamhire-hosts.googlecode.com");
$host=str_replace(" "," ",$host);
$host=str_replace("8.8.8.8","",$host);
$host=str_replace("8.8.4.4","",$host);
$host=explode("\n",str_replace("\r\n","\n",$host));
foreach($host as $hostkey=>$hoststring){
//talk.google.com is special case. We cannot use it as G-Server
if(preg_match('/(.*?)\ttalk\.google\.com$/',$hoststring,$hostmatch)){
}elseif(preg_match('/(.*?)\t.*?\.google\.com$/',$hoststring,$hostmatch)){
if(filter_var($hostmatch[1],FILTER_VALIDATE_IP)){
$googleip2[]=$hostmatch[1];
}
}elseif(preg_match('/(.*?)\t.*?\.google\.com\.hk$/',$hoststring,$hostmatch)){
if(filter_var($hostmatch[1],FILTER_VALIDATE_IP)){
$googleip2[]=$hostmatch[1];
}
}
}
$googleip2=array_unique($googleip2);
echo "Huhamhire-Hosts=".implode(",",$googleip2)."\r\n";
$googleip = $googleip1 +$googleip2;
if(count($googleip)){
$googleip=array_unique($googleip);
@unlink("data/last-known-good");
file_put_contents("data/last-known-good",implode("\r\n",$googleip));
echo " last-known-good=".implode(",",$googleip)."\r\n";
}else{
###
}
echo "\r\n";
?>