예제 #1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $rir_id = $this->rir_id;
     $as_number = $this->as_number;
     $this->cli->br()->comment('Looking up and adding: AS' . $as_number);
     $asnWhois = new Whois($as_number);
     $parsedWhois = $asnWhois->parse();
     $asn = new ASN();
     // Skip null results
     if (is_null($parsedWhois) === true) {
         // Save the null entry
         $asn->rir_id = $rir_id;
         $asn->asn = $as_number;
         $asn->raw_whois = $asnWhois->raw();
         $asn->save();
         return;
     }
     $asn->rir_id = $rir_id;
     $asn->asn = $as_number;
     $asn->name = empty($parsedWhois->name) !== true ? $parsedWhois->name : null;
     $asn->description = isset($parsedWhois->description[0]) ? $parsedWhois->description[0] : $asn->name;
     $asn->description_full = count($parsedWhois->description) > 0 ? json_encode($parsedWhois->description) : json_encode([$asn->description]);
     // Insert PeerDB Info if we get any
     if ($peerDb = $this->peeringDBData) {
         $asn->website = $peerDb->website;
         $asn->looking_glass = $peerDb->looking_glass;
         $asn->traffic_estimation = $peerDb->info_traffic;
         $asn->traffic_ratio = $peerDb->info_ratio;
     }
     $asn->counrty_code = $parsedWhois->counrty_code;
     $asn->owner_address = json_encode($parsedWhois->address);
     $asn->raw_whois = $asnWhois->raw();
     $asn->save();
     // Save ASN Emails
     foreach ($parsedWhois->emails as $email) {
         $asnEmail = new ASNEmail();
         $asnEmail->asn_id = $asn->id;
         $asnEmail->email_address = $email;
         // Check if its an abuse email
         if (in_array($email, $parsedWhois->abuse_emails)) {
             $asnEmail->abuse_email = true;
         }
         $asnEmail->save();
     }
     $this->cli->br()->comment($asn->asn . ' - ' . $asn->description . ' [' . $asn->name . ']');
 }
예제 #2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $oldAsn = $this->oldAsn;
     $oldAsn->emails()->delete();
     $this->cli->br()->comment('Updating: AS' . $oldAsn->asn);
     $asnWhois = new Whois($oldAsn->asn);
     $parsedWhois = $asnWhois->parse();
     // Skip null results
     if (is_null($parsedWhois) === true) {
         $oldAsn->touch();
         return;
     }
     $oldAsn->name = $parsedWhois->name;
     $oldAsn->description = isset($parsedWhois->description[0]) ? $parsedWhois->description[0] : $parsedWhois->name;
     $oldAsn->description_full = count($parsedWhois->description) > 0 ? json_encode($parsedWhois->description) : json_encode([$oldAsn->description]);
     // If we have the PeerDB info lets update it.
     if ($peerDb = $this->peeringDBData) {
         $oldAsn->website = $peerDb->website;
         $oldAsn->looking_glass = $peerDb->looking_glass;
         $oldAsn->traffic_estimation = $peerDb->info_traffic;
         $oldAsn->traffic_ratio = $peerDb->info_ratio;
     }
     $oldAsn->counrty_code = $parsedWhois->counrty_code;
     $oldAsn->owner_address = json_encode($parsedWhois->address);
     $oldAsn->raw_whois = $asnWhois->raw();
     $oldAsn->save();
     // Save ASN Emails
     foreach ($parsedWhois->emails as $email) {
         $asnEmail = new ASNEmail();
         $asnEmail->asn_id = $oldAsn->id;
         $asnEmail->email_address = $email;
         // Check if its an abuse email
         if (in_array($email, $parsedWhois->abuse_emails)) {
             $asnEmail->abuse_email = true;
         }
         $asnEmail->save();
     }
 }