Sep 14

先看这个脚本:

#!/bin/bash
alias elog="logger -t $0 -s"
elog() {
    logger -t $0 -s "$@"
}
elog "hahahaha"
test123(){
    elog "i am in function!"
}
test123

运行后提示:

elog: command not found

如果换成 #!/bin/sh 则无问题:

#!/bin/sh
alias elog="logger -t $0 -s"
elog() {
    logger -t $0 -s "$@"
}
elog "hahahaha"
test123(){
    elog "i am in function!"
}
test123

执行后:

<13>Sep 14 11:59:48 /root/init.d/testme: hahahaha
<13>Sep 14 11:59:48 /root/init.d/testme: i am in function!

参考:Execute a passed alias inside a function?

Aliases are expanded when a command is read, not when it is executed. Therefore, an alias definition appearing on the same line as another command does not take effect until the next line of input is read. The commands following the alias definition on that line are not affected by the new alias. This behavior is also an issue when functions are executed. Aliases are expanded when a function definition is read, not when the function is executed, because a function definition is itself a compound command. As a consequence, aliases defined in a function are not available until after that function is executed. To be safe, always put alias definitions on a separate line, and do not use alias in compound commands.

修改为:(函数形式)

#!/bin/bash
elog() {
    logger -t $0 -s "$@"
}
elog "hahahaha"
test123(){
    elog "i am in function!"
}
test123

可行。 :roll: :roll: :roll:

再参考:Linux 环境中 alias 不生效问题

Tags: , , ,

Sep 13

Overture 自 1.5rc4 开始默认使用正则来匹配域名列表,这直接导致运行在路由器上的实例性能骤降。

以 Asus RT-AC68P 为例,在启用 gfwlistdnsmasq-china-list 后,使用默认的 regex-list 匹配方式:

"DomainFile": {
"Primary": "/opt/etc/chinalist",
"Alternative": "/opt/etc/gfwlist",
"Matcher": "regex-list"
}

查询境外网站的时间由几百毫秒(300~800ms)飙升到 1.2 秒,国内网站则因为有 chinaroute 的 IPNetworkFile 规则在先而不受影响。

把 Matcher 改为 "full-map", "suffix-tree", "full-list" (性能影响依次递增)可在单次 dig 查询下缓解这一现象,但是用 D-N-SPerf 做压力测试时,与取消 DomainFile.Matcher 相比,仍然急剧的体现出性能下降,Overture 的每秒查询能力由 300 次骤降到 40 次

所以在路由器上使用 Overture 1.5rc4+ 版本只做解毒用途,而且带机较多的情况下,建议关闭 DomainFile.Matcher,也就是把这两个文件置空。范例:(empty 为空文本文件)

"IPNetworkFile": {
"Primary": "/opt/etc/chinaroute",
"Alternative": "/opt/etc/empty"
},
"DomainFile": {
"Primary": "/opt/etc/empty",
"Alternative": "/opt/etc/empty",
"Matcher": "full-map"
}

2019-09-15 追加,暂时不要用 suffix-tree 匹配模式,有 Bug!无论域名文件是否为空,总会使用主 DNS 查询!

https://github.com/shawn1m/overture/issues/172


Sep 11

Tags:

Sep 09

DNS 搞对了速度还行,8K 也能看,CPU 是瓶颈了。

:oops: :oops: :oops:

Tags: , ,

Sep 09

小姑娘翻唱的不错,乐队,录音也都是一流。

HTML5 源生视频播放,rapidash.ccipfs.com 直链。

:cool: :cool: :cool:


[2/56]  < 1 2 3 4 5 6 7 8 9 10 > ... »