Skip to content

Commit

Permalink
add the pdnsd to avoid the dns error
Browse files Browse the repository at this point in the history
  • Loading branch information
roubo committed Oct 14, 2014
1 parent 2f3b295 commit 703727d
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ modouSS
* 实现透明代理(全局代理)
* 默认将部分国内ip添加到白名单,访问国内网站和看国内视频正常
* 魔豆屏幕配置账号密码
* 加入pdnsd,避免dns污染问题

## 缺陷

* 屏幕上输入密码会比较难受,如果密码复杂的话
* 受国内dns污染的影响,个人用户访问特殊网站会有问题
Binary file added bin/pdnsd
Binary file not shown.
3 changes: 3 additions & 0 deletions conf/dnsmasq/dropbox.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
server=/.dropbox.com/127.0.0.1#5353
server=/.dropboxusercontent.com/127.0.0.1#5353
server=/.dropbox.co/127.0.0.1#5353
5 changes: 5 additions & 0 deletions conf/dnsmasq/facebook.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
server=/.facebook.com/127.0.0.1#5353
server=/.fbcdn.net/127.0.0.1#5353
server=/.tfbnw.net/127.0.0.1#5353
server=/.akamaihd.net/127.0.0.1#5353
server=/.thefacebook.com/127.0.0.1#5353
7 changes: 7 additions & 0 deletions conf/dnsmasq/twitter.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
server=/.twitter.com/127.0.0.1#5353
server=/t.co/127.0.0.1#5353
server=/.tweetdeck.com/127.0.0.1#5353
server=/.twimg.com/127.0.0.1#5353
server=/.tinypic.com/127.0.0.1#5353
server=/.twitpic.com/127.0.0.1#5353

3 changes: 3 additions & 0 deletions conf/dnsmasq/youtube.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
server=/.youtube.com/127.0.0.1#5353
server=/.googlevideo.com/127.0.0.1#5353
server=/.ytimg.com/127.0.0.1#5353
18 changes: 18 additions & 0 deletions conf/pdnsd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
global {
perm_cache=1024;
cache_dir=/var;
run_as=matrix;
server_port = 5353;
server_ip = 127.0.0.1;
status_ctl = on;
query_method=tcp_only;
min_ttl=15m;
max_ttl=1w;
timeout=10;
}
server {
label= googledns;
ip = 8.8.8.8;
root_server = on;
uptest = none;
}
8 changes: 0 additions & 8 deletions init
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ usage()
echo "example: $0 start"
}


install()
{
# to tp
Expand All @@ -34,7 +33,6 @@ install()
return 0;
}


uninstall()
{
#rm /lib/libgcc_s.so.1 2>/dev/null
Expand All @@ -43,36 +41,30 @@ uninstall()
return 0;
}


stop()
{
$CURDIR/sbin/ss.sh stop
return 0;
}


start()
{
#ln -s $CURDIR/lib/libgcc_s.so.1 /lib/libgcc_s.so.1 2>/dev/null
$CURDIR/sbin/ss.sh start
return 0;
}


status()
{
echo "Hello, modou";
return 0;
}


config()
{
echo "Hello, modou"
return 0;
}


# main
if [ $# -lt 1 ]; then
usage init
Expand Down
Binary file modified res/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/picon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions sbin/ss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
CURWDIR=$(cd $(dirname $0) && pwd) CUSTOMCONF="$CURWDIR/../conf/custom.conf"
SETCONFDEF="$CURWDIR/../conf/set.def"
SETCONF="$CURWDIR/../conf/set.conf"
PDNSDCONFILE="$CURWDIR/../conf/pdnsd.conf"
PIDFILE="$CURWDIR/../conf/custom.pid"
SSBIN="$CURWDIR/../bin/ss-redir"
SSSHELL="$CURWDIR/../sbin/ss-transp.sh "
PDNSDBIN="$CURWDIR/../bin/pdnsd"
DNSMASQCONF="/system/conf/dnsmasq.conf"
PDNSDCONF="conf-dir=$CURWDIR/../conf/dnsmasq";

CMDHEAD='"cmd":"'
CMDTAIL='",'
Expand All @@ -16,6 +20,48 @@ CMDBUTTON1=${CMDHEAD}${SHELLBUTTON1}${CMDTAIL};
CMDBUTTON2=${CMDHEAD}${SHELLBUTTON2}${CMDTAIL};
CMDBUTTON22=${CMDHEAD}${SHELLBUTTON22}${CMDTAIL};

## add the change of dnsmasq conf for pdnsd
## fork from HDNS
delConfDir() {
/system/sbin/writesys.sh
local pdnsddir=`echo "$CURWDIR/../conf/dnsmasq" | sed -e 's:/:\\\\/:g'`
/bin/sed -ie "/conf-dir=$pdnsddir/d" $DNSMASQCONF 1>/dev/null 2>&1
/system/sbin/writesys.sh close
}

addConfDir() {
/system/sbin/writesys.sh
local pdnsddir=`echo "$CURWDIR/../conf/dnsmasq" | sed -e 's:/:\\\\/:g'`
/bin/sed -ie "/conf-dir=$pdnsddir/d" $DNSMASQCONF 1>/dev/null 2>&1
echo $PDNSDCONF >> $DNSMASQCONF
/system/sbin/writesys.sh close
}

dnsStop() {
pid=`/bin/ps|grep dnsmasq|grep -v grep|awk '{print $1}'`
if [ "$pid" != "" ]; then
/bin/kill $pid 1>/dev/null 2>&1
else
/usr/bin/killall dnsmasq 1>/dev/null 2>&1
fi
}

dnsStart() {
dnsStop
/bin/dnsmasq -C "$DNSMASQCONF" &
}

pdnsdEnable() {
addConfDir
dnsStart
}

pdnsdDisable() {
delConfDir
killall pdnsd 1>/dev/null 2>&1
dnsStart
}

testServerStatus()
{
status=`ps | grep ss-redir | wc -l`
Expand Down Expand Up @@ -131,11 +177,14 @@ ssConfig()

ssStart()
{
pdnsdEnable;
serveraddr=`head -n 1 $SETCONF | cut -d ' ' -f2-`;
serverport=`head -n 2 $SETCONF | tail -n 1 | cut -d ' ' -f2-`;
secmode=`head -n 3 $SETCONF | tail -n 1 | cut -d ' ' -f2-`;
passwd=`head -n 4 $SETCONF | tail -n 1 | cut -d ' ' -f2-`;
$SSSHELL $serveraddr $serverport $secmode $passwd &
chown matrix $PDNSDCONFILE 1>/dev/null 2>&1
$PDNSDBIN -c $PDNSDCONFILE &
sleep 2
genCustomConfig;
pid=`cat $PIDFILE 2>/dev/null`;
Expand All @@ -145,6 +194,7 @@ ssStart()

ssStop()
{
pdnsdDisable;
killall ss-redir 1>/dev/null 2>&1;
iptables -t nat -F SHADOWSOCKS 1>/dev/null 2>&1
iptables -t nat -F OUTPUT 1>/dev/null 2>&1
Expand Down

0 comments on commit 703727d

Please sign in to comment.