Code Monkey home page Code Monkey logo

easydns's Introduction

Easydns

  1. 此项目的目的时做一个足够简单高效的dns透传优选和屏蔽广告服务,类似smartdns, 但不会有 smartdns那么多的功能,只会提供核心关键的功能以保持简单高效。
  2. 此项目编译到 Padavan 算是rust依赖mipsel toolchain交叉编译到Padavan的模板
  3. 百分之百用Rust语言开发

功能完成度

假定的场景是:dns请求中的问题只有一个, 多个的情况属于容错,事实上现在dns请求带多个问题的场景基本已经没有了,家用是碰不到的。

  • A(ipv4)记录的透传并过整条链路(缓存和优选)
  • AAAA(ipv6)记录的透传并过整条链路(缓存和优选)
  • 所有其他记录容错(直接给到上游服务器去返回,不过缓存和优选)
  • 缓存(根据ttl时间, 最大条数限制)
  • 多线程(tokio实现)
  • 缓存持久化(存本地文件,下次启动时load)
  • 域名过滤(过滤广告,返回soa)
    • 返回soa
    • 从文件中读
    • 从网址中读
  • dns优选
    • 上游dns服务器优选
    • 返回的IP地址优选
      • ping协议 (需要root权限或者给程序设置cap_net_raw)
      • tcp协议
        • 80端口网页中的域名预加载到缓存
  • 参数配置化(统一的配置文件)
  • 标准日志
  • github action自动编译
  • 测试(单元测试,稳定性测试,性能测试)
  • 其他平台的编译(linux, windows, macos)

必须的依赖:

  1. rust环境
  2. mipsel toolchain 下载地址 下完解压即可
  3. cargo exec 仓库地址 clone完成后
cargo install --path .
  1. curl, 系统上必须安装 curl

可选依赖:

  1. 在本机上测试和运行依赖于 qemu-mipsel 5.2.0, 单纯编译不需要。

运行项目

自动rust版本同步

rustup show

编译

cargo exec build

运行

cargo exec run

单元测试

cargo exec test

发布

cargo exec release

调试

调试依赖

  1. qemu-mipsel 5.2.0
  2. mipsel toolchain
  3. mipsel gdb (安装教程)

有了这三个工具调试就很简单了

gdb server 启动

qemu-mipsel -L /path to mipsel toolchain/mipsel-linux-uclibc/sysroot -g 1234 ./target/mipsel-unknown-linux-uclibc/debug/easydns

gdb client连接

$ ./mipsel-linux-gdb
GNU gdb (GDB) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=mipsel-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote localhost:1234
Remote debugging using localhost:1234

在clion这种IDE上可以以Remote GDB Server来配置,核心就是上面两个命令

常用命令

设置cap_net_raw

sudo setcap cap_net_raw=eip {程序名称}

easydns's People

Contributors

dunmengjun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.