From e535b4667d53af0f7d2e9baa5339928e38ddbb3b Mon Sep 17 00:00:00 2001 From: Barry O'Donovan Date: Tue, 20 Jun 2023 09:49:18 +0100 Subject: [PATCH 1/4] ide --- _ide_helper.php | 64 ++++++------------- app/Models/Aggregators/CustomerAggregator.php | 12 ++-- app/Models/Aggregators/RouterAggregator.php | 8 +-- app/Models/Aggregators/SwitcherAggregator.php | 8 +-- app/Models/Aggregators/UserAggregator.php | 2 +- app/Models/Aggregators/VlanAggregator.php | 4 +- app/Models/Contact.php | 4 +- app/Models/Customer.php | 12 ++-- app/Models/CustomerToUser.php | 2 +- app/Models/Logo.php | 2 - app/Models/PatchPanel.php | 4 +- app/Models/PhysicalInterface.php | 2 +- app/Models/Router.php | 8 +-- app/Models/SwitchPort.php | 4 +- app/Models/Switcher.php | 8 +-- app/Models/User.php | 2 +- app/Models/Vlan.php | 4 +- 17 files changed, 56 insertions(+), 94 deletions(-) diff --git a/_ide_helper.php b/_ide_helper.php index 779b9c94c..d0af0573b 100644 --- a/_ide_helper.php +++ b/_ide_helper.php @@ -3940,37 +3940,42 @@ public static function macroCall($method, $parameters) return $instance->macroCall($method, $parameters); } /** - * Remove all items from the cache. + * Get a lock instance. * - * @return bool + * @param string $name + * @param int $seconds + * @param string|null $owner + * @return \Illuminate\Contracts\Cache\Lock * @static */ - public static function flush() + public static function lock($name, $seconds = 0, $owner = null) { - /** @var \Illuminate\Cache\FileStore $instance */ - return $instance->flush(); + /** @var \Illuminate\Cache\NullStore $instance */ + return $instance->lock($name, $seconds, $owner); } /** - * Get the Filesystem instance. + * Restore a lock instance using the owner identifier. * - * @return \Illuminate\Filesystem\Filesystem + * @param string $name + * @param string $owner + * @return \Illuminate\Contracts\Cache\Lock * @static */ - public static function getFilesystem() + public static function restoreLock($name, $owner) { - /** @var \Illuminate\Cache\FileStore $instance */ - return $instance->getFilesystem(); + /** @var \Illuminate\Cache\NullStore $instance */ + return $instance->restoreLock($name, $owner); } /** - * Get the working directory of the cache. + * Remove all items from the cache. * - * @return string + * @return bool * @static */ - public static function getDirectory() + public static function flush() { - /** @var \Illuminate\Cache\FileStore $instance */ - return $instance->getDirectory(); + /** @var \Illuminate\Cache\NullStore $instance */ + return $instance->flush(); } /** * Get the cache key prefix. @@ -3980,35 +3985,8 @@ public static function getDirectory() */ public static function getPrefix() { - /** @var \Illuminate\Cache\FileStore $instance */ + /** @var \Illuminate\Cache\NullStore $instance */ return $instance->getPrefix(); - } - /** - * Get a lock instance. - * - * @param string $name - * @param int $seconds - * @param string|null $owner - * @return \Illuminate\Contracts\Cache\Lock - * @static - */ - public static function lock($name, $seconds = 0, $owner = null) - { - /** @var \Illuminate\Cache\FileStore $instance */ - return $instance->lock($name, $seconds, $owner); - } - /** - * Restore a lock instance using the owner identifier. - * - * @param string $name - * @param string $owner - * @return \Illuminate\Contracts\Cache\Lock - * @static - */ - public static function restoreLock($name, $owner) - { - /** @var \Illuminate\Cache\FileStore $instance */ - return $instance->restoreLock($name, $owner); } } diff --git a/app/Models/Aggregators/CustomerAggregator.php b/app/Models/Aggregators/CustomerAggregator.php index fe8c24930..6551ef8f9 100644 --- a/app/Models/Aggregators/CustomerAggregator.php +++ b/app/Models/Aggregators/CustomerAggregator.php @@ -42,9 +42,14 @@ * IXP\Models\Aggregators\CustomerAggregator * * @property int $id + * @property int|null $irrdb + * @property int|null $company_registered_detail_id + * @property int|null $company_billing_details_id + * @property int|null $reseller * @property string|null $name * @property int|null $type * @property string|null $shortname + * @property string|null $abbreviatedName * @property int|null $autsys * @property int|null $maxprefixes * @property string|null $peeringemail @@ -54,8 +59,8 @@ * @property string|null $nocemail * @property string|null $nochours * @property string|null $nocwww - * @property int|null $irrdb * @property string|null $peeringmacro + * @property string|null $peeringmacrov6 * @property string|null $peeringpolicy * @property string|null $corpwww * @property \Illuminate\Support\Carbon|null $datejoin @@ -64,12 +69,7 @@ * @property int|null $activepeeringmatrix * @property int|null $lastupdatedby * @property string|null $creator - * @property int|null $company_registered_detail_id - * @property int|null $company_billing_details_id - * @property string|null $peeringmacrov6 - * @property string|null $abbreviatedName * @property string|null $MD5Support - * @property int|null $reseller * @property int $isReseller * @property int $in_manrs * @property int $in_peeringdb diff --git a/app/Models/Aggregators/RouterAggregator.php b/app/Models/Aggregators/RouterAggregator.php index 1bfc7cf24..7ff32603b 100644 --- a/app/Models/Aggregators/RouterAggregator.php +++ b/app/Models/Aggregators/RouterAggregator.php @@ -32,7 +32,6 @@ * IXP\Models\Aggregators\RouterAggregator * * @property int $id - * @property int|null $pair_id * @property int $vlan_id * @property string $handle * @property int $protocol @@ -51,9 +50,6 @@ * @property bool $bgp_lc * @property string $template * @property bool $skip_md5 - * @property string|null $last_update_started - * @property \Illuminate\Support\Carbon|null $last_updated - * @property int $pause_updates * @property bool $rpki * @property string|null $software_version * @property string|null $operating_system @@ -61,6 +57,7 @@ * @property int $rfc1997_passthru * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at + * @property \Illuminate\Support\Carbon|null $last_updated * @property-read \IXP\Models\Vlan $vlan * @method static Builder|Router hasApi() * @method static Builder|Router ipv4() @@ -79,15 +76,12 @@ * @method static Builder|RouterAggregator whereCreatedAt($value) * @method static Builder|RouterAggregator whereHandle($value) * @method static Builder|RouterAggregator whereId($value) - * @method static Builder|RouterAggregator whereLastUpdateStarted($value) * @method static Builder|RouterAggregator whereLastUpdated($value) * @method static Builder|RouterAggregator whereLgAccess($value) * @method static Builder|RouterAggregator whereMgmtHost($value) * @method static Builder|RouterAggregator whereName($value) * @method static Builder|RouterAggregator whereOperatingSystem($value) * @method static Builder|RouterAggregator whereOperatingSystemVersion($value) - * @method static Builder|RouterAggregator wherePairId($value) - * @method static Builder|RouterAggregator wherePauseUpdates($value) * @method static Builder|RouterAggregator wherePeeringIp($value) * @method static Builder|RouterAggregator whereProtocol($value) * @method static Builder|RouterAggregator whereQuarantine($value) diff --git a/app/Models/Aggregators/SwitcherAggregator.php b/app/Models/Aggregators/SwitcherAggregator.php index ee408edd2..9d90ee4eb 100644 --- a/app/Models/Aggregators/SwitcherAggregator.php +++ b/app/Models/Aggregators/SwitcherAggregator.php @@ -36,22 +36,22 @@ * IXP\Models\Aggregators\SwitcherAggregator * * @property int $id + * @property int|null $infrastructure * @property int|null $cabinetid * @property int|null $vendorid * @property string|null $name + * @property string|null $hostname * @property string|null $ipv4addr * @property string|null $ipv6addr * @property string|null $snmppasswd - * @property int|null $infrastructure * @property string|null $model * @property bool|null $active - * @property string|null $notes - * @property string|null $hostname * @property string|null $os * @property string|null $osDate * @property string|null $osVersion - * @property string|null $serialNumber * @property string|null $lastPolled + * @property string|null $notes + * @property string|null $serialNumber * @property int|null $mauSupported * @property int|null $asn * @property string|null $loopback_ip diff --git a/app/Models/Aggregators/UserAggregator.php b/app/Models/Aggregators/UserAggregator.php index 169166e4a..80c471c4b 100644 --- a/app/Models/Aggregators/UserAggregator.php +++ b/app/Models/Aggregators/UserAggregator.php @@ -55,9 +55,9 @@ * @property string|null $name * @property int|null $peeringdb_id * @property array|null $extra_attributes - * @property array|null $prefs * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at + * @property array|null $prefs * @property-read \Illuminate\Database\Eloquent\Collection $apiKeys * @property-read int|null $api_keys_count * @property-read Customer|null $customer diff --git a/app/Models/Aggregators/VlanAggregator.php b/app/Models/Aggregators/VlanAggregator.php index a38e03278..51424200b 100644 --- a/app/Models/Aggregators/VlanAggregator.php +++ b/app/Models/Aggregators/VlanAggregator.php @@ -35,11 +35,11 @@ * IXP\Models\Aggregators\VlanAggregator * * @property int $id + * @property int $infrastructureid * @property string|null $name * @property int|null $number - * @property string|null $notes * @property bool $private - * @property int $infrastructureid + * @property string|null $notes * @property int $peering_matrix * @property int $peering_manager * @property string|null $config_name diff --git a/app/Models/Contact.php b/app/Models/Contact.php index 56b7e73e4..da304d13d 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -38,17 +38,17 @@ * @property int $id * @property int|null $custid * @property string $name + * @property string|null $position * @property string|null $email * @property string|null $phone * @property string|null $mobile * @property bool $facilityaccess * @property bool $mayauthorize + * @property string|null $notes * @property \Illuminate\Support\Carbon|null $updated_at * @property int|null $lastupdatedby * @property string|null $creator * @property \Illuminate\Support\Carbon|null $created_at - * @property string|null $position - * @property string|null $notes * @property-read \Illuminate\Database\Eloquent\Collection $contactGroups * @property-read int|null $contact_groups_count * @property-read \Illuminate\Database\Eloquent\Collection $contactGroupsAll diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 7a0853a01..c36bd6b0c 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -48,9 +48,14 @@ * IXP\Models\Customer * * @property int $id + * @property int|null $irrdb + * @property int|null $company_registered_detail_id + * @property int|null $company_billing_details_id + * @property int|null $reseller * @property string|null $name * @property int|null $type * @property string|null $shortname + * @property string|null $abbreviatedName * @property int|null $autsys * @property int|null $maxprefixes * @property string|null $peeringemail @@ -60,8 +65,8 @@ * @property string|null $nocemail * @property string|null $nochours * @property string|null $nocwww - * @property int|null $irrdb * @property string|null $peeringmacro + * @property string|null $peeringmacrov6 * @property string|null $peeringpolicy * @property string|null $corpwww * @property Carbon|null $datejoin @@ -70,12 +75,7 @@ * @property int|null $activepeeringmatrix * @property int|null $lastupdatedby * @property string|null $creator - * @property int|null $company_registered_detail_id - * @property int|null $company_billing_details_id - * @property string|null $peeringmacrov6 - * @property string|null $abbreviatedName * @property string|null $MD5Support - * @property int|null $reseller * @property int $isReseller * @property int $in_manrs * @property int $in_peeringdb diff --git a/app/Models/CustomerToUser.php b/app/Models/CustomerToUser.php index 054a3a1b8..61eeb26e2 100644 --- a/app/Models/CustomerToUser.php +++ b/app/Models/CustomerToUser.php @@ -39,9 +39,9 @@ * @property int $customer_id * @property int $user_id * @property int $privs - * @property array|null $extra_attributes * @property string|null $last_login_date * @property string|null $last_login_from + * @property array|null $extra_attributes * @property string|null $last_login_via * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at diff --git a/app/Models/Logo.php b/app/Models/Logo.php index da97af2c5..3d1d29873 100644 --- a/app/Models/Logo.php +++ b/app/Models/Logo.php @@ -35,7 +35,6 @@ * * @property int $id * @property int|null $customer_id - * @property string $type * @property string $original_name * @property string $stored_name * @property string $uploaded_by @@ -53,7 +52,6 @@ * @method static \Illuminate\Database\Eloquent\Builder|Logo whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|Logo whereOriginalName($value) * @method static \Illuminate\Database\Eloquent\Builder|Logo whereStoredName($value) - * @method static \Illuminate\Database\Eloquent\Builder|Logo whereType($value) * @method static \Illuminate\Database\Eloquent\Builder|Logo whereUpdatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|Logo whereUploadedBy($value) * @method static \Illuminate\Database\Eloquent\Builder|Logo whereWidth($value) diff --git a/app/Models/PatchPanel.php b/app/Models/PatchPanel.php index 62d158b24..7627bb184 100644 --- a/app/Models/PatchPanel.php +++ b/app/Models/PatchPanel.php @@ -48,10 +48,9 @@ * @property int $connector_type * @property string|null $installation_date * @property string $port_prefix - * @property int $active - * @property int $colo_pp_type * @property int $chargeable * @property string $location_notes + * @property int $active * @property int|null $u_position * @property int|null $mounted_at * @property \Illuminate\Support\Carbon|null $created_at @@ -66,7 +65,6 @@ * @method static Builder|PatchPanel whereCabinetId($value) * @method static Builder|PatchPanel whereCableType($value) * @method static Builder|PatchPanel whereChargeable($value) - * @method static Builder|PatchPanel whereColoPpType($value) * @method static Builder|PatchPanel whereColoReference($value) * @method static Builder|PatchPanel whereConnectorType($value) * @method static Builder|PatchPanel whereCreatedAt($value) diff --git a/app/Models/PhysicalInterface.php b/app/Models/PhysicalInterface.php index 33d536e04..fdb8ef060 100644 --- a/app/Models/PhysicalInterface.php +++ b/app/Models/PhysicalInterface.php @@ -40,13 +40,13 @@ * * @property int $id * @property int|null $switchportid + * @property int|null $fanout_physical_interface_id * @property int|null $virtualinterfaceid * @property int|null $status * @property int|null $speed * @property string|null $duplex * @property int|null $rate_limit * @property string|null $notes - * @property int|null $fanout_physical_interface_id * @property bool $autoneg * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at diff --git a/app/Models/Router.php b/app/Models/Router.php index 037091be7..1fef41d79 100644 --- a/app/Models/Router.php +++ b/app/Models/Router.php @@ -34,7 +34,6 @@ * IXP\Models\Router * * @property int $id - * @property int|null $pair_id * @property int $vlan_id * @property string $handle * @property int $protocol @@ -53,9 +52,6 @@ * @property bool $bgp_lc * @property string $template * @property bool $skip_md5 - * @property string|null $last_update_started - * @property \Illuminate\Support\Carbon|null $last_updated - * @property int $pause_updates * @property bool $rpki * @property string|null $software_version * @property string|null $operating_system @@ -63,6 +59,7 @@ * @property int $rfc1997_passthru * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at + * @property \Illuminate\Support\Carbon|null $last_updated * @property-read \IXP\Models\Vlan $vlan * @method static Builder|Router hasApi() * @method static Builder|Router ipv4() @@ -81,15 +78,12 @@ * @method static Builder|Router whereCreatedAt($value) * @method static Builder|Router whereHandle($value) * @method static Builder|Router whereId($value) - * @method static Builder|Router whereLastUpdateStarted($value) * @method static Builder|Router whereLastUpdated($value) * @method static Builder|Router whereLgAccess($value) * @method static Builder|Router whereMgmtHost($value) * @method static Builder|Router whereName($value) * @method static Builder|Router whereOperatingSystem($value) * @method static Builder|Router whereOperatingSystemVersion($value) - * @method static Builder|Router wherePairId($value) - * @method static Builder|Router wherePauseUpdates($value) * @method static Builder|Router wherePeeringIp($value) * @method static Builder|Router whereProtocol($value) * @method static Builder|Router whereQuarantine($value) diff --git a/app/Models/SwitchPort.php b/app/Models/SwitchPort.php index 794d97983..5bfcef035 100644 --- a/app/Models/SwitchPort.php +++ b/app/Models/SwitchPort.php @@ -47,6 +47,8 @@ * @property int|null $switchid * @property int|null $type * @property string|null $name + * @property int $active + * @property int|null $ifIndex * @property string|null $ifName * @property string|null $ifAlias * @property int|null $ifHighSpeed @@ -56,8 +58,6 @@ * @property int|null $ifOperStatus * @property int|null $ifLastChange * @property string|null $lastSnmpPoll - * @property int|null $ifIndex - * @property int $active * @property int|null $lagIfIndex * @property string|null $mauType * @property string|null $mauState diff --git a/app/Models/Switcher.php b/app/Models/Switcher.php index de766b20d..823d0ff73 100644 --- a/app/Models/Switcher.php +++ b/app/Models/Switcher.php @@ -50,22 +50,22 @@ * IXP\Models\Switcher * * @property int $id + * @property int|null $infrastructure * @property int|null $cabinetid * @property int|null $vendorid * @property string|null $name + * @property string|null $hostname * @property string|null $ipv4addr * @property string|null $ipv6addr * @property string|null $snmppasswd - * @property int|null $infrastructure * @property string|null $model * @property bool|null $active - * @property string|null $notes - * @property string|null $hostname * @property string|null $os * @property string|null $osDate * @property string|null $osVersion - * @property string|null $serialNumber * @property string|null $lastPolled + * @property string|null $notes + * @property string|null $serialNumber * @property int|null $mauSupported * @property int|null $asn * @property string|null $loopback_ip diff --git a/app/Models/User.php b/app/Models/User.php index 588fe181c..e0be3a130 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -67,9 +67,9 @@ * @property string|null $name * @property int|null $peeringdb_id * @property array|null $extra_attributes - * @property array|null $prefs * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at + * @property array|null $prefs * @property-read \Illuminate\Database\Eloquent\Collection $apiKeys * @property-read int|null $api_keys_count * @property-read \IXP\Models\Customer|null $customer diff --git a/app/Models/Vlan.php b/app/Models/Vlan.php index d4d66fcab..f335d0e8c 100644 --- a/app/Models/Vlan.php +++ b/app/Models/Vlan.php @@ -36,11 +36,11 @@ * IXP\Models\Vlan * * @property int $id + * @property int $infrastructureid * @property string|null $name * @property int|null $number - * @property string|null $notes * @property bool $private - * @property int $infrastructureid + * @property string|null $notes * @property int $peering_matrix * @property int $peering_manager * @property string|null $config_name From eccd69121758951f910af9b21b0542901a42eafd Mon Sep 17 00:00:00 2001 From: Barry O'Donovan Date: Sat, 1 Jul 2023 20:58:49 +0100 Subject: [PATCH 2/4] [BF] Fix markdown prefix - closes inex/IXP-Manager#862 --- app/Http/Controllers/Api/V4/UtilsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/V4/UtilsController.php b/app/Http/Controllers/Api/V4/UtilsController.php index 4af5d4a94..079069300 100644 --- a/app/Http/Controllers/Api/V4/UtilsController.php +++ b/app/Http/Controllers/Api/V4/UtilsController.php @@ -54,7 +54,7 @@ public function markdown( Request $r ): JsonResponse { $pd = new Parsedown(); return response()->json([ - 'html' => htmlspecialchars( $pd->text( $r->text ) ) + 'html' => clean( $pd->text( $r->text ) ) ]); } } \ No newline at end of file From 4420a5905e0b310c7703a6d3002422c3654fc400 Mon Sep 17 00:00:00 2001 From: Barry O'Donovan Date: Sat, 1 Jul 2023 21:13:48 +0100 Subject: [PATCH 3/4] [IM] Potential fix for inex/IXP-Manager#855 --- app/Services/Grapher/Backend/Mrtg.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app/Services/Grapher/Backend/Mrtg.php b/app/Services/Grapher/Backend/Mrtg.php index c71846246..53917bfc1 100644 --- a/app/Services/Grapher/Backend/Mrtg.php +++ b/app/Services/Grapher/Backend/Mrtg.php @@ -187,8 +187,6 @@ public function getPeeringPorts(): array if( !$pi->isConnectedOrQuarantine() || !$pi->switchPort->ifIndex || !( $pi->switchPort->switcher->active && $pi->switchPort->switcher->poll ) - || $pi->switchPort->typeReseller() - || $pi->switchPort->typeFanout() ) { continue; } @@ -196,7 +194,7 @@ public function getPeeringPorts(): array $data[ 'pis' ][ $pi->id ] = $pi; if( !isset( $data[ 'custs' ][ $c->id ] ) ) { - $data[ 'custs' ][ $c->id ] = $c; + $data[ 'custs' ][ $c->id ] = $c; } if( !isset( $data['sws'][ $pi->switchPort->switcher->id ] ) ) { @@ -224,18 +222,23 @@ public function getPeeringPorts(): array $data[ 'custlags' ][ $c->id ][ $vi->id ][] = $pi->id; } - $data['swports'][ $pi->switchPort->switcher->id ][] = $pi->id; - $data['locports'][ $pi->switchPort->switcher->cabinet->location->id ][] = $pi->id; - $data['infraports'][ $pi->switchPort->switcher->infrastructureModel->id ][] = $pi->id; - $data['ixpports'][] = $pi->id; - $maxbytes = $pi->detectedSpeed() * 1000000 / 8; // Mbps * bps / to bytes $switcher = $pi->switchPort->switcher; $location = $pi->switchPort->switcher->cabinet->location; - $data['swports_maxbytes' ][ $switcher->id ] += $maxbytes; - $data['locports_maxbytes' ][ $location->id ] += $maxbytes; - $data['infraports_maxbytes'][ $switcher->infrastructureModel->id ] += $maxbytes; - $data['ixpports_maxbytes'] += $maxbytes; + + // don't count reseller ports or fanout ports in agregates + if( !$pi->switchPort->typeReseller() && !$pi->switchPort->typeFanout() ) { + $data[ 'swports' ][ $pi->switchPort->switcher->id ][] = $pi->id; + $data[ 'locports' ][ $pi->switchPort->switcher->cabinet->location->id ][] = $pi->id; + $data[ 'infraports' ][ $pi->switchPort->switcher->infrastructureModel->id ][] = $pi->id; + $data[ 'ixpports' ][] = $pi->id; + + $data['swports_maxbytes' ][ $switcher->id ] += $maxbytes; + $data['locports_maxbytes' ][ $location->id ] += $maxbytes; + $data['infraports_maxbytes'][ $switcher->infrastructureModel->id ] += $maxbytes; + $data['ixpports_maxbytes'] += $maxbytes; + } + } } } From 540fa8b8d136d989e5ba3a0d2e55d5f97e5e5115 Mon Sep 17 00:00:00 2001 From: Barry O'Donovan Date: Tue, 26 Sep 2023 14:18:47 +0100 Subject: [PATCH 4/4] [DB] Do not log automated update events for route servers --- app/Models/Router.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Models/Router.php b/app/Models/Router.php index 1fef41d79..4fe226ce0 100644 --- a/app/Models/Router.php +++ b/app/Models/Router.php @@ -149,6 +149,17 @@ class Router extends Model 'last_updated' => 'datetime', ]; + /** + * The attributes that should not be logged + * + * @var array + */ + public $field_log_exception = [ + 'last_updated', + 'updated_at', + ]; + + /** * CONST PROTOCOL */