From eccef4f40b80a9086a244956dd8571b0c3c97441 Mon Sep 17 00:00:00 2001 From: Enoch Date: Sun, 10 Nov 2024 22:26:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Detect.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Detect.php b/src/Detect.php index 68e1f15..bec9db6 100644 --- a/src/Detect.php +++ b/src/Detect.php @@ -6,7 +6,30 @@ use WebSocket\Client; class Detect { 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() { $nodeinfo = $this->callWebSocet('{"msg":"getnodelist"}');