Add status of process

This commit is contained in:
Nick Peng
2018-08-03 22:49:55 +08:00
parent f5863e4d82
commit 08c1f5e8d1
9 changed files with 178 additions and 101 deletions

View File

@@ -7,7 +7,11 @@ SmartDNS是一个运行在本地的DNS服务器SmartDNS接受本地客户端
支持树莓派openwrt华硕路由器等设备。
**阿里DNS**
软件效果展示
==============
**阿里DNS**
使用阿里DNS查询百度IP并检测结果。
```shell
pi@raspberrypi:~/code/smartdns_build $ nslookup www.baidu.com 223.5.5.5
Server: 223.5.5.5
@@ -38,8 +42,8 @@ PING 180.97.33.108 (180.97.33.108) 56(84) bytes of data.
rtt min/avg/max/mdev = 31.014/31.094/31.175/0.193 ms
```
**smartdns**
**smartdns**
使用阿里SmartDNS查询百度IP并检测结果。
```shell
pi@raspberrypi:~/code/smartdns_build $ nslookup www.baidu.com
Server: 192.168.1.1
@@ -121,16 +125,17 @@ rtt min/avg/max/mdev = 5.954/6.133/6.313/0.195 ms
|openwrt LEDE|smartdns.xxxxxxxxx.arm_cortex-a7_neon-vfpv4.ipk|支持arm A7核心CPU的路由器
|openwrt LUCI|luci-app-smartdns.xxxxxxxxx.xxxx.all.ipk|openwrt管理统一界面
openwrt系统CPU架构比较多请查看CPU架构后下载CPU架构可在路由器管理界面找到查看方法
openwrt系统CPU架构比较多上述表格未列出所有支持系统请查看CPU架构后下载。
CPU架构可在路由器管理界面找到查看方法
* 登录路由器,点击`System`->`Software`,点击`Configuration` Tab页面在opkg安装源中可找到对应软件架构下载路径中可找到如下架构为ar71xx
```
src/gz chaos_calmer_base http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/base
```
[此处下载](https://github.com/pymumu/smartdns/releases)
请在Release页面下载[此处下载](https://github.com/pymumu/smartdns/releases)
标准Linux系统安装树莓派
标准Linux系统安装树莓派, X86_64系统
--------------
1. 安装
下载配套安装包`smartdns.xxxxxxxx.armhf.deb`并上传到Linux系统中。 执行如下命令安装
@@ -164,23 +169,22 @@ systemctl start smartdns
II. 华为等路由器可能不支持配置DNS为本地IP请修改PC端手机端DNS服务器为树莓派IP。
5. 检测服务是否配置成功。
使用nslookup查询域名,看命令结果中的`服务器`项目是否显示为`Linux主机名`如raspberry则表示生效
使用`nslookup -querytype=ptr 127.0.0.1`查询域名
看命令结果中的`name`项目是否显示为`smartdns``主机名`,如`smartdns`则表示生效
```
C:\Users\meikechong>nslookup www.baidu.com
服务器: raspberry
Address: 192.168.1.1
非权威应答:
名称: www.a.shifen.com
Address: 14.215.177.39
Aliases: www.baidu.com
pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 127.0.0.1
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
1.0.0.127.in-addr.arpa name = smartdns.
```
openwrt/LEDE
--------------
1. 安装
将软件使用winscp上传到路由器的/root目录执行如下命令安装
将软件使用winscp上传到路由器的/root目录执行如下命令安装
```
opkg install smartdns.xxxxxxxx.xxxx.ipk
@@ -195,18 +199,17 @@ opkg install luci-app-smartdns.xxxxxxxx.xxxx.all.ipk
3. 启动服务
勾选配置页面中的`Enable(启用)`来启动SmartDNS
4. 检测服务是否配置成功
使用nslookup查询域名,看命令结果中的`服务器`项目是否显示为`Linux主机名`,如`smartdns`则表示生效
4. 检测服务是否配置成功
使用`nslookup -querytype=ptr 127.0.0.1`查询域名
看命令结果中的`name`项目是否显示为`smartdns``主机名`,如`smartdns`则表示生效
```
C:\Users\meikechong>nslookup www.baidu.com
服务器: smartdns
Address: 192.168.1.1
非权威应答:
名称: www.a.shifen.com
Address: 14.215.177.39
Aliases: www.baidu.com
pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 127.0.0.1
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
1.0.0.127.in-addr.arpa name = smartdns.
```
5. 注意:
@@ -223,32 +226,31 @@ Aliases: www.baidu.com
登录管理界面,点击`系统管理`->点击`系统设置`,配置`Enable SSH``Lan Only`
SSH登录用户名密码与管理界面相同。
2. 下载`Download Master`
2. 下载`Download Master`
在管理界面点击`USB相关应用`->点击`Download Master`下载。
下载完成后,启用`Download Master`,如果不需要下载功能,此处可以卸载`Download Master`但要保证卸载前Download Master是启用的。
3. 安装SmartDNS
3. 安装SmartDNS
将软件使用winscp上传到路由器的`/tmp/mnt/sda1`目录。或网上邻居复制到sda1共享目录
```
ipkg install smartdns.xxxxxxx.mipsbig.ipk
```
4. 重启路由器生效服务
待路由器启动后使用nslookup查询域名,看命令结果中的`服务器`项目是否显示为`smartdns`如显示smartdns则表示生效
4. 重启路由器生效服务
待路由器启动后,使用`nslookup -querytype=ptr 127.0.0.1`查询域名
看命令结果中的`name`项目是否显示为`smartdns``主机名`,如`smartdns`则表示生效
```
C:\Users\meikechong>nslookup www.baidu.com
服务器: smartdns
Address: 192.168.1.1
非权威应答:
名称: www.a.shifen.com
Address: 14.215.177.39
Aliases: www.baidu.com
pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 127.0.0.1
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
1.0.0.127.in-addr.arpa name = smartdns.
```
5. 额外说明
5. 额外说明
上述过程smartdns将安装到U盘根目录采用optware的模式运行。
其目录结构如下: 此处仅列出smartdns相关文件
@@ -299,7 +301,7 @@ vi /opt/etc/smartdns/smartdns.conf
|server-tcp|上游TCP DNS|无|[IP][:port],可重复| server-tcp 8.8.8.8:53
|address|指定域名IP地址|无|address /domain/ip| address /www.example.com/1.2.3.4
[Donate](#Donate)
[Donate](#Donate)
==============
如果你觉得此项目对你有帮助,请捐助我们,以使项目能持续发展,更加完善。
* PayPal
@@ -311,6 +313,15 @@ vi /opt/etc/smartdns/smartdns.conf
* Wechat 微信
![wechat](doc/wechat_donate.jpg)
声明
==============
* `SmartDNS`著作权归属Nick Peng (pymumu at gmail.com)。
* `SmartDNS`为免费软件,用户可以非商业性地复制和使用`SmartDNS`
* 禁止将 `SmartDNS` 用于商业用途。
* 使用本软件的风险由用户自行承担,在适用法律允许的最大范围内,对因使用本产品所产生的损害及风险,包括但不限于直接或间接的个人损害、商业赢利的丧失、贸易中断、商业信息的丢失或任何其它经济损失,不承担任何责任。
* 本软件不会未经用户同意收集任何用户信息。
说明
==============
目前代码未开源,后续根据情况开源。

View File

@@ -7,7 +7,11 @@ SmartDNS是一个运行在本地的DNS服务器SmartDNS接受本地客户端
支持树莓派openwrt华硕路由器等设备。
**阿里DNS**
软件效果展示
==============
**阿里DNS**
使用阿里DNS查询百度IP并检测结果。
```shell
pi@raspberrypi:~/code/smartdns_build $ nslookup www.baidu.com 223.5.5.5
Server: 223.5.5.5
@@ -38,8 +42,8 @@ PING 180.97.33.108 (180.97.33.108) 56(84) bytes of data.
rtt min/avg/max/mdev = 31.014/31.094/31.175/0.193 ms
```
**smartdns**
**smartdns**
使用阿里SmartDNS查询百度IP并检测结果。
```shell
pi@raspberrypi:~/code/smartdns_build $ nslookup www.baidu.com
Server: 192.168.1.1
@@ -121,32 +125,41 @@ rtt min/avg/max/mdev = 5.954/6.133/6.313/0.195 ms
|openwrt LEDE|smartdns.xxxxxxxxx.arm_cortex-a7_neon-vfpv4.ipk|支持arm A7核心CPU的路由器
|openwrt LUCI|luci-app-smartdns.xxxxxxxxx.xxxx.all.ipk|openwrt管理统一界面
openwrt系统CPU架构比较多请查看CPU架构后下载CPU架构可在路由器管理界面找到查看方法
openwrt系统CPU架构比较多上述表格未列出所有支持系统请查看CPU架构后下载。
CPU架构可在路由器管理界面找到查看方法
* 登录路由器,点击`System`->`Software`,点击`Configuration` Tab页面在opkg安装源中可找到对应软件架构下载路径中可找到如下架构为ar71xx
```
src/gz chaos_calmer_base http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/base
```
[此处下载](https://github.com/pymumu/smartdns/releases)
请在Release页面下载[此处下载](https://github.com/pymumu/smartdns/releases)
标准Linux系统安装树莓派
标准Linux系统安装树莓派, X86_64系统
--------------
1. 安装
下载配套安装包`smartdns.xxxxxxxx.armhf.deb`并上传到Linux系统中。 执行如下命令安装
```
dpkg -i smartdns.xxxxxxxx.armhf.deb
```
2. 修改配置
安装完成后可配置smartdns的上游服务器信息。具体配置参数参考`配置参数`说明。
一般情况下,只需要增加`server [IP]:port`, `server-tcp [IP]:port`配置项
尽可能配置多个上游DNS服务器包括国内外的服务器。
```
vi /etc/smartdns/smartdns.conf
```
3. 启动服务
```
systemctl enable smartdns
systemctl start smartdns
```
4. 将DNS请求转发的SmartDNS解析。
修改本地路由器的DNS服务器将DNS服务器配置为SmartDNS。
* 登录到本地网络的路由器中配置树莓派分配静态IP地址。
@@ -156,23 +169,22 @@ systemctl start smartdns
II. 华为等路由器可能不支持配置DNS为本地IP请修改PC端手机端DNS服务器为树莓派IP。
5. 检测服务是否配置成功。
使用nslookup查询域名,看命令结果中的`服务器`项目是否显示为`Linux主机名`如raspberry则表示生效
使用`nslookup -querytype=ptr 127.0.0.1`查询域名
看命令结果中的`name`项目是否显示为`smartdns``主机名`,如`smartdns`则表示生效
```
C:\Users\meikechong>nslookup www.baidu.com
服务器: raspberry
Address: 192.168.1.1
非权威应答:
名称: www.a.shifen.com
Address: 14.215.177.39
Aliases: www.baidu.com
pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 127.0.0.1
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
1.0.0.127.in-addr.arpa name = smartdns.
```
openwrt/LEDE
--------------
1. 安装
将软件使用winscp上传到路由器的/root目录执行如下命令安装
将软件使用winscp上传到路由器的/root目录执行如下命令安装
```
opkg install smartdns.xxxxxxxx.xxxx.ipk
@@ -187,17 +199,17 @@ opkg install luci-app-smartdns.xxxxxxxx.xxxx.all.ipk
3. 启动服务
勾选配置页面中的`Enable(启用)`来启动SmartDNS
4. 检测服务是否配置成功
使用nslookup查询域名,看命令结果中的`服务器`项目是否显示为`Linux主机名`,如`smartdns`则表示生效
4. 检测服务是否配置成功
使用`nslookup -querytype=ptr 127.0.0.1`查询域名
看命令结果中的`name`项目是否显示为`smartdns``主机名`,如`smartdns`则表示生效
```
C:\Users\meikechong>nslookup www.baidu.com
服务器: smartdns
Address: 192.168.1.1
非权威应答:
名称: www.a.shifen.com
Address: 14.215.177.39
Aliases: www.baidu.com
pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 127.0.0.1
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
1.0.0.127.in-addr.arpa name = smartdns.
```
5. 注意:
@@ -214,31 +226,31 @@ Aliases: www.baidu.com
登录管理界面,点击`系统管理`->点击`系统设置`,配置`Enable SSH``Lan Only`
SSH登录用户名密码与管理界面相同。
2. 下载`Download Master`
2. 下载`Download Master`
在管理界面点击`USB相关应用`->点击`Download Master`下载。
下载完成后,启用`Download Master`,如果不需要下载功能,此处可以卸载`Download Master`但要保证卸载前Download Master是启用的。
3. 安装SmartDNS
将软件使用winscp上传到路由器的`/tmp/mnt/sda1`目录。或网上邻居复制到sda1共享目录
3. 安装SmartDNS
将软件使用winscp上传到路由器的`/tmp/mnt/sda1`目录。或网上邻居复制到sda1共享目录
```
ipkg install smartdns.xxxxxxx.mipsbig.ipk
```
4. 重启路由器生效服务
待路由器启动后使用nslookup查询域名,看命令结果中的`服务器`项目是否显示为`smartdns`如显示smartdns则表示生效
4. 重启路由器生效服务
待路由器启动后,使用`nslookup -querytype=ptr 127.0.0.1`查询域名
看命令结果中的`name`项目是否显示为`smartdns``主机名`,如`smartdns`则表示生效
```
C:\Users\meikechong>nslookup www.baidu.com
服务器: smartdns
Address: 192.168.1.1
非权威应答:
名称: www.a.shifen.com
Address: 14.215.177.39
Aliases: www.baidu.com
pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 127.0.0.1
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
1.0.0.127.in-addr.arpa name = smartdns.
```
5. 额外说明
5. 额外说明
上述过程smartdns将安装到U盘根目录采用optware的模式运行。
其目录结构如下: 此处仅列出smartdns相关文件
@@ -289,7 +301,7 @@ vi /opt/etc/smartdns/smartdns.conf
|server-tcp|上游TCP DNS|无|[IP][:port],可重复| server-tcp 8.8.8.8:53
|address|指定域名IP地址|无|address /domain/ip| address /www.example.com/1.2.3.4
[Donate](#Donate)
[Donate](#Donate)
==============
如果你觉得此项目对你有帮助,请捐助我们,以使项目能持续发展,更加完善。
* PayPal
@@ -301,6 +313,15 @@ vi /opt/etc/smartdns/smartdns.conf
* Wechat 微信
![wechat](doc/wechat_donate.jpg)
声明
==============
* `SmartDNS`著作权归属Nick Peng (pymumu at gmail.com)。
* `SmartDNS`为免费软件,用户可以非商业性地复制和使用`SmartDNS`
* 禁止将 `SmartDNS` 用于商业用途。
* 使用本软件的风险由用户自行承担,在适用法律允许的最大范围内,对因使用本产品所产生的损害及风险,包括但不限于直接或间接的个人损害、商业赢利的丧失、贸易中断、商业信息的丢失或任何其它经济损失,不承担任何责任。
* 本软件不会未经用户同意收集任何用户信息。
说明
==============
目前代码未开源,后续根据情况开源。

View File

@@ -8,7 +8,18 @@ function index()
end
local page
page = entry({"admin", "services", "smartdns"}, cbi("smartdns"), _("SmartDNS"), 60)
page.dependent = true
page = entry({"admin", "services", "smartdns", "status"}, call("act_status"))
page.leaf = true
end
local function is_running()
return luci.sys.call("pidof smartdns >/dev/null") == 0
end
function act_status()
local e={}
e.running = is_running()
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@@ -4,6 +4,15 @@ msgstr "Content-Type: text/plain; charset=UTF-8\n"
msgid "SmartDNS"
msgstr "SmartDNS"
msgid "SmartDNS is a local high-performance DNS server"
msgstr "SmartDNS是一个本地高性能DNS服务器"
msgid "SmartDNS Server"
msgstr "SmartDNS 服务器"
msgid "SmartDNS is a local high-performance DNS server, supports finding fastest IP, supports ad filtering, and supports avoiding DNS poisoning."
msgstr "SmartDNS是一个本地高性能DNS服务器支持避免域名污染支持返回最快IP支持广告过滤。"
msgid "Server Name"
msgstr "服务器名称"
@@ -22,8 +31,8 @@ msgstr "SmartDNS本地服务端口"
msgid "Redirect"
msgstr "重定向"
msgid "Redirect standard dns query from 53 to smartdns"
msgstr "将53端口的DNS请求重定向到SmartDNS"
msgid "Redirect standard dns query from 53 to smartdns, as default DNS server"
msgstr "将53端口的DNS请求重定向到SmartDNS, 替换默认DNS服务"
msgid "Cache Size"
msgstr "缓存大小"

View File

@@ -1,16 +1,15 @@
-- Copyright 2018 Nick Peng (pymumu@gmail.com)
require("nixio.fs")
require("luci.http")
require ("nixio.fs")
require ("luci.http")
require ("luci.dispatcher")
require ("nixio.fs")
m = Map("smartdns", translate("SmartDNS"),
translate("SmartDNS is a local dns server to find fastest ip."))
m = Map("smartdns")
m.title = translate("SmartDNS Server")
m.description = translate("SmartDNS is a local high-performance DNS server, supports finding fastest IP, supports ad filtering, and supports avoiding DNS poisoning.")
if luci.sys.call("pidof smartdns >/dev/null") == 0 then
m = Map("smartdns", translate("SmartDNS"), "%s - %s" %{translate("SmartDNS"), translate("RUNNING")})
else
m = Map("smartdns", translate("SmartDNS"), "%s - %s" %{translate("SmartDNS"), translate("NOT RUNNING")})
end
m:section(SimpleSection).template = "smartdns/smartdns_status"
-- Basic
s = m:section(TypedSection, "smartdns", translate("Settings"), translate("General Settings"))
@@ -18,6 +17,7 @@ s.anonymous = true
---- Eanble
o = s:option(Flag, "enabled", translate("Enable"), translate("Enable or disable smartdns server"))
o.default = o.disabled
o.rempty = false
---- server name
@@ -33,10 +33,12 @@ o.default = 5353
o.datatype = "port"
o.rempty = false
o = s:option(Flag, "redirect", translate("Redirect"), translate("Redirect standard dns query from 53 to smartdns"))
o.default = true
o.placeholder = "1"
o.rempty = false
o = s:option(Flag, "redirect", translate("Redirect"), translate("Redirect standard dns query from 53 to smartdns, as default DNS server"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
---- cache-size
o = s:option(Value, "cache_size", translate("Cache Size"), translate("DNS domain result cache size"))

View File

@@ -0,0 +1,22 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "smartdns", "status")%>', null,
function(x, data) {
var tb = document.getElementById('smartdns_status');
if (data && tb) {
if (data.running) {
var links = '<b><font color=green>SmartDNS - <%:RUNNING%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<b><font color=red>SmartDNS - <%:NOT RUNNING%></font></b>';
}
}
}
);
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="smartdns_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@@ -1,2 +1,3 @@
config 'smartdns'
option 'enabled' '0'
option 'enabled' '0'

View File

@@ -2,10 +2,10 @@
BIN=smartdns
OBJS_LIB=lib/rbtree.o lib/art.o lib/bitops.o
OBJS=smartdns.o fast_ping.o dns_client.o dns_server.o dns.o util.o tlog.o conf.o dns_cache.o $(OBJS_LIB)
CFLAGS=-g -O0 -Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing
CFLAGS=-O2 -Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing
CFLAGS +=-Iinclude
CFLAGS += -DBASE_FILE_NAME=\"$(notdir $<)\"
CXXFLAGS=-g -O0 -Wall -std=c++11
CXXFLAGS=-O2 -Wall -std=c++11
CXXFLAGS +=-Iinclude
LDFLAGS += -lpthread

View File

@@ -38,7 +38,7 @@ int config_bind(char *value)
int config_server_name(char *value)
{
strncpy(dns_conf_server_name, value, DNS_MAX_CNAME_LEN);
strncpy(dns_conf_server_name, value, DNS_MAX_CONF_CNAME_LEN);
return 0;
}