juzaweb/proxies
Composer 安装命令:
composer require juzaweb/proxies
包简介
Craw and management proxies
README 文档
README
The Juzaweb Proxies Module is a comprehensive solution for managing, crawling, and testing proxies within your Juzaweb CMS application. It provides tools to maintain a pool of active proxies, verify their connectivity, and seamlessly integrate them into your application logic.
Features
- Proxy Management: Store and manage proxy details including IP, port, protocol, and authentication credentials.
- Automated Testing: Schedule regular checks to ensure proxies are active and responsive.
- On-Demand Testing: Manually test specific proxies via Artisan commands.
- Proxy Allocation: Retrieve available ("free") proxies for use in your application, with concurrency handling.
- Admin Interface: Configure settings and view proxy status directly from the Juzaweb Admin Panel.
Installation
You can install the package via composer:
composer require juzaweb/proxies
Configuration
Database Settings
The module uses the following settings keys which can be configured via the Juzaweb Admin Panel (Settings -> Proxies) or directly in the database:
proxy_test_url: The URL used to verify proxy connectivity (Default:https://translate.google.com).proxy_test_timeout: The timeout duration in seconds for proxy connection tests (Default:20).proxy_auto_test_enable: Enable automatic hourly testing of proxies (Set to1to enable).
Scheduler
To enable the automatic proxy checker, ensure your application's scheduler is running. If proxy_auto_test_enable is set to 1, the module will register a scheduled command to check proxies hourly.
php artisan schedule:run
Usage
Artisan Commands
The module provides several Artisan commands for managing proxies from the command line.
Check Proxies
Run a check on all available (free) proxies in the database.
php artisan proxy:check
You can also check a specific proxy by providing its address:
php artisan proxy:check --proxy=192.168.1.1:8080
Test Connectivity
Test the connectivity of a specific proxy configuration.
php artisan proxy:test <ip> <port> [protocol]
Example:
php artisan proxy:test 127.0.0.1 8080 https
Programmatic Usage
You can use the Juzaweb\Modules\Proxies\Contracts\ProxyManager contract to interact with proxies in your code.
Retrieve a Random Active Proxy
To get a random proxy that is currently active:
use Juzaweb\Modules\Proxies\Contracts\ProxyManager; $proxyManager = app(ProxyManager::class); $proxy = $proxyManager->random(); if ($proxy) { // Use the proxy echo $proxy->ip . ':' . $proxy->port; }
Retrieve and Reserve an Available Proxy
To get an available ("free") proxy and mark it as in-use (setting is_free to false):
use Juzaweb\Modules\Proxies\Contracts\ProxyManager; $proxyManager = app(ProxyManager::class); $proxy = $proxyManager->free(); if ($proxy) { // The proxy is now marked as not free. // Use the proxy... }
Helper Functions
The module provides global helper functions for working with proxy strings:
is_proxy_format(string $proxy): bool- Validates if a string is in the formatIP:PORT.parse_proxy_string_to_array(string $proxy): array- Parses a proxy string into an array with keysip,port,protocol,created_at, andupdated_at.
License
This project is licensed under the GPL-2.0 License.
juzaweb/proxies 适用场景与选型建议
juzaweb/proxies 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.83k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 10 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 juzaweb/proxies 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 juzaweb/proxies 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.83k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-10-28