cli-anything-adguardhome

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

cli-anything-adguardhome

cli-anything-adguardhome

Network-wide ad blocking and DNS management via the AdGuard Home REST API. Designed for AI agents and power users who need to manage filtering, DNS rewrites, clients, DHCP, and query logs without a GUI.
通过 AdGuard Home REST API 实现全网络广告拦截与DNS管理。专为无需图形界面(GUI)即可管理过滤规则、DNS重写、客户端、DHCP和查询日志的AI Agent及高级用户设计。

Installation

安装

This CLI is installed as part of the cli-anything-adguardhome package:
bash
pip install cli-anything-adguardhome
Prerequisites:
  • Python 3.10+
  • AdGuard Home must be installed and running
  • Install AdGuard Home:
    curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v
此CLI作为cli-anything-adguardhome包的一部分进行安装:
bash
pip install cli-anything-adguardhome
前置要求:
  • Python 3.10+
  • AdGuard Home 必须已安装并运行
  • 安装AdGuard Home:
    curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v

Usage

使用方法

Basic Commands

基础命令

bash
undefined
bash
undefined

Show help

显示帮助信息

cli-anything-adguardhome --help
cli-anything-adguardhome --help

Start interactive REPL mode

启动交互式REPL模式

cli-anything-adguardhome
cli-anything-adguardhome

Check server status

检查服务器状态

cli-anything-adguardhome server status
cli-anything-adguardhome server status

Run with JSON output (for agent consumption)

以JSON格式输出(供Agent使用)

cli-anything-adguardhome --json server status
undefined
cli-anything-adguardhome --json server status
undefined

REPL Mode

REPL交互模式

When invoked without a subcommand, the CLI enters an interactive REPL session:
bash
cli-anything-adguardhome
当不指定子命令调用时,CLI会进入交互式REPL会话:
bash
cli-anything-adguardhome

Enter commands interactively with tab-completion and history

交互式输入命令,支持自动补全和历史记录

undefined
undefined

Command Groups

命令组

Config

配置

Connection and configuration management.
CommandDescription
show
Show current connection configuration
save
Save connection settings to a config file
test
Test the connection to AdGuard Home
连接与配置管理。
命令说明
show
显示当前连接配置
save
将连接设置保存到配置文件
test
测试与AdGuard Home的连接

Server

服务器

Server status and control commands.
CommandDescription
status
Show server protection status
version
Show AdGuard Home version
restart
Restart the AdGuard Home server
服务器状态与控制命令。
命令说明
status
显示服务器防护状态
version
显示AdGuard Home版本
restart
重启AdGuard Home服务器

Filter

过滤规则

DNS filter list management.
CommandDescription
list
List all configured filter lists
status
Show filtering status
toggle
Enable or disable filtering globally
add
Add a new filter list by URL
remove
Remove a filter list
enable
Enable a specific filter list
disable
Disable a specific filter list
refresh
Force-refresh all filter lists
DNS过滤列表管理。
命令说明
list
列出所有已配置的过滤列表
status
显示过滤功能状态
toggle
全局启用或禁用过滤功能
add
通过URL添加新的过滤列表
remove
删除过滤列表
enable
启用指定过滤列表
disable
禁用指定过滤列表
refresh
强制刷新所有过滤列表

Blocking

拦截设置

Parental control, safe browsing, and safe search settings.
CommandDescription
parental status
Show parental control status
parental enable
Enable parental control
parental disable
Disable parental control
safebrowsing status
Show safe browsing status
safebrowsing enable
Enable safe browsing
safebrowsing disable
Disable safe browsing
safesearch status
Show safe search status
safesearch enable
Enable safe search
safesearch disable
Disable safe search
家长控制、安全浏览与安全搜索设置。
命令说明
parental status
显示家长控制状态
parental enable
启用家长控制
parental disable
禁用家长控制
safebrowsing status
显示安全浏览状态
safebrowsing enable
启用安全浏览
safebrowsing disable
禁用安全浏览
safesearch status
显示安全搜索状态
safesearch enable
启用安全搜索
safesearch disable
禁用安全搜索

Blocked-Services

拦截服务

Manage blocked internet services.
CommandDescription
list
List currently blocked services
set
Set the list of blocked services
管理被拦截的互联网服务。
命令说明
list
列出当前被拦截的服务
set
设置被拦截服务列表

Clients

客户端

Client device management.
CommandDescription
list
List all configured clients
add
Add a new client by name and IP
remove
Remove a client
show
Show details for a specific client
客户端设备管理。
命令说明
list
列出所有已配置的客户端
add
通过名称和IP添加新客户端
remove
删除客户端
show
显示指定客户端的详细信息

Stats

统计信息

Query statistics.
CommandDescription
show
Show DNS query statistics
reset
Reset all statistics
config
View or update statistics retention interval
查询统计数据。
命令说明
show
显示DNS查询统计数据
reset
重置所有统计数据
config
查看或更新统计数据保留间隔

