From 7103134fa18693a785b17f430fe73de484d2d54c Mon Sep 17 00:00:00 2001 From: sparc Date: Wed, 27 Jul 2005 13:46:57 +0000 Subject: [PATCH] some improvments on AS queries --- Changes.md | 1 + Handlers.md | 9 +++------ src/whois.ip.arin.php | 6 +++++- src/whois.ip.php | 29 +++++++++++++---------------- test.txt | 3 +++ 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Changes.md b/Changes.md index a17749d..00359ba 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,7 @@ - added handler.template.php - disclaimer updated - updated README file + - some improvments for AS queries 2005/07/26 David Saez - added handler for za.org & za.net, thanx to diff --git a/Handlers.md b/Handlers.md index 304453c..11b4a1b 100644 --- a/Handlers.md +++ b/Handlers.md @@ -57,15 +57,12 @@ the following subkeys: network ------- - Only when dealing with ip addresses. Could contain the + Only when dealing with ip addresses or AS. Could contain the following subkeys: - name -> network name + name -> network/AS name inetnum -> network ip address range desc -> network description - host_ip -> ip address that was tested - host_name> host name obtained doing reverse dns - lookup on host_ip mnt-by -> who provided that network mnt-lower> who provided that network nserver -> name servers in listed order that @@ -74,7 +71,7 @@ the following subkeys: remarks -> remarks provided by the registry changed -> date of last change created -> creation date - handle -> domain handle + handle -> network/AS handle source -> who gives this information owner,admin,tech,zone,billing,abuse diff --git a/src/whois.ip.arin.php b/src/whois.ip.arin.php index dec742b..87b6188 100644 --- a/src/whois.ip.arin.php +++ b/src/whois.ip.arin.php @@ -50,6 +50,10 @@ function parse ($data_str) "network.desc." => "Comment:", "network.created" => "RegDate:", "network.changed" => "Updated:", + 'network.handle' => 'ASHandle:', + 'network.name' => 'ASName:', + 'network.handle' => 'NetHandle:', + 'network.name' => 'NetName:', "tech.handle" => "TechHandle:", "tech.name" => "TechName:", "tech.phone" => "TechPhone:", @@ -60,7 +64,7 @@ function parse ($data_str) "abuse.email" => "OrgAbuseEmail:" ); - return generic_parser_b($data_str,$items); + return generic_parser_b($data_str,$items,'ymd',false); } } diff --git a/src/whois.ip.php b/src/whois.ip.php index 84900c7..4f8eb4e 100644 --- a/src/whois.ip.php +++ b/src/whois.ip.php @@ -193,38 +193,35 @@ if (!isset($result['regrinfo']['network']['inetnum']) && $result['regrinfo']['network']['inetnum']=$this->cidr_conv($result['regrinfo']['network']['cdir']); } -$result["regrinfo"]["network"]["host_ip"]=$this->Query["host_ip"]; -$result["regrinfo"]["network"]["host_name"]=$this->Query["host_name"]; - return $result; } //----------------------------------------------------------------- function cidr_conv($net) -{ -$start=strtok($net,'/'); -$n=3-substr_count($net, '.'); +{ +$start=strtok($net,'/'); +$n=3-substr_count($net, '.'); if ($n>0) { for ($i=$n;$i>0;$i--) $start.='.0'; } - -$bits1=str_pad(decbin(ip2long($start)),32,'0','STR_PAD_LEFT'); -$net=pow(2,(32-substr(strstr($net,'/'),1)))-1; + +$bits1=str_pad(decbin(ip2long($start)),32,'0','STR_PAD_LEFT'); +$net=pow(2,(32-substr(strstr($net,'/'),1)))-1; $bits2=str_pad(decbin($net),32,'0','STR_PAD_LEFT'); $final=''; - + for ($i=0;$i<32;$i++) - { - if ($bits1[$i]==$bits2[$i]) $final.=$bits1[$i]; - if ($bits1[$i]==1 and $bits2[$i]==0) $final.=$bits1[$i]; - if ($bits1[$i]==0 and $bits2[$i]==1) $final.=$bits2[$i]; + { + if ($bits1[$i]==$bits2[$i]) $final.=$bits1[$i]; + if ($bits1[$i]==1 and $bits2[$i]==0) $final.=$bits1[$i]; + if ($bits1[$i]==0 and $bits2[$i]==1) $final.=$bits2[$i]; } - -return $start." - ".long2ip(bindec($final)); + +return $start." - ".long2ip(bindec($final)); } } diff --git a/test.txt b/test.txt index cbb9cab..26d28ca 100644 --- a/test.txt +++ b/test.txt @@ -65,3 +65,6 @@ krnic 210.178.148.129 lacnic 200.44.33.31 ripe 62.97.102.115 +// ASN + +arin AS220