tourze / ip-collection-bundle
IP地址收集和标记管理工具,支持多种IP来源同步
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/ip-collection-bundle
Requires
- php: ^8.1
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- league/uri: ^7.5.1
- nesbot/carbon: ^2.72 || ^3
- symfony/config: ^6.4
- symfony/console: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-client: ^6.4
- symfony/http-client-contracts: ^2.5 | ^3.0
- symfony/http-kernel: ^6.4
- symfony/serializer: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/doctrine-indexed-bundle: 0.0.*
- tourze/doctrine-timestamp-bundle: 0.0.*
- tourze/doctrine-upsert-bundle: 0.1.*
- tourze/easy-admin-attribute: 0.1.*
- tourze/symfony-cron-job-bundle: 0.1.*
- tourze/symfony-lock-command-bundle: 0.0.*
- yiisoft/json: ^1.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-11-01 19:17:41 UTC
README
A Symfony Bundle for collecting and managing IP address information from various sources including AWS, cloud providers, and BT trackers.
Features
- Synchronize various public IP address lists
- Collect BT Tracker addresses
- Synchronize AWS IP address ranges
- IP address tagging and management
- Automated synchronization with cron jobs
Installation
Requirements
This bundle requires the following dependencies:
- PHP 8.1 or higher
- Symfony 7.3+
- Doctrine ORM 3.0+
- Additional packages:
league/uri: URI manipulation librarynesbot/carbon: Date manipulation libraryyiisoft/json: JSON encoding/decodingtourze/doctrine-upsert-bundle: Database upsert operationstourze/symfony-lock-command-bundle: Command lockingtourze/symfony-cron-job-bundle: Cron job scheduling
Install via Composer
composer require tourze/ip-collection-bundle
Configuration
Add the bundle to your config/bundles.php:
return [ // ... IpCollectionBundle\IpCollectionBundle::class => ['all' => true], ];
Usage
Commands
The Bundle provides the following console commands:
game-boost:sync-cidr- Synchronize IP address lists from various cloud providers and sourcesip-collection:sync-aws-ip-range- Synchronize AWS IP address rangesbt:sync-public-tracker- Collect public BT Tracker addresses
All commands are configured with automatic cron scheduling and can also be executed manually.
Manual Execution
# Synchronize AWS IP ranges (runs every 6 hours) php bin/console ip-collection:sync-aws-ip-range # Sync CIDR lists from various cloud providers (runs every 6 hours) php bin/console game-boost:sync-cidr # Collect BT tracker addresses (runs daily at 6:33 AM) php bin/console bt:sync-public-tracker
Entities
The Bundle includes the following entities:
IpTag- Stores IP address tag informationBtTracker- Stores BT Tracker information
Advanced Usage
Customizing IP Sources
You can extend the SyncCidrListCommand class to add your own IP data sources:
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(); } }
Working with IP Tags
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;
Working with BT Trackers
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://') );
Testing
Run the following command in the project root directory to execute tests:
vendor/bin/phpunit packages/ip-collection-bundle/tests
Contributing
Please see CONTRIBUTING.md for details on how to contribute to this project.
Changelog
Please see CHANGELOG.md for information about recent changes.
License
This project is licensed under the MIT License - see the LICENSE file for details.