Log

日志

DNS query log management.
CommandDescription
show
Show recent DNS query log entries
config
View or update query log settings
clear
Clear the query log
DNS查询日志管理。
命令说明
show
显示近期DNS查询日志条目
config
查看或更新查询日志设置
clear
清空查询日志

Rewrite

DNS重写

DNS rewrite rules.
CommandDescription
list
List all DNS rewrite rules
add
Add a DNS rewrite rule
remove
Remove a DNS rewrite rule
DNS重写规则。
命令说明
list
列出所有DNS重写规则
add
添加DNS重写规则
remove
删除DNS重写规则

DHCP

DHCP

DHCP server management.
CommandDescription
status
Show DHCP server status
leases
List active DHCP leases
add-static
Add a static DHCP lease
remove-static
Remove a static DHCP lease
DHCP服务器管理。
命令说明
status
显示DHCP服务器状态
leases
列出活跃的DHCP租约
add-static
添加静态DHCP租约
remove-static
删除静态DHCP租约

TLS

TLS

TLS/HTTPS configuration.
CommandDescription
status
Show TLS configuration status
TLS/HTTPS配置。
命令说明
status
显示TLS配置状态

Examples

示例

Check Server Status

检查服务器状态

bash
cli-anything-adguardhome server status
cli-anything-adguardhome server version
bash
cli-anything-adguardhome server status
cli-anything-adguardhome server version

Manage Filter Lists

管理过滤列表

bash
undefined
bash
undefined

List current filters

列出当前过滤列表

cli-anything-adguardhome filter list
cli-anything-adguardhome filter list

Add a new blocklist

添加新的拦截列表

cli-anything-adguardhome filter add --url https://somehost.com/list.txt --name "My List"
cli-anything-adguardhome filter add --url https://somehost.com/list.txt --name "My List"

Refresh all filters

刷新所有过滤列表

cli-anything-adguardhome filter refresh
undefined
cli-anything-adguardhome filter refresh
undefined

DNS Rewrites

DNS重写

bash
undefined
bash
undefined

Add a local DNS entry

添加本地DNS条目

cli-anything-adguardhome rewrite add --domain "myserver.local" --answer "192.168.1.50"
cli-anything-adguardhome rewrite add --domain "myserver.local" --answer "192.168.1.50"

List all rewrites

列出所有重写规则

cli-anything-adguardhome rewrite list
undefined
cli-anything-adguardhome rewrite list
undefined

Client Management

客户端管理

bash
cli-anything-adguardhome clients add --name "My PC" --ip 192.168.1.100
cli-anything-adguardhome clients list
bash
cli-anything-adguardhome clients add --name "My PC" --ip 192.168.1.100
cli-anything-adguardhome clients list

Query Statistics

查询统计数据

bash
undefined
bash
undefined

Show stats (human-readable)

显示统计数据(人类可读格式)

cli-anything-adguardhome stats show
cli-anything-adguardhome stats show

Show stats (JSON for agents)

显示统计数据(供Agent使用的JSON格式)

cli-anything-adguardhome --json stats show
undefined
cli-anything-adguardhome --json stats show
undefined

Output Formats

输出格式

All commands support dual output modes:
  • Human-readable (default): Tables, colors, formatted text
  • Machine-readable (
    --json
    flag): Structured JSON for agent consumption
bash
undefined
所有命令支持两种输出模式:
  • 人类可读格式(默认):表格、颜色、格式化文本
  • 机器可读格式
    --json
    参数):结构化JSON,供Agent使用
bash
undefined

Human output

人类可读输出

cli-anything-adguardhome filter list
cli-anything-adguardhome filter list

JSON output for agents

供Agent使用的JSON输出

cli-anything-adguardhome --json filter list
undefined
cli-anything-adguardhome --json filter list
undefined

For AI Agents

面向AI Agent的使用说明

When using this CLI programmatically:
  1. Always use
    --json
    flag
    for parseable output
  2. Check return codes - 0 for success, non-zero for errors
  3. Parse stderr for error messages on failure
  4. Use absolute paths for all file operations
  5. Test connection first with
    config test
    before other commands
以编程方式使用此CLI时:
  1. 始终使用
    --json
    参数
    以获得可解析的输出
  2. 检查返回码 - 0表示成功,非零表示错误
  3. 解析stderr以获取失败时的错误信息
  4. 使用绝对路径进行所有文件操作
  5. 先测试连接,在执行其他命令前使用
    config test
    测试连接

More Information

更多信息

  • Full documentation: See README.md in the package
  • Test coverage: See TEST.md in the package
  • Methodology: See HARNESS.md in the cli-anything-plugin
  • 完整文档:查看包中的README.md
  • 测试覆盖率:查看包中的TEST.md
  • 方法说明:查看cli-anything-plugin中的HARNESS.md

Version

版本

1.0.0
1.0.0