Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.

Commit 9c1a787

Browse files
author
icymind
committed
add unbound
1 parent 9676578 commit 9c1a787

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/renderer/lib/openwrt.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,45 @@ class Openwrt {
212212
return this.execute(cmd)
213213
}
214214

215+
configUnbound (port = '5353', dnsServers = ['8.8.8.8', '8.8.4.4']) {
216+
let cfg = String.raw`
217+
server:
218+
port: ${port}
219+
outgoing-range: 60
220+
outgoing-num-tcp: 1
221+
incoming-num-tcp: 1
222+
msg-buffer-size: 8192
223+
msg-cache-size: 100k
224+
msg-cache-slabs: 1
225+
num-queries-per-thread: 30
226+
rrset-cache-size: 100k
227+
rrset-cache-slabs: 1
228+
infra-cache-slabs: 1
229+
infra-cache-numhosts: 200
230+
tcp-upstream: yes
231+
access-control: 0.0.0.0/0 allow
232+
access-control: ::0/0 allow
233+
username: ""
234+
pidfile: "/var/run/unbound.pid"
235+
root-hints: "/etc/unbound/named.cache"
236+
target-fetch-policy: "2 1 0 0 0 0"
237+
harden-short-bufsize: yes
238+
harden-large-queries: yes
239+
auto-trust-anchor-file: "/etc/unbound/root.key"
240+
key-cache-size: 100k
241+
key-cache-slabs: 1
242+
neg-cache-size: 10k
243+
forward-zone:
244+
name: "."
245+
forward-first: no
246+
`
247+
dnsServers.forEach(ip => {
248+
cfg += ` forward-addr: ${ip}`
249+
})
250+
const cmd = `echo ${cfg} > /etc/unbound/unbound.conf`
251+
return this.execute(cmd)
252+
}
253+
215254
// shadowsocks
216255
async installSs (targzFPath) {
217256
// need move out of asar file

src/renderer/lib/vrouter.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function installPackage (serialTcpPort, waitForOutput = 20000) {
9090
const subCmds = []
9191
subCmds.push(`sed -i 's/downloads.openwrt.org/mirrors.tuna.tsinghua.edu.cn\\/openwrt/g' /etc/opkg/distfeeds.conf`)
9292
subCmds.push('opkg update')
93-
subCmds.push('opkg remove dnsmasq && opkg install dnsmasq-full ipset openssh-sftp-server libopenssl rng-tools iptables-mod-tproxy ip')
93+
subCmds.push('opkg remove dnsmasq && opkg install dnsmasq-full ipset openssh-sftp-server libopenssl rng-tools iptables-mod-tproxy ip unbound')
9494
subCmds.push('/etc/init.d/dropbear restart')
9595
subCmds.push('echo "done" > /tmp/log/vrouter')
9696
const cmd = subCmds.join(' && ')
@@ -217,6 +217,9 @@ class VRouter extends Openwrt {
217217
process.emit('init', '配置 Dnsmasq')
218218
await this.configDnsmasq()
219219

220+
process.emit('init', '配置 unbound')
221+
await this.configUnbound()
222+
220223
process.emit('init', '修改虚拟机时区')
221224
await this.changeTZ(this.name)
222225

0 commit comments

Comments
 (0)