save
This commit is contained in:
parent
eccef4f40b
commit
66c393f34c
@ -6,12 +6,16 @@ use WebSocket\Client;
|
|||||||
class Detect
|
class Detect
|
||||||
{
|
{
|
||||||
var $dest='ws://172.83.153.167:2345';
|
var $dest='ws://172.83.153.167:2345';
|
||||||
public function getClassify(){
|
public function getClassify($type=null){
|
||||||
if(!isset($this->classify)){
|
if(!isset($this->classify)){
|
||||||
$this->classify();
|
$this->classify();
|
||||||
}
|
}
|
||||||
|
if($type){
|
||||||
|
return $this->classify[$type];
|
||||||
|
}else{
|
||||||
return $this->classify;
|
return $this->classify;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public function classify(){
|
public function classify(){
|
||||||
if(!isset($this->ping)){
|
if(!isset($this->ping)){
|
||||||
$this->ping();
|
$this->ping();
|
||||||
@ -19,12 +23,17 @@ class Detect
|
|||||||
$classify = [];
|
$classify = [];
|
||||||
foreach($this->ping as $id=>$node){
|
foreach($this->ping as $id=>$node){
|
||||||
$isp = $node['nodeinfo']->nodename;
|
$isp = $node['nodeinfo']->nodename;
|
||||||
$isp=explode(' ',$isp);
|
$isp = preg_replace('/\(.*?\)/', '', $isp);
|
||||||
|
|
||||||
|
$isp=explode('-',$isp);
|
||||||
if(in_array(end($isp),['电信','联通','移动','BGP'])){
|
if(in_array(end($isp),['电信','联通','移动','BGP'])){
|
||||||
$isp = '中国'.end($isp);
|
$isp = '中国'.end($isp);
|
||||||
}else{
|
}else{
|
||||||
$isp = $isp[0];
|
$isp = $isp[0];
|
||||||
}
|
}
|
||||||
|
if(!isset($classify[$isp])){
|
||||||
|
$classify[$isp]=[];
|
||||||
|
}
|
||||||
array_push($classify[$isp],$node);
|
array_push($classify[$isp],$node);
|
||||||
}
|
}
|
||||||
$this->classify=$classify;
|
$this->classify=$classify;
|
||||||
|
Loading…
Reference in New Issue
Block a user