コード例 #1
0
ファイル: Whois.php プロジェクト: BGPView/Backend-API
 public function __construct($input, $cidr = null, $rir = null, $useRaw = false)
 {
     $this->esClient = new ClientBuilder();
     $this->ipUtils = new IpUtils();
     $this->whoisUrl = config('app.whois_query_url');
     // Check if we supply direct raw whois details
     if ($useRaw === true && is_null($rir) !== true) {
         $this->rir = $rir;
         $this->rawData = $input;
         $this->rawLines = explode("\n", $input);
         return;
     }
     $this->input = $this->ipUtils->normalizeInput(trim($input), $showAS = true);
     $allocation = $this->ipUtils->getAllocationEntry($this->input, $cidr);
     if (is_null($allocation) === true || empty($allocation) === true) {
         $assignment = $this->ipUtils->getIanaAssignmentEntry($this->input);
         if (is_null($assignment) === true || empty($assignment) === true) {
             $this->rawData = null;
             $this->rawLines = [];
             return;
         } else {
             $this->rir = Rir::where('whois_server', $assignment->whois_server)->first();
         }
     } else {
         $this->rir = Rir::find($allocation->rir_id);
     }
     if (empty($this->rir) || is_null($this->rir) === true) {
         $this->rawData = null;
         $this->rawLines = [];
         return;
     }
     $this->allocationData = $allocation;
     // Lets fetch the raw whois data
     if (is_null($cidr) !== true) {
         $this->input .= '/' . $cidr;
     }
     $this->rawData = removeAccents($this->getRawWhois());
     $this->rawLines = explode("\n", $this->rawData);
 }