Skip to main content

A Lightweight DNS Proxy/Relay

Project description

Dnspooh

自定义规则

规则分为: if/then 规则、 if/before 、if/after 和 if/before/after 规则。前者用于直接返回 DNS 结果,而无需请求上游服务器,通常用于屏蔽或自定义域名解析;后者可以指定上游服务器,以及处理上游服务器的返回结果。

每种规则都可以设置 end 块来表示命中该规则是否继续下一条规则判断, end 块的值是布尔类型。

if/then 规则

在所有类型的规则中, if/then 规则只能命中一次,后续的 if/then 规则都将会被跳过。then 块用来直接返回 DNS 请求结果,而不再将请求转给上游服务器。

if/before 规则

before 块用于指定上游服务器,或者替换请求中的域名。

if/after 规则

after 块用于过滤响应的解析结果。

if/before/after 规则

结合了 if/before 规则和 if/after 规则。

规则块

if

if 由一个或多个判断条件组成的逻辑运算表达式。支持的判断条件有:

  • domain is domain
  • domain is (domain1, domain2, ...)
  • domain is not domain
  • domain is not (domain1, domain2, ...)
  • keyword in domain
  • (keyword1, keyword2, ...) in domain
  • keyword not in domain
  • (keyword1, keyword2, ...) not in domain
  • domain starts with prefix
  • domain starts with (prefix1, prefix2, ...)
  • domain starts without prefix
  • domain starts without (prefix1, prefix2, ...)
  • domain ends with suffix
  • domain ends with (suffix1, suffix2, ...)
  • domain ends without suffix
  • domain ends without (suffix1, suffix2, ...)
  • domain match /regex/

支持的逻辑运算按优先级排列如下:

  • not expr
  • expr and expr
  • expr or expr

then

  • block
  • return ip
  • return (ip1, ip2, ...)

before

  • set upstream group to name
  • set upstream name to name
  • replace domain by domain

after

  • block if expr1
  • return ip if expr1
  • return (ip1, ip2, ...) if expr1
  • add record ip
  • add record (ip1, ip2, ...)
  • add record ip if expr1
  • add record (ip1, ip2, ...) if expr1
  • remove record where expr2
  • replace record by ip where expr2
  • run command where expr2

expr1 支持的判断条件有:

  • any ip is ip
  • any ip is (ip1, ip2, ...)
  • any ip is not ip
  • any ip is not (ip1, ip2, ...)
  • any ip in cidr
  • any ip in (cidr1, cidr2, ...)
  • any ip not in cidr
  • any ip not in (cidr1, cidr2, ...)
  • any geoip is country
  • any geoip is not country
  • all ip is ip
  • all ip is (ip1, ip2, ...)
  • all ip is not ip
  • all ip is not (ip1, ip2, ...)
  • all ip in cidr
  • all ip in (cidr1, cidr2, ...)
  • all ip not in cidr
  • all ip not in (cidr1, cidr2, ...)
  • all geoip is country
  • all geoip is not country

expr2 支持的判断条件有:

  • ip is ip
  • ip is (ip1, ip2, ....)
  • ip is not ip
  • ip is not (ip1, ip2, ....)
  • ip in cidr
  • ip in (cidr1, cidr2, ...)
  • ip not in cidr
  • ip not in (cidr1, cidr2, ...)
  • geoip is country
  • geoip is not country
  • first
  • last

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dnspooh-0.1.0.tar.gz (87.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dnspooh-0.1.0-py3-none-any.whl (90.0 kB view details)

Uploaded Python 3

File details

Details for the file dnspooh-0.1.0.tar.gz.

File metadata

  • Download URL: dnspooh-0.1.0.tar.gz
  • Upload date:
  • Size: 87.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for dnspooh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4fe4a67cd8294702fd5742650e08484b4b9c3b6149a079d32c84cf9d2e9ce8b1
MD5 2f9d0d1eca3ca850f9d0a13ccf9ee2ea
BLAKE2b-256 1c022dd1e0436944cfe616dd99c92c2ddcdeaaf93a3f590f08577974bfd7baa1

See more details on using hashes here.

File details

Details for the file dnspooh-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dnspooh-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 90.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for dnspooh-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ca1b63e09fdffd257ceda45fad85a34ce448fbd9394e7bb69f41a37359f326e
MD5 5421470ab441fff1511d82afb8de5d88
BLAKE2b-256 929af546ecad0e97fbc86ebcbaada836da0c06dae09012cb802a088bb8884193

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page