Skip to content

Commit

Permalink
[BF] Fix for #873 - No IRRDB shown for IPv6 only peer
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Nov 26, 2023
1 parent 540fa8b commit 5ab908a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
8 changes: 4 additions & 4 deletions app/Http/Requests/Irrdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ public function rules(): array
*/
public function withValidator(): void
{
if( !( $this->cust->routeServerClient() && $this->cust->irrdbFiltered() ) ) {
throw new IrrdbManage( 'IRRDB only applies to customers who are route server clients which are configured for IRRDB filtering.' );
}

if( !in_array( $this->protocol, [ 4,6 ], false ) ) {
abort( 404 , 'Unknown protocol');
}

if( !( $this->cust->routeServerClient( $this->protocol ) && $this->cust->irrdbFiltered() ) ) {
throw new IrrdbManage( 'IRRDB only applies to customers who are route server clients which are configured for IRRDB filtering.' );
}

if( !in_array( $this->type, [ "asn", 'prefix' ] ) ) {
abort( 404 , 'Unknown IRRDB type');
}
Expand Down
22 changes: 15 additions & 7 deletions app/Models/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -881,17 +881,25 @@ public function type(): string
*
* @throws
*/
public function routeServerClient( int $proto = 4 ): bool
public function routeServerClient( ?int $proto = null ): bool
{
if( !in_array( $proto, [ 4, 6 ] ) ) {
if( !in_array( $proto, [ null, 4, 6 ] ) ) {
throw new IXP_Exception( 'Invalid protocol' );
}

return (bool) self::leftJoin('virtualinterface AS vi', 'vi.custid', 'cust.id')
->leftJoin('vlaninterface AS vli', 'vli.virtualinterfaceid', 'vi.id')
->where('vli.rsclient', true )
->where('cust.id', $this->id)
->where("ipv{$proto}enabled", true)->count();
$protos = $proto === null ? [ 4, 6 ] : [ $proto ];

foreach( $protos as $p ) {
if( self::leftJoin('virtualinterface AS vi', 'vi.custid', 'cust.id')
->leftJoin('vlaninterface AS vli', 'vli.virtualinterfaceid', 'vi.id')
->where('vli.rsclient', true )
->where('cust.id', $this->id)
->where("ipv{$p}enabled", true)->count() ) {
return true;
}
}

return false;
}

/**
Expand Down

0 comments on commit 5ab908a

Please sign in to comment.