Coder Social home page Coder Social logo

dns-server's Introduction

dns-server

A DNS server app written by pure Nodejs for develop and test use. Only support IPv4 now.

To resolve specified domain name to specified IP using keyword-matching algorithm. Useful for frontend developer and tester when involved into a website project.

纯Nodejs写的本地DNS服务器,供开发测试使用。

前端做网站时,本地开发通常是用nginx或nodejs做服务器,然后在浏览器中使用IP地址(127.0.0.1或localhost)来打开网站。但有些功能需要有域名(或二级域名)才能工作,那么就可以用这个工具来做本地解析,对符合关键字的域名查询指向指定的IP。

效果图 effect

请留意各图中的url地址,实际上hursing.com不存在的。Please look at the url and know that the hursing.com does not exist actually.

sample

sample

sample

nslookup

使用方法 How to use

按照图示,找到原来的DNS服务器地址,并改成127.0.0.1。Follow the steps, find the original dns server and change it to 127.0.0.1.

Mac

修改前 before change:

mac

修改后 after change:

mac

Windows

查看原来的dns服务器地址 view the original dns server:

win

修改前 before change:

win

修改后 after change: win

启动dns服务 launch dns server

打开 openindex.js:

code

对上面的代码做修改 modify the code

  • fallbackServer改成原来的DNS服务器地址 change fallbackServer to your original dns server address
  • domain改成你想解析的域名关键字 change domain to the keyword of your expected domain name
  • targetIp改成你想解析到的IP地址 change targetIp to the resolved IP

然后运行 then run node index.js。mac上需要 on mac you have to run sudo node index.js

running

实现原理 implement

DNS protocol: https://tools.ietf.org/html/rfc1035

可以做更多 You can do more

  • 加入配置文件,可匹配多个关键字 use configuration file for matching multiple keywords
  • 增加命令行参数,不用在源码修改关键字 add command line args support to avoid modifying keyword in source code

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.