cboxdk/laravel-dns 问题修复 & 功能扩展

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

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

cboxdk/laravel-dns

Composer 安装命令:

composer require cboxdk/laravel-dns

包简介

Laravel integration for cboxdk/dns — authoritative DNS lookups, domain-ownership verification, DNSSEC validation, and intoDNS/MxToolbox-style diagnostics via a facade, Artisan commands, and validation rules.

README 文档

README

Latest Version on Packagist Total Downloads PHP Version

The DNS toolkit for Laravel: authoritative lookups, domain-ownership verification, DNSSEC validation, and intoDNS/MxToolbox-style diagnostics — exposed through a facade, Artisan commands, and validation rules.

This package is the Laravel integration for the framework-agnostic cboxdk/dns engine. The DNS protocol handling, verification, propagation, SPF/DMARC parsing, and DNSSEC chain validation all live in that core library; this package wires it into the container, config, the console, and the validator so it is one composer require away in a Laravel app.

Installation

composer require cboxdk/laravel-dns

The service provider is auto-discovered. Publish the config if you want to tune the resolver:

php artisan vendor:publish --tag="dns-config"

It works with zero configuration out of the box (a raw UDP/TCP socket resolver against 1.1.1.1).

Configuration

config/dns.php:

Key Env Default Purpose
resolver DNS_RESOLVER socket Transport: socket (raw UDP/TCP) or doh (DNS-over-HTTPS JSON).
nameserver DNS_NAMESERVER 1.1.1.1 Recursive resolver for the socket transport.
timeout DNS_TIMEOUT 3.0 Per-query timeout, seconds.
doh_endpoint DNS_DOH_ENDPOINT https://dns.google/resolve JSON DoH endpoint when resolver=doh.
challenge_prefix DNS_CHALLENGE_PREFIX _cbox-challenge Label for ownership-verification TXT records.
allow_non_public_nameservers DNS_ALLOW_NON_PUBLIC_NAMESERVERS false Lifts the SSRF filter on authoritative reads. Local testing only.

The socket transport can target a zone's own authoritative nameservers, which domain-ownership verification and propagation checks require. The doh transport only queries a provider's recursive resolver, so it cannot answer authoritative or propagation queries.

Facade

use Cbox\LaravelDns\Facades\Dns;
use Cbox\Dns\Enums\RecordType;

$response = Dns::lookup('example.com', RecordType::MX);
$response->values();                       // ['mail.example.com']

Dns::verifyDomain('example.com', $token);  // bool — read authoritatively
Dns::challengeHost('example.com');         // '_cbox-challenge.example.com'

$report = Dns::diagnose('example.com');    // Cbox\Dns\Diagnostics\Report
$report->hasErrors();

Dns::dnssec()->validate('example.com');    // Cbox\Dns\Dnssec\ValidationResult

You can also inject the core types directly — the container binds both Cbox\Dns\Dns and the Cbox\Dns\Contracts\Resolver contract:

public function __construct(private \Cbox\Dns\Dns $dns) {}

Artisan commands

php artisan dns:lookup example.com MX          # table of records
php artisan dns:verify example.com <token>     # ownership challenge + result
php artisan dns:diagnose example.com           # grouped findings, non-zero exit on errors
php artisan dns:propagation www.example.com A example.com [--all]
php artisan dns:dnssec example.com             # secure / insecure / bogus + reason

Validation rules

use Cbox\LaravelDns\Rules\DnsRecordExists;
use Cbox\LaravelDns\Rules\DomainVerified;
use Cbox\Dns\Enums\RecordType;

$request->validate([
    'mail_domain' => ['required', new DnsRecordExists(RecordType::MX)],
    'domain'      => ['required', new DomainVerified($team->dns_token)],
]);

DnsRecordExists fails when the value resolves no record of the given type; DomainVerified fails unless the value publishes the challenge token in its authoritative TXT record.

Testing

Compose InteractsWithDns into your host application's TestCase to stub records and assert with zero network I/O:

use Cbox\LaravelDns\Testing\InteractsWithDns;
use Cbox\Dns\Enums\RecordType;

$this->fakeDns()->stub('example.com', RecordType::MX, ['mail.example.com']);

Dns::lookup('example.com', RecordType::MX)->values(); // ['mail.example.com']

fakeDns() swaps the container's resolver and Dns bindings for an in-memory fake, so the facade, commands, and validation rules all resolve stubbed records.

Requirements

  • PHP 8.4+
  • Laravel 12.x or 13.x

The DNS engine

All DNS behaviour is provided by cboxdk/dns — including the spoofing-resistant resolver, the SSRF-guarded authoritative reader, SPF/DMARC/CAA parsing, and DNSSEC chain validation against the IANA root trust anchors. This package claims only the Laravel integration.

Documentation

Full documentation lives in docs/.

Credits

License

The MIT License (MIT). See LICENSE.md.

cboxdk/laravel-dns 适用场景与选型建议

cboxdk/laravel-dns 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 07 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 cboxdk/laravel-dns 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-15