Coder Social home page Coder Social logo

alvinsung / dnsforwarder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lifenjoiner/dnsforwarder

0.0 1.0 0.0 4.93 MB

Just a DNS utility. My personal mod for daily use ~

License: GNU General Public License v3.0

C 86.77% Shell 10.01% HTML 2.12% M4 1.10%

dnsforwarder's Introduction

dnsforwarder

一个简单的 DNS 转发代理

主要功能:

  1. 指定不同的域名使用不同的服务器(支持非标准端口)、不同的协议(UDP、TCP)进行查询;
  2. DNS 缓存及相关的控制(支持自定义 TTL);
  3. 屏蔽包含指定的 IP 的 DNS 数据包;
  4. Hosts 功能(支持通配符、CName 指定、网络 Hosts);
  5. 屏蔽指定的域名查询请求(广告屏蔽?);
  6. 跨平台(Windows、Linux);

安装和部署

参考 default.config

配置逻辑

host 匹配顺序:

  1. DisabledList, 行数据 < 512 字节。
  2. Hosts {AppendHosts(静态) -> hosts 文件(动态)}
    类型:支持 IPv4、IPv6、@@(跳过)、<name> (GoodIPList) 和 CName
  3. DNS 缓存。
  4. (ServerGroup = GroupFile + UDPGroup + TCPGroup + TLSGroup) {
    行数据 < 384 字节;
    全被转为小写;
    #;后面为注释;
    相同 domain 时后面的规则生效(Last In First Match);
    GroupFile 路径语法: Win: ExpandEnvironmentStrings, *nix: wordexp
    }
  5. 无匹配时选择一组上级 DNS 转发查询。

DisabledList, GroupFile 的 domain 匹配

  1. 无通配符: 全部 || 每一个.后面的部分;
  2. 有通配符: Win: PathMatchSpec(,); *nix: fnmatch(,,)

Log 类型缩写

Alias Description
B Bad
C Cache
H Hosts records
INFO Information
R Rejected
S Tls
T TCP
U UDP

A simple DNS forwarder

Main Fetures:

  1. Forwarding queries to customized domains (and their subdomains) to specified servers over a specified protocol (UDP or TCP). non-standard ports are supported;
  2. DNS cache and its controls (including modifying TTL for different domains);
  3. Ignoring DNS responses from upstream servers containing particular IPs;
  4. Loading hosts from file (including the support for wildcards, CName redirections and remote hosts files);
  5. Refusing queries to specified domains (for ads blocking?);
  6. Cross-platform (Windows, Linux);

Installation & Deployment

Read default.en.config.

Configuring Logic

host matching order:

  1. DisabledList, line length < 512 chars
  2. Hosts {AppendHosts (StaticHosts) -> hosts-files (DynamicHosts)}
    Types:supports IPv4, IPv6, @@ (skipping), <name> (GoodIPList) and CName
  3. DNS Cache
  4. (ServerGroup = GroupFile + UDPGroup + TCPGroup + TLSGroup) {
    line length < 384 chars;
    converted to lower case before testing;
    # or ; leads comments;
    for the same domain rules, the last wins (Last In First Match);
    GroupFile path syntax: Win: ExpandEnvironmentStrings, *nix: wordexp.
    }
  5. If none matches, forward it to 1 group of upstream DNS.

Domain Matching for DisabledList, GroupFile:

  1. No Wild Card: Full || Right part of each .;
  2. Wild Card: Win: PathMatchSpec(,); *nix: fnmatch(,,)

Log Flags

Alias Description
B Bad
C Cache
H Hosts records
INFO Information
R Rejected
S Tls
T TCP
U UDP

License :

GPL v3

Dependencies :

For Linux:

pthread;
libcurl (optional);

For Windows:

None.

Macros needed to be declared while compiling :

For Linux:

None.

For Windows x86 (at least Windows XP)

WIN32

For Windows x86-64 (at least Windows Vista):

WIN32
WIN64

dnsforwarder's People

Contributors

buttonfly1000 avatar lifenjoiner avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.