分类功能
This commit is contained in:
parent
e634be9344
commit
eccef4f40b
@ -6,7 +6,30 @@ 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(){
|
||||||
|
if(!isset($this->classify)){
|
||||||
|
$this->classify();
|
||||||
|
}
|
||||||
|
return $this->classify;
|
||||||
|
}
|
||||||
|
public function classify(){
|
||||||
|
if(!isset($this->ping)){
|
||||||
|
$this->ping();
|
||||||
|
}
|
||||||
|
$classify = [];
|
||||||
|
foreach($this->ping as $id=>$node){
|
||||||
|
$isp = $node['nodeinfo']->nodename;
|
||||||
|
$isp=explode(' ',$isp);
|
||||||
|
if(in_array(end($isp),['电信','联通','移动','BGP'])){
|
||||||
|
$isp = '中国'.end($isp);
|
||||||
|
}else{
|
||||||
|
$isp = $isp[0];
|
||||||
|
}
|
||||||
|
array_push($classify[$isp],$node);
|
||||||
|
}
|
||||||
|
$this->classify=$classify;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
public function node()
|
public function node()
|
||||||
{
|
{
|
||||||
$nodeinfo = $this->callWebSocet('{"msg":"getnodelist"}');
|
$nodeinfo = $this->callWebSocet('{"msg":"getnodelist"}');
|
||||||
|
Loading…
Reference in New Issue
Block a user