1. Go to this page and download the library: Download tourze/ip-collection-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class CustomSyncCommand extends SyncCidrListCommand
{
protected function getProviders(): \Traversable
{
// Add your custom providers here
yield 'custom-source' => [
'https://example.com/ip-list.txt',
];
// Include default providers
yield from parent::getProviders();
}
}
use IpCollectionBundle\Entity\IpTag;
use Doctrine\ORM\EntityManagerInterface;
// Find IPs by tag
$repository = $entityManager->getRepository(IpTag::class);
$awsIps = $repository->findBy(['tag' => 'aws-ipv4']);
$chinaIps = $repository->findBy(['tag' => 'geoip2-cn']);
$aliyunIps = $repository->findBy(['tag' => 'aliyun']);
// Check if an IP belongs to a specific provider
$isAwsIp = $repository->findOneBy([
'address' => '203.0.113.0/24',
'tag' => 'aws-ipv4'
]) !== null;
use IpCollectionBundle\Entity\BtTracker;
// Get all active trackers
$trackerRepository = $entityManager->getRepository(BtTracker::class);
$trackers = $trackerRepository->findAll();
// Filter by protocol
$udpTrackers = array_filter($trackers, fn(BtTracker $tracker) =>
str_starts_with($tracker->getUrl(), 'udp://')
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.