clash82/cachedhttpbl 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

clash82/cachedhttpbl

Composer 安装命令:

composer require clash82/cachedhttpbl

包简介

Cached http:BL is a PHP >=8.3 library that allows to check IPv4 address with `Project HoneyPot's http:BL service` to determine if it's located on the blacklist.

README 文档

README

phpunit phpcs php-cs-fixer phpstan phpmd rector

Author: Rafał Toborek

Cached http:BL is a PHP (>= v8.3) library that allows you to check an IPv4 address using Project HoneyPot's http:BL service to determine whether it is listed on the blacklist.

Note: If you still need to support PHP 5.x or PHP < 7.2, install version 2.x. For PHP >= 7.2, install version 3.x.

Why use the http:BL service?

Http:BL provides data about the IP addresses of visitors to your website. The data is exchanged via the DNS system. You can query DNS server and receive a response indicating the type of visitor to your site, the level of threat they pose, and how long it has been since they were last seen within the Project Honey Pot trap network.

More details on how the service works can be found on the official webpage.

Why use the Cached http:BL library?

One of the biggest advantages of using the CachedHttpBL library is the ability to cache http:BL responses using cache adapters. You can use one of the available cache adapters (CSV, Memory, BlackHole) or create a new one by implementing a dedicated cache interface. The library is built in an elegant, object-oriented style, allowing you to extend its functionality.

Try it!

Stable version:

composer require clash82/cachedhttpbl:4.*

Here is an example (CLI script) of how to use library with CSV cache adapter:

<?php

// define the suspicious IP address (fill this with the IP address you want to check)
$ip = '';

// provide a valid http:BL API key (you can create one at the http:BL dashboard)
// note: there is no way to validate this key programmatically, so ensure it's correct
$httpblApiKey = '';

// use namespace autoloader
require_once 'CachedHttpBl/vendor/autoload.php';

// create a new storage adapter for caching responses
$adapter = new CachedHttpBL\CacheAdapter\CSVCacheAdapter(sys_get_temp_dir().'/httpbl_cache.csv');

// initialize the provider for Project Honey Pot
$provider = new CachedHttpBL\Provider\ProjectHoneyPotProvider($httpblApiKey);

// set up the CachedHttpBL client
$cachedHttpBl = new CachedHttpBL\Client($provider, $adapter);

try {
    // fetch response data from the http:BL service
    $response = $cachedHttpBl->checkIP($ip);

    // use a translator to provide more detailed information about the response (optional but useful)
    $translator = new CachedHttpBL\Translator\ProjectHoneyPotTranslator();
    $translator->translate($response);

    // output formatted details about the IP address
    printf("The http:BL service was requested to get details about %s IP address:\n\n", $ip);

    printf("Type code: %d\n", $response->getType());
    printf("Activity code: %d (%s)\n", $response->getActivity(), $translator->getActivityDescription());
    printf("Threat code: %d (%s)\n", $response->getThreat(), $translator->getThreatDescription());
    printf("Type meaning code: %d (%s)\n", $response->getTypeMeaning(), $translator->getTypeMeaningDescription());

    // save the cache for future use
    $adapter->writeCache();
} catch (\Exception $e) {
    // handle errors gracefully
    printf("Error: Unable to retrieve details for the given IP address. %s\n", $e->getMessage());
}

Launch the Test Suite

In the CachedHttpBL directory:

composer test

Change log

v4.2.0:

v4.1.0:

  • dropped support for PHP < v8.3.

v4.0.0:

  • dropped support for PHP < v8.1 (use v3.x instead),
  • Travis-CI integration was replaced with GitHub Actions,
  • added logical operator is for Translator class type meanings (eg. isHarversterType(), isUnknownType(), etc.),
  • code refactor and upgrades.

v3.0.0:

  • dropped support for PHP v5.x and PHP < v7.2 (use v2.x instead),
  • added full support for PHP v7.2 and PHP v7.3 (enabled strict_types),
  • enabled Travis-CI integration for phpstan, php-cs-fixer, phpmd and phpcs,
  • fixed minor issues and adjusted coding standards.

v2.0.0:

  • added PSR-2 coding standards,
  • added lot of improvements and bug fixes,
  • completely refactored code (added more abstract class model, interfaces, cache adapters etc.),
  • added tests.

v1.0.1:

  • some stupid errors were fixed.

v1.0.0:

  • initial release.

Jezus żyje! 🧡

clash82/cachedhttpbl 适用场景与选型建议

clash82/cachedhttpbl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 41.31k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2015 年 08 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「spam」 「blacklist」 「httpbl」 「projecthoneypot」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 clash82/cachedhttpbl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 clash82/cachedhttpbl 我们能提供哪些服务?
定制开发 / 二次开发

基于 clash82/cachedhttpbl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 41.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 22
  • 点击次数: 22
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 22
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2015-08-04