├── README.md ├── dnsmasq.conf ├── dnsmasq_sniproxy_all.sh ├── dnsmasq_sniproxy_disney.sh ├── dnsmasq_sniproxy_nr.sh ├── dnsmasq_sniproxy_tw.sh ├── dnsmasq_sniproxy_youtube.sh ├── proxy-domains-all.txt ├── proxy-domains-disney.txt ├── proxy-domains-nr.txt ├── proxy-domains-tw.txt ├── proxy-domains-youtube.txt ├── sniproxy.conf ├── sniproxy.default └── sniproxy ├── sniproxy-0.6.0.el6.x86_64.rpm ├── sniproxy-0.6.0.el7.x86_64.rpm ├── sniproxy-0.6.0.el8.x86_64.rpm ├── sniproxy_0.6.0_amd64.deb └── sniproxy_0.6.0_i386.deb /README.md: -------------------------------------------------------------------------------- 1 | # Dnsmasq SNIproxy One-click Install 2 | 3 | ## 脚本说明: 4 | 5 | * 原理简述:使用[Dnsmasq](http://thekelleys.org.uk/dnsmasq/doc.html)的DNS将网站解析劫持到[SNI proxy](https://github.com/dlundquist/sniproxy)反向代理的页面上。 6 | 7 | * 用途:让无法观看流媒体的VPS可以观看(前提:VPS中要有一个是能观看流媒体的)。 8 | 9 | * 特性: 10 | 11 | **1、完整版** 12 | 13 | 在原脚本基础上,增加了Youtube分流规则。 14 | 默认解锁`Netflix Hulu HBO DisneyPlus Youtube`[等](https://github.com/codionx/dnsmasq_sniproxy_install/blob/master/proxy-domains-all.txt) 15 | 16 | **2、宋仲基版** 17 | 18 | 修改了原脚本的规则,仅保留了Youtube分流规则,安装后供宋仲基使用。 19 | 20 | **3、台湾流媒体解锁版** 21 | 22 | 修改了原脚本的规则,增加了Dazn | Disney+ | Netflix | YouTube Premium | Amazon Prime Video | TVBAnywhere+ | Spotify | KKTV | LiTV | LineTV.TW | HBO | Bahamut | Bilibili国际 分流规则,安装后供台湾流媒体解锁使用。 23 | 24 | ***如果需要自定义*** 25 | 26 | 可Folk后,自行编辑proxy-domians相关文件。 27 | 28 | 或:安装后,修改`/etc/dnsmasq.d/custom_netflix.conf`和`/etc/sniproxy.conf` 29 | 30 | 31 | 32 | * 脚本支持系统:CentOS6+, Debian8+, Ubuntu16+ 33 | * CentOS6/7/8, Debian8/9/10, Ubuntu16/18 已测试成功 34 | * 理论上不限虚拟化类型,如有问题请反馈 35 | * 如果脚本最后显示的IP和实际公网IP不相符,请修改一下文件`/etc/sniproxy.conf`中的IP地址 36 | 37 |

38 | 39 | ## 脚本用法: 40 | 41 | bash dnsmasq_sniproxy.sh [-h] [-i] [-f] [-id] [-is] [-fs] [-u] [-ud] [-us] 42 | -h , --help 显示帮助信息 43 | -i , --install 安装 Dnsmasq + SNI Proxy 44 | -f , --fastinstall 快速安装 Dnsmasq + SNI Proxy 45 | -id, --installdnsmasq 仅安装 Dnsmasq 46 | -is, --installsniproxy 仅安装 SNI Proxy 47 | -fs, --fastinstallsniproxy 快速安装 SNI Proxy 48 | -u , --uninstall 卸载 Dnsmasq + SNI Proxy 49 | -ud, --undnsmasq 卸载 Dnsmasq 50 | -us, --unsniproxy 卸载 SNI Proxy 51 | 52 | ### 快速安装-完整版: 53 | ``` Bash 54 | wget --no-check-certificate -O dnsmasq_sniproxy_all.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_all.sh && bash dnsmasq_sniproxy_all.sh -f 55 | ``` 56 | ### 快速安装-宋仲基版: 57 | ``` Bash 58 | wget --no-check-certificate -O dnsmasq_sniproxy_youtube.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_youtube.sh && bash dnsmasq_sniproxy_youtube.sh -f 59 | ``` 60 | ### 快速安装-DisneyPlus版: 61 | ``` Bash 62 | wget --no-check-certificate -O dnsmasq_sniproxy_disney.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_disney.sh && bash dnsmasq_sniproxy_disney.sh -f 63 | ``` 64 | ### 快速安装-台湾流媒体版: 65 | ``` Bash 66 | wget --no-check-certificate -O dnsmasq_sniproxy_tw.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_tw.sh && bash dnsmasq_sniproxy_tw.sh -f 67 | ``` 68 | 69 | ### 快速安装-Nearouter香港版: 70 | ``` Bash 71 | wget --no-check-certificate -O dnsmasq_sniproxy_nr.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_nr.sh && bash dnsmasq_sniproxy_nr.sh -f 72 | ``` 73 | 74 | ### 普通安装-完整版: 75 | ``` Bash 76 | wget --no-check-certificate -O dnsmasq_sniproxy_all.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_all.sh && bash dnsmasq_sniproxy_all.sh -i 77 | ``` 78 | ### 普通安装-宋仲基版: 79 | ``` Bash 80 | wget --no-check-certificate -O dnsmasq_sniproxy_youtube.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_youtube.sh && bash dnsmasq_sniproxy_youtube.sh -i 81 | ``` 82 | 83 | ### 卸载-完整版: 84 | ``` Bash 85 | wget --no-check-certificate -O dnsmasq_sniproxy_all.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_all.sh && bash dnsmasq_sniproxy_all.sh -u 86 | ``` 87 | ### 卸载-宋仲基版: 88 | ``` Bash 89 | wget --no-check-certificate -O dnsmasq_sniproxy_youtube.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_youtube.sh && bash dnsmasq_sniproxy_youtube.sh -u 90 | ``` 91 | ### 卸载-Disney版: 92 | ``` Bash 93 | wget --no-check-certificate -O dnsmasq_sniproxy_disney.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_disney.sh && bash dnsmasq_sniproxy_disney.sh -u 94 | ``` 95 | ### 卸载-台湾流媒体版: 96 | ``` Bash 97 | wget --no-check-certificate -O dnsmasq_sniproxy_tw.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_tw.sh && bash dnsmasq_sniproxy_tw.sh -u 98 | ``` 99 | 100 | ### 卸载-Nearouter香港版: 101 | ``` Bash 102 | wget --no-check-certificate -O dnsmasq_sniproxy_nr.sh https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy_nr.sh && bash dnsmasq_sniproxy_nr.sh -u 103 | ``` 104 |

105 | ## 使用方法: 106 | 将代理VPS的DNS地址修改为这个主机的IP就可以了,如果不能用,记得只保留一个DNS地址试一下。 107 | 108 | 防止滥用,建议不要随意公布IP地址,或使用防火墙做好限制工作。 109 | 110 | ### 调试排错: 111 | - 确认sniproxy有效运行 112 | 113 | 查看sni状态:systemctl status sniproxy 114 | 115 | 如果sni不在运行,检查一下是否有其他服务占用80,443端口,以防端口冲突,先将其他服务更改一下监听端口,查看端口监听:netstat -tlunp|grep 443 116 | 117 | - 确认防火墙放行80,443,53 118 | 119 | 调试可直接关闭防火墙 systemctl stop firewalld.service 120 | 121 | 阿里云/谷歌云/AWS等运营商安全组端口同样需要放行 122 | 可通过其他服务器 telnet vpsip 53 以及 telnet vpsip 443 进行测试 123 | 124 | - 解析域名 125 | 126 | 尝试用其他服务器配置完毕dns后,解析域名:nslookup netflix.com 判断IP是否是NETFLIX代理机器IP 127 | 如果不存在nslookup命令,CENTOS安装:yum install -y bind-utils DEBIAN安装:apt-get -y install dnsutils 128 | 129 | --- 130 | 131 | ___本脚本仅限解锁流媒体使用___ 132 | -------------------------------------------------------------------------------- /dnsmasq.conf: -------------------------------------------------------------------------------- 1 | domain-needed 2 | bogus-priv 3 | no-resolv 4 | no-poll 5 | all-servers 6 | server=8.8.8.8 7 | server=1.1.1.1 8 | server=208.67.222.222 9 | server=4.2.2.1 10 | cache-size=2048 11 | local-ttl=60 12 | interface=* 13 | -------------------------------------------------------------------------------- /dnsmasq_sniproxy_all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | red='\033[0;31m' 6 | green='\033[0;32m' 7 | yellow='\033[0;33m' 8 | plain='\033[0m' 9 | 10 | [[ $EUID -ne 0 ]] && echo -e "[${red}Error${plain}] 请使用root用户来执行脚本!" && exit 1 11 | 12 | disable_selinux(){ 13 | if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then 14 | sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 15 | setenforce 0 16 | fi 17 | } 18 | 19 | check_sys(){ 20 | local checkType=$1 21 | local value=$2 22 | 23 | local release='' 24 | local systemPackage='' 25 | 26 | if [[ -f /etc/redhat-release ]]; then 27 | release="centos" 28 | systemPackage="yum" 29 | elif grep -Eqi "debian|raspbian" /etc/issue; then 30 | release="debian" 31 | systemPackage="apt" 32 | elif grep -Eqi "ubuntu" /etc/issue; then 33 | release="ubuntu" 34 | systemPackage="apt" 35 | elif grep -Eqi "centos|red hat|redhat" /etc/issue; then 36 | release="centos" 37 | systemPackage="yum" 38 | elif grep -Eqi "debian|raspbian" /proc/version; then 39 | release="debian" 40 | systemPackage="apt" 41 | elif grep -Eqi "ubuntu" /proc/version; then 42 | release="ubuntu" 43 | systemPackage="apt" 44 | elif grep -Eqi "centos|red hat|redhat" /proc/version; then 45 | release="centos" 46 | systemPackage="yum" 47 | fi 48 | 49 | if [[ "${checkType}" == "sysRelease" ]]; then 50 | if [ "${value}" == "${release}" ]; then 51 | return 0 52 | else 53 | return 1 54 | fi 55 | elif [[ "${checkType}" == "packageManager" ]]; then 56 | if [ "${value}" == "${systemPackage}" ]; then 57 | return 0 58 | else 59 | return 1 60 | fi 61 | fi 62 | } 63 | 64 | getversion(){ 65 | if [[ -s /etc/redhat-release ]]; then 66 | grep -oE "[0-9.]+" /etc/redhat-release 67 | else 68 | grep -oE "[0-9.]+" /etc/issue 69 | fi 70 | } 71 | 72 | centosversion(){ 73 | if check_sys sysRelease centos; then 74 | local code=$1 75 | local version="$(getversion)" 76 | local main_ver=${version%%.*} 77 | if [ "$main_ver" == "$code" ]; then 78 | return 0 79 | else 80 | return 1 81 | fi 82 | else 83 | return 1 84 | fi 85 | } 86 | 87 | get_ip(){ 88 | local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 ) 89 | [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com ) 90 | [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip ) 91 | echo ${IP} 92 | } 93 | 94 | check_ip(){ 95 | local checkip=$1 96 | local valid_check=$(echo $checkip|awk -F. '$1<=255&&$2<=255&&$3<=255&&$4<=255{print "yes"}') 97 | if echo $checkip|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then 98 | if [ ${valid_check:-no} == "yes" ]; then 99 | return 0 100 | else 101 | echo -e "[${red}Error${plain}] IP $checkip not available!" 102 | return 1 103 | fi 104 | else 105 | echo -e "[${red}Error${plain}] IP format error!" 106 | return 1 107 | fi 108 | } 109 | 110 | download(){ 111 | local filename=${1} 112 | echo -e "[${green}Info${plain}] ${filename} download configuration now..." 113 | wget --no-check-certificate -q -t3 -T60 -O ${1} ${2} 114 | if [ $? -ne 0 ]; then 115 | echo -e "[${red}Error${plain}] Download ${filename} failed." 116 | exit 1 117 | fi 118 | } 119 | 120 | error_detect_depends(){ 121 | local command=$1 122 | local depend=`echo "${command}" | awk '{print $4}'` 123 | echo -e "[${green}Info${plain}] Starting to install package ${depend}" 124 | ${command} > /dev/null 2>&1 125 | if [ $? -ne 0 ]; then 126 | echo -e "[${red}Error${plain}] Failed to install ${red}${depend}${plain}" 127 | exit 1 128 | fi 129 | } 130 | 131 | config_firewall(){ 132 | if centosversion 6; then 133 | /etc/init.d/iptables status > /dev/null 2>&1 134 | if [ $? -eq 0 ]; then 135 | for port in ${ports}; do 136 | iptables -L -n | grep -i ${port} > /dev/null 2>&1 137 | if [ $? -ne 0 ]; then 138 | iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${port} -j ACCEPT 139 | if [ ${port} == "53" ]; then 140 | iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${port} -j ACCEPT 141 | fi 142 | else 143 | echo -e "[${green}Info${plain}] port ${green}${port}${plain} already be enabled." 144 | fi 145 | done 146 | /etc/init.d/iptables save 147 | /etc/init.d/iptables restart 148 | else 149 | echo -e "[${yellow}Warning${plain}] iptables looks like not running or not installed, please enable port ${ports} manually if necessary." 150 | fi 151 | elif centosversion 7 || centosversion 8; then 152 | systemctl status firewalld > /dev/null 2>&1 153 | if [ $? -eq 0 ]; then 154 | default_zone=$(firewall-cmd --get-default-zone) 155 | for port in ${ports}; do 156 | firewall-cmd --permanent --zone=${default_zone} --add-port=${port}/tcp 157 | if [ ${port} == "53" ]; then 158 | firewall-cmd --permanent --zone=${default_zone} --add-port=${port}/udp 159 | fi 160 | firewall-cmd --reload 161 | done 162 | else 163 | echo -e "[${yellow}Warning${plain}] firewalld looks like not running or not installed, please enable port ${ports} manually if necessary." 164 | fi 165 | fi 166 | } 167 | 168 | install_dependencies(){ 169 | echo "安装依赖软件..." 170 | if check_sys packageManager yum; then 171 | echo -e "[${green}Info${plain}] Checking the EPEL repository..." 172 | if [ ! -f /etc/yum.repos.d/epel.repo ]; then 173 | yum install -y epel-release > /dev/null 2>&1 174 | fi 175 | [ ! -f /etc/yum.repos.d/epel.repo ] && echo -e "[${red}Error${plain}] Install EPEL repository failed, please check it." && exit 1 176 | [ ! "$(command -v yum-config-manager)" ] && yum install -y yum-utils > /dev/null 2>&1 177 | [ x"$(yum-config-manager epel | grep -w enabled | awk '{print $3}')" != x"True" ] && yum-config-manager --enable epel > /dev/null 2>&1 178 | echo -e "[${green}Info${plain}] Checking the EPEL repository complete..." 179 | 180 | if [[ ${fastmode} = "1" ]]; then 181 | yum_depends=( 182 | curl gettext-devel libev-devel pcre-devel perl udns-devel 183 | ) 184 | else 185 | yum_depends=( 186 | wget git autoconf automake curl gettext-devel libev-devel pcre-devel perl pkgconfig rpm-build udns-devel 187 | ) 188 | fi 189 | for depend in ${yum_depends[@]}; do 190 | error_detect_depends "yum -y install ${depend}" 191 | done 192 | if [[ ${fastmode} = "0" ]]; then 193 | if centosversion 6; then 194 | error_detect_depends "yum -y groupinstall development" 195 | error_detect_depends "yum -y install centos-release-scl" 196 | error_detect_depends "yum -y install devtoolset-6-gcc-c++" 197 | elif centosversion 7 || centosversion 8; then 198 | yum groups list development | grep Installed > /dev/null 2>&1 199 | if [[ $? -eq 0 ]]; then 200 | yum groups mark remove development -y > /dev/null 2>&1 201 | fi 202 | error_detect_depends "yum -y groupinstall development" 203 | fi 204 | fi 205 | elif check_sys packageManager apt; then 206 | if [[ ${fastmode} = "1" ]]; then 207 | apt_depends=( 208 | curl gettext libev-dev libpcre3-dev libudns-dev 209 | ) 210 | else 211 | apt_depends=( 212 | wget git autotools-dev cdbs debhelper dh-autoreconf dpkg-dev gettext libev-dev libpcre3-dev libudns-dev pkg-config fakeroot devscripts 213 | ) 214 | fi 215 | apt-get -y update 216 | for depend in ${apt_depends[@]}; do 217 | error_detect_depends "apt-get -y install ${depend}" 218 | done 219 | if [[ ${fastmode} = "0" ]]; then 220 | error_detect_depends "apt-get -y install build-essential" 221 | fi 222 | fi 223 | } 224 | 225 | install_dnsmasq(){ 226 | netstat -a -n -p | grep LISTEN | grep -P "\d+\.\d+\.\d+\.\d+:53\s+" > /dev/null && echo -e "[${red}Error${plain}] required port 53 already in use\n" && exit 1 227 | echo "安装Dnsmasq..." 228 | if check_sys packageManager yum; then 229 | error_detect_depends "yum -y install dnsmasq" 230 | if centosversion 6; then 231 | error_detect_depends "yum -y install make" 232 | error_detect_depends "yum -y install gcc-c++" 233 | cd /tmp/ 234 | if [ -e dnsmasq-2.80 ]; then 235 | rm -rf dnsmasq-2.80 236 | fi 237 | download dnsmasq-2.80.tar.gz http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.80.tar.gz 238 | tar -zxf dnsmasq-2.80.tar.gz 239 | cd dnsmasq-2.80 240 | make 241 | if [ $? -ne 0 ]; then 242 | echo -e "[${red}Error${plain}] dnsmasq upgrade failed." 243 | rm -rf /tmp/dnsmasq-2.80 /tmp/dnsmasq-2.80.tar.gz 244 | exit 1 245 | fi 246 | yes|cp -f /tmp/dnsmasq-2.80/src/dnsmasq /usr/sbin/dnsmasq && chmod 755 /usr/sbin/dnsmasq 247 | fi 248 | elif check_sys packageManager apt; then 249 | error_detect_depends "apt-get -y install dnsmasq" 250 | fi 251 | [ ! -f /usr/sbin/dnsmasq ] && echo -e "[${red}Error${plain}] 安装dnsmasq出现问题,请检查." && exit 1 252 | download /etc/dnsmasq.d/custom_netflix.conf https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq.conf 253 | download /tmp/proxy-domains-all.txt https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/proxy-domains-all.txt 254 | for domain in $(cat /tmp/proxy-domains-all.txt); do 255 | printf "address=/${domain}/${publicip}\n"\ 256 | | tee -a /etc/dnsmasq.d/custom_netflix.conf > /dev/null 2>&1 257 | done 258 | [ "$(grep -x -E "(conf-dir=/etc/dnsmasq.d|conf-dir=/etc/dnsmasq.d,.bak|conf-dir=/etc/dnsmasq.d/,\*.conf|conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig)" /etc/dnsmasq.conf)" ] || echo -e "\nconf-dir=/etc/dnsmasq.d" >> /etc/dnsmasq.conf 259 | echo "启动 Dnsmasq 服务..." 260 | if check_sys packageManager yum; then 261 | if centosversion 6; then 262 | chkconfig dnsmasq on 263 | service dnsmasq start 264 | elif centosversion 7 || centosversion 8; then 265 | systemctl enable dnsmasq 266 | systemctl start dnsmasq 267 | fi 268 | elif check_sys packageManager apt; then 269 | systemctl enable dnsmasq 270 | systemctl restart dnsmasq 271 | fi 272 | cd /tmp 273 | rm -rf /tmp/dnsmasq-2.80 /tmp/dnsmasq-2.80.tar.gz /tmp/proxy-domains-all.txt 274 | echo -e "[${green}Info${plain}] dnsmasq install complete..." 275 | } 276 | 277 | install_sniproxy(){ 278 | for aport in 80 443; do 279 | netstat -a -n -p | grep LISTEN | grep -P "\d+\.\d+\.\d+\.\d+:${aport}\s+" > /dev/null && echo -e "[${red}Error${plain}] required port ${aport} already in use\n" && exit 1 280 | done 281 | install_dependencies 282 | echo "安装SNI Proxy..." 283 | if check_sys packageManager yum; then 284 | rpm -qa | grep sniproxy >/dev/null 2>&1 285 | if [ $? -eq 0 ]; then 286 | rpm -e sniproxy 287 | fi 288 | elif check_sys packageManager apt; then 289 | dpkg -s sniproxy >/dev/null 2>&1 290 | if [ $? -eq 0 ]; then 291 | dpkg -r sniproxy 292 | fi 293 | fi 294 | bit=`uname -m` 295 | cd /tmp 296 | if [[ ${fastmode} = "0" ]]; then 297 | if [ -e sniproxy ]; then 298 | rm -rf sniproxy 299 | fi 300 | git clone https://github.com/dlundquist/sniproxy.git 301 | cd sniproxy 302 | fi 303 | if check_sys packageManager yum; then 304 | if [[ ${fastmode} = "1" ]]; then 305 | if [[ ${bit} = "x86_64" ]]; then 306 | download /tmp/sniproxy-0.6.0.el7.x86_64.rpm https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy-0.6.0.el7.x86_64.rpm 307 | error_detect_depends "yum -y install /tmp/sniproxy-0.6.0.el7.x86_64.rpm" 308 | rm -rf /tmp/sniproxy-0.6.0.el7.x86_64.rpm 309 | else 310 | echo -e "${red}暂不支持${bit}内核,请使用编译模式安装!${plain}" && exit 1 311 | fi 312 | else 313 | ./autogen.sh && ./configure && make dist 314 | if centosversion 6; then 315 | scl enable devtoolset-6 'rpmbuild --define "_sourcedir `pwd`" --define "_topdir /tmp/sniproxy/rpmbuild" --define "debug_package %{nil}" -ba redhat/sniproxy.spec' 316 | elif centosversion 7 || centosversion 8; then 317 | sed -i "s/\%configure CFLAGS\=\"-I\/usr\/include\/libev\"/\%configure CFLAGS\=\"-fPIC -I\/usr\/include\/libev\"/" redhat/sniproxy.spec 318 | rpmbuild --define "_sourcedir `pwd`" --define "_topdir /tmp/sniproxy/rpmbuild" --define "debug_package %{nil}" -ba redhat/sniproxy.spec 319 | fi 320 | error_detect_depends "yum -y install /tmp/sniproxy/rpmbuild/RPMS/x86_64/sniproxy-*.rpm" 321 | fi 322 | download /etc/init.d/sniproxy https://raw.githubusercontent.com/dlundquist/sniproxy/master/redhat/sniproxy.init && chmod +x /etc/init.d/sniproxy 323 | elif check_sys packageManager apt; then 324 | if [[ ${fastmode} = "1" ]]; then 325 | if [[ ${bit} = "x86_64" ]]; then 326 | download /tmp/sniproxy_0.6.0_amd64.deb https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy_0.6.0_amd64.deb 327 | error_detect_depends "dpkg -i --no-debsig /tmp/sniproxy_0.6.0_amd64.deb" 328 | rm -rf /tmp/sniproxy_0.6.0_amd64.deb 329 | elif [[ ${bit} = "i386" ]]; then 330 | download /tmp/sniproxy_0.6.0_i386.deb https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy_0.6.0_i386.deb 331 | error_detect_depends "dpkg -i --no-debsig /tmp/sniproxy_0.6.0_i386.deb" 332 | rm -rf /tmp/sniproxy_0.6.0_i386.deb 333 | else 334 | echo -e "${red}暂不支持${bit}内核,请使用编译模式安装!${plain}" && exit 1 335 | fi 336 | else 337 | ./autogen.sh && dpkg-buildpackage 338 | error_detect_depends "dpkg -i --no-debsig ../sniproxy_*.deb" 339 | rm -rf /tmp/sniproxy*.deb 340 | fi 341 | download /etc/init.d/sniproxy https://raw.githubusercontent.com/dlundquist/sniproxy/master/debian/init.d && chmod +x /etc/init.d/sniproxy 342 | download /etc/default/sniproxy https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/sniproxy.default 343 | fi 344 | [ ! -f /usr/sbin/sniproxy ] && echo -e "[${red}Error${plain}] 安装Sniproxy出现问题,请检查." && exit 1 345 | [ ! -f /etc/init.d/sniproxy ] && echo -e "[${red}Error${plain}] 下载Sniproxy启动文件出现问题,请检查." && exit 1 346 | download /etc/sniproxy.conf https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/sniproxy.conf 347 | download /tmp/sniproxy-domains.txt https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/proxy-domains-all.txt 348 | sed -i -e 's/\./\\\./g' -e 's/^/ \.\*/' -e 's/$/\$ \*/' /tmp/sniproxy-domains.txt || (echo -e "[${red}Error:${plain}] Failed to configuration sniproxy." && exit 1) 349 | sed -i '/table {/r /tmp/sniproxy-domains.txt' /etc/sniproxy.conf || (echo -e "[${red}Error:${plain}] Failed to configuration sniproxy." && exit 1) 350 | if [ ! -e /var/log/sniproxy ]; then 351 | mkdir /var/log/sniproxy 352 | fi 353 | echo "启动 SNI Proxy 服务..." 354 | if check_sys packageManager yum; then 355 | if centosversion 6; then 356 | chkconfig sniproxy on > /dev/null 2>&1 357 | service sniproxy start || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 358 | elif centosversion 7 || centosversion 8; then 359 | systemctl enable sniproxy > /dev/null 2>&1 360 | systemctl start sniproxy || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 361 | fi 362 | elif check_sys packageManager apt; then 363 | systemctl daemon-reload 364 | systemctl enable sniproxy > /dev/null 2>&1 365 | systemctl restart sniproxy || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 366 | fi 367 | cd /tmp 368 | rm -rf /tmp/sniproxy/ 369 | rm -rf /tmp/sniproxy-domains.txt 370 | echo -e "[${green}Info${plain}] sniproxy install complete..." 371 | } 372 | 373 | install_check(){ 374 | if check_sys packageManager yum || check_sys packageManager apt; then 375 | if centosversion 5; then 376 | return 1 377 | fi 378 | return 0 379 | else 380 | return 1 381 | fi 382 | } 383 | 384 | ready_install(){ 385 | echo "检测您的系統..." 386 | if ! install_check; then 387 | echo -e "[${red}Error${plain}] Your OS is not supported to run it!" 388 | echo -e "Please change to CentOS 6+/Debian 8+/Ubuntu 16+ and try again." 389 | exit 1 390 | fi 391 | if check_sys packageManager yum; then 392 | error_detect_depends "yum -y install net-tools" 393 | elif check_sys packageManager apt; then 394 | error_detect_depends "apt-get -y install net-tools" 395 | fi 396 | disable_selinux 397 | if check_sys packageManager yum; then 398 | config_firewall 399 | fi 400 | echo -e "[${green}Info${plain}] Checking the system complete..." 401 | } 402 | 403 | hello(){ 404 | echo "" 405 | echo -e "${yellow}Dnsmasq + SNI Proxy自助安装脚本${plain}" 406 | echo -e "${yellow}支持系统: CentOS 6+, Debian8+, Ubuntu16+${plain}" 407 | echo "" 408 | } 409 | 410 | help(){ 411 | hello 412 | echo "使用方法:bash $0 [-h] [-i] [-f] [-id] [-is] [-fs] [-u] [-ud] [-us]" 413 | echo "" 414 | echo " -h , --help 显示帮助信息" 415 | echo " -i , --install 安装 Dnsmasq + SNI Proxy" 416 | echo " -f , --fastinstall 快速安装 Dnsmasq + SNI Proxy" 417 | echo " -id, --installdnsmasq 仅安装 Dnsmasq" 418 | echo " -is, --installsniproxy 仅安装 SNI Proxy" 419 | echo " -fs, --fastinstallsniproxy 快速安装 SNI Proxy" 420 | echo " -u , --uninstall 卸载 Dnsmasq + SNI Proxy" 421 | echo " -ud, --undnsmasq 卸载 Dnsmasq" 422 | echo " -us, --unsniproxy 卸载 SNI Proxy" 423 | echo "" 424 | } 425 | 426 | install_all(){ 427 | ports="53 80 443" 428 | publicip=$(get_ip) 429 | hello 430 | ready_install 431 | install_dnsmasq 432 | install_sniproxy 433 | echo "" 434 | echo -e "${yellow}Dnsmasq + SNI Proxy 已完成安装!${plain}" 435 | echo "" 436 | echo -e "${yellow}将您的DNS更改为 $(get_ip) 即可以观看Netflix节目了。${plain}" 437 | echo "" 438 | } 439 | 440 | only_dnsmasq(){ 441 | ports="53" 442 | hello 443 | ready_install 444 | inputipcount=1 445 | echo -e "请输入SNIProxy服务器的IP地址" 446 | read -e -p "(默认为本机公网IP): " inputip 447 | while true; do 448 | if [ "${inputipcount}" == 3 ]; then 449 | echo -e "[${red}Error:${plain}] IP输入错误次数过多,请重新执行脚本。" 450 | exit 1 451 | fi 452 | if [ -z ${inputip} ]; then 453 | publicip=$(get_ip) 454 | break 455 | else 456 | check_ip ${inputip} 457 | if [ $? -eq 0 ]; then 458 | publicip=${inputip} 459 | break 460 | else 461 | echo -e "请重新输入SNIProxy服务器的IP地址" 462 | read -e -p "(默认为本机公网IP): " inputip 463 | fi 464 | fi 465 | inputipcount=`expr ${inputipcount} + 1` 466 | done 467 | install_dnsmasq 468 | echo "" 469 | echo -e "${yellow}Dnsmasq 已完成安装!${plain}" 470 | echo "" 471 | echo -e "${yellow}将您的DNS更改为 $(get_ip) 即可以观看Netflix节目了。${plain}" 472 | echo "" 473 | } 474 | 475 | only_sniproxy(){ 476 | ports="80 443" 477 | hello 478 | ready_install 479 | install_sniproxy 480 | echo "" 481 | echo -e "${yellow}SNI Proxy 已完成安装!${plain}" 482 | echo "" 483 | echo -e "${yellow}将Netflix的相关域名解析到 $(get_ip) 即可以观看Netflix节目了。${plain}" 484 | echo "" 485 | } 486 | 487 | undnsmasq(){ 488 | echo -e "[${green}Info${plain}] Stoping dnsmasq services." 489 | if check_sys packageManager yum; then 490 | if centosversion 6; then 491 | chkconfig dnsmasq off > /dev/null 2>&1 492 | service dnsmasq stop || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 493 | elif centosversion 7 || centosversion 8; then 494 | systemctl disable dnsmasq > /dev/null 2>&1 495 | systemctl stop dnsmasq || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 496 | fi 497 | elif check_sys packageManager apt; then 498 | systemctl disable dnsmasq > /dev/null 2>&1 499 | systemctl stop dnsmasq || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 500 | fi 501 | echo -e "[${green}Info${plain}] Starting to uninstall dnsmasq services." 502 | if check_sys packageManager yum; then 503 | yum remove dnsmasq -y > /dev/null 2>&1 504 | if [ $? -ne 0 ]; then 505 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}dnsmasq${plain}" 506 | fi 507 | elif check_sys packageManager apt; then 508 | apt-get remove dnsmasq -y > /dev/null 2>&1 509 | if [ $? -ne 0 ]; then 510 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}dnsmasq${plain}" 511 | fi 512 | fi 513 | rm -rf /etc/dnsmasq.d/custom_netflix.conf 514 | echo -e "[${green}Info${plain}] services uninstall dnsmasq complete..." 515 | } 516 | 517 | unsniproxy(){ 518 | echo -e "[${green}Info${plain}] Stoping sniproxy services." 519 | if check_sys packageManager yum; then 520 | if centosversion 6; then 521 | chkconfig sniproxy off > /dev/null 2>&1 522 | service sniproxy stop || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 523 | elif centosversion 7 || centosversion 8; then 524 | systemctl disable sniproxy > /dev/null 2>&1 525 | systemctl stop sniproxy || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 526 | fi 527 | elif check_sys packageManager apt; then 528 | systemctl disable sniproxy > /dev/null 2>&1 529 | systemctl stop sniproxy || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 530 | fi 531 | echo -e "[${green}Info${plain}] Starting to uninstall sniproxy services." 532 | if check_sys packageManager yum; then 533 | yum remove sniproxy -y > /dev/null 2>&1 534 | if [ $? -ne 0 ]; then 535 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}sniproxy${plain}" 536 | fi 537 | elif check_sys packageManager apt; then 538 | apt-get remove sniproxy -y > /dev/null 2>&1 539 | if [ $? -ne 0 ]; then 540 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}sniproxy${plain}" 541 | fi 542 | fi 543 | rm -rf /etc/sniproxy.conf 544 | echo -e "[${green}Info${plain}] services uninstall sniproxy complete..." 545 | } 546 | 547 | confirm(){ 548 | echo -e "${yellow}是否继续执行?(n:取消/y:继续)${plain}" 549 | read -e -p "(默认:取消): " selection 550 | [ -z "${selection}" ] && selection="n" 551 | if [ ${selection} != "y" ]; then 552 | exit 0 553 | fi 554 | } 555 | 556 | if [[ $# = 1 ]];then 557 | key="$1" 558 | case $key in 559 | -i|--install) 560 | fastmode=0 561 | install_all 562 | ;; 563 | -f|--fastinstall) 564 | fastmode=1 565 | install_all 566 | ;; 567 | -id|--installdnsmasq) 568 | fastmode=0 569 | only_dnsmasq 570 | ;; 571 | -is|--installsniproxy) 572 | fastmode=0 573 | only_sniproxy 574 | ;; 575 | -fs|--fastinstallsniproxy) 576 | fastmode=1 577 | only_sniproxy 578 | ;; 579 | -u|--uninstall) 580 | hello 581 | echo -e "${yellow}正在执行卸载Dnsmasq和SNI Proxy.${plain}" 582 | confirm 583 | undnsmasq 584 | unsniproxy 585 | ;; 586 | -ud|--undnsmasq) 587 | hello 588 | echo -e "${yellow}正在执行卸载Dnsmasq.${plain}" 589 | confirm 590 | undnsmasq 591 | ;; 592 | -us|--unsniproxy) 593 | hello 594 | echo -e "${yellow}正在执行卸载SNI Proxy.${plain}" 595 | confirm 596 | unsniproxy 597 | ;; 598 | -h|--help|*) 599 | help 600 | ;; 601 | esac 602 | else 603 | help 604 | fi 605 | -------------------------------------------------------------------------------- /dnsmasq_sniproxy_disney.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | red='\033[0;31m' 6 | green='\033[0;32m' 7 | yellow='\033[0;33m' 8 | plain='\033[0m' 9 | 10 | [[ $EUID -ne 0 ]] && echo -e "[${red}Error${plain}] 请使用root用户来执行脚本!" && exit 1 11 | 12 | disable_selinux(){ 13 | if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then 14 | sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 15 | setenforce 0 16 | fi 17 | } 18 | 19 | check_sys(){ 20 | local checkType=$1 21 | local value=$2 22 | 23 | local release='' 24 | local systemPackage='' 25 | 26 | if [[ -f /etc/redhat-release ]]; then 27 | release="centos" 28 | systemPackage="yum" 29 | elif grep -Eqi "debian|raspbian" /etc/issue; then 30 | release="debian" 31 | systemPackage="apt" 32 | elif grep -Eqi "ubuntu" /etc/issue; then 33 | release="ubuntu" 34 | systemPackage="apt" 35 | elif grep -Eqi "centos|red hat|redhat" /etc/issue; then 36 | release="centos" 37 | systemPackage="yum" 38 | elif grep -Eqi "debian|raspbian" /proc/version; then 39 | release="debian" 40 | systemPackage="apt" 41 | elif grep -Eqi "ubuntu" /proc/version; then 42 | release="ubuntu" 43 | systemPackage="apt" 44 | elif grep -Eqi "centos|red hat|redhat" /proc/version; then 45 | release="centos" 46 | systemPackage="yum" 47 | fi 48 | 49 | if [[ "${checkType}" == "sysRelease" ]]; then 50 | if [ "${value}" == "${release}" ]; then 51 | return 0 52 | else 53 | return 1 54 | fi 55 | elif [[ "${checkType}" == "packageManager" ]]; then 56 | if [ "${value}" == "${systemPackage}" ]; then 57 | return 0 58 | else 59 | return 1 60 | fi 61 | fi 62 | } 63 | 64 | getversion(){ 65 | if [[ -s /etc/redhat-release ]]; then 66 | grep -oE "[0-9.]+" /etc/redhat-release 67 | else 68 | grep -oE "[0-9.]+" /etc/issue 69 | fi 70 | } 71 | 72 | centosversion(){ 73 | if check_sys sysRelease centos; then 74 | local code=$1 75 | local version="$(getversion)" 76 | local main_ver=${version%%.*} 77 | if [ "$main_ver" == "$code" ]; then 78 | return 0 79 | else 80 | return 1 81 | fi 82 | else 83 | return 1 84 | fi 85 | } 86 | 87 | get_ip(){ 88 | local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 ) 89 | [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com ) 90 | [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip ) 91 | echo ${IP} 92 | } 93 | 94 | check_ip(){ 95 | local checkip=$1 96 | local valid_check=$(echo $checkip|awk -F. '$1<=255&&$2<=255&&$3<=255&&$4<=255{print "yes"}') 97 | if echo $checkip|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then 98 | if [ ${valid_check:-no} == "yes" ]; then 99 | return 0 100 | else 101 | echo -e "[${red}Error${plain}] IP $checkip not available!" 102 | return 1 103 | fi 104 | else 105 | echo -e "[${red}Error${plain}] IP format error!" 106 | return 1 107 | fi 108 | } 109 | 110 | download(){ 111 | local filename=${1} 112 | echo -e "[${green}Info${plain}] ${filename} download configuration now..." 113 | wget --no-check-certificate -q -t3 -T60 -O ${1} ${2} 114 | if [ $? -ne 0 ]; then 115 | echo -e "[${red}Error${plain}] Download ${filename} failed." 116 | exit 1 117 | fi 118 | } 119 | 120 | error_detect_depends(){ 121 | local command=$1 122 | local depend=`echo "${command}" | awk '{print $4}'` 123 | echo -e "[${green}Info${plain}] Starting to install package ${depend}" 124 | ${command} > /dev/null 2>&1 125 | if [ $? -ne 0 ]; then 126 | echo -e "[${red}Error${plain}] Failed to install ${red}${depend}${plain}" 127 | exit 1 128 | fi 129 | } 130 | 131 | config_firewall(){ 132 | if centosversion 6; then 133 | /etc/init.d/iptables status > /dev/null 2>&1 134 | if [ $? -eq 0 ]; then 135 | for port in ${ports}; do 136 | iptables -L -n | grep -i ${port} > /dev/null 2>&1 137 | if [ $? -ne 0 ]; then 138 | iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${port} -j ACCEPT 139 | if [ ${port} == "53" ]; then 140 | iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${port} -j ACCEPT 141 | fi 142 | else 143 | echo -e "[${green}Info${plain}] port ${green}${port}${plain} already be enabled." 144 | fi 145 | done 146 | /etc/init.d/iptables save 147 | /etc/init.d/iptables restart 148 | else 149 | echo -e "[${yellow}Warning${plain}] iptables looks like not running or not installed, please enable port ${ports} manually if necessary." 150 | fi 151 | elif centosversion 7 || centosversion 8; then 152 | systemctl status firewalld > /dev/null 2>&1 153 | if [ $? -eq 0 ]; then 154 | default_zone=$(firewall-cmd --get-default-zone) 155 | for port in ${ports}; do 156 | firewall-cmd --permanent --zone=${default_zone} --add-port=${port}/tcp 157 | if [ ${port} == "53" ]; then 158 | firewall-cmd --permanent --zone=${default_zone} --add-port=${port}/udp 159 | fi 160 | firewall-cmd --reload 161 | done 162 | else 163 | echo -e "[${yellow}Warning${plain}] firewalld looks like not running or not installed, please enable port ${ports} manually if necessary." 164 | fi 165 | fi 166 | } 167 | 168 | install_dependencies(){ 169 | echo "安装依赖软件..." 170 | if check_sys packageManager yum; then 171 | echo -e "[${green}Info${plain}] Checking the EPEL repository..." 172 | if [ ! -f /etc/yum.repos.d/epel.repo ]; then 173 | yum install -y epel-release > /dev/null 2>&1 174 | fi 175 | [ ! -f /etc/yum.repos.d/epel.repo ] && echo -e "[${red}Error${plain}] Install EPEL repository failed, please check it." && exit 1 176 | [ ! "$(command -v yum-config-manager)" ] && yum install -y yum-utils > /dev/null 2>&1 177 | [ x"$(yum-config-manager epel | grep -w enabled | awk '{print $3}')" != x"True" ] && yum-config-manager --enable epel > /dev/null 2>&1 178 | echo -e "[${green}Info${plain}] Checking the EPEL repository complete..." 179 | 180 | if [[ ${fastmode} = "1" ]]; then 181 | yum_depends=( 182 | curl gettext-devel libev-devel pcre-devel perl udns-devel 183 | ) 184 | else 185 | yum_depends=( 186 | wget git autoconf automake curl gettext-devel libev-devel pcre-devel perl pkgconfig rpm-build udns-devel 187 | ) 188 | fi 189 | for depend in ${yum_depends[@]}; do 190 | error_detect_depends "yum -y install ${depend}" 191 | done 192 | if [[ ${fastmode} = "0" ]]; then 193 | if centosversion 6; then 194 | error_detect_depends "yum -y groupinstall development" 195 | error_detect_depends "yum -y install centos-release-scl" 196 | error_detect_depends "yum -y install devtoolset-6-gcc-c++" 197 | elif centosversion 7 || centosversion 8; then 198 | yum groups list development | grep Installed > /dev/null 2>&1 199 | if [[ $? -eq 0 ]]; then 200 | yum groups mark remove development -y > /dev/null 2>&1 201 | fi 202 | error_detect_depends "yum -y groupinstall development" 203 | fi 204 | fi 205 | elif check_sys packageManager apt; then 206 | if [[ ${fastmode} = "1" ]]; then 207 | apt_depends=( 208 | curl gettext libev-dev libpcre3-dev libudns-dev 209 | ) 210 | else 211 | apt_depends=( 212 | wget git autotools-dev cdbs debhelper dh-autoreconf dpkg-dev gettext libev-dev libpcre3-dev libudns-dev pkg-config fakeroot devscripts 213 | ) 214 | fi 215 | apt-get -y update 216 | for depend in ${apt_depends[@]}; do 217 | error_detect_depends "apt-get -y install ${depend}" 218 | done 219 | if [[ ${fastmode} = "0" ]]; then 220 | error_detect_depends "apt-get -y install build-essential" 221 | fi 222 | fi 223 | } 224 | 225 | install_dnsmasq(){ 226 | netstat -a -n -p | grep LISTEN | grep -P "\d+\.\d+\.\d+\.\d+:53\s+" > /dev/null && echo -e "[${red}Error${plain}] required port 53 already in use\n" && exit 1 227 | echo "安装Dnsmasq..." 228 | if check_sys packageManager yum; then 229 | error_detect_depends "yum -y install dnsmasq" 230 | if centosversion 6; then 231 | error_detect_depends "yum -y install make" 232 | error_detect_depends "yum -y install gcc-c++" 233 | cd /tmp/ 234 | if [ -e dnsmasq-2.80 ]; then 235 | rm -rf dnsmasq-2.80 236 | fi 237 | download dnsmasq-2.80.tar.gz http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.80.tar.gz 238 | tar -zxf dnsmasq-2.80.tar.gz 239 | cd dnsmasq-2.80 240 | make 241 | if [ $? -ne 0 ]; then 242 | echo -e "[${red}Error${plain}] dnsmasq upgrade failed." 243 | rm -rf /tmp/dnsmasq-2.80 /tmp/dnsmasq-2.80.tar.gz 244 | exit 1 245 | fi 246 | yes|cp -f /tmp/dnsmasq-2.80/src/dnsmasq /usr/sbin/dnsmasq && chmod 755 /usr/sbin/dnsmasq 247 | fi 248 | elif check_sys packageManager apt; then 249 | error_detect_depends "apt-get -y install dnsmasq" 250 | fi 251 | [ ! -f /usr/sbin/dnsmasq ] && echo -e "[${red}Error${plain}] 安装dnsmasq出现问题,请检查." && exit 1 252 | download /etc/dnsmasq.d/custom_netflix.conf https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq.conf 253 | download /tmp/proxy-domains-disney.txt https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/proxy-domains-disney.txt 254 | for domain in $(cat /tmp/proxy-domains-disney.txt); do 255 | printf "address=/${domain}/${publicip}\n"\ 256 | | tee -a /etc/dnsmasq.d/custom_netflix.conf > /dev/null 2>&1 257 | done 258 | [ "$(grep -x -E "(conf-dir=/etc/dnsmasq.d|conf-dir=/etc/dnsmasq.d,.bak|conf-dir=/etc/dnsmasq.d/,\*.conf|conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig)" /etc/dnsmasq.conf)" ] || echo -e "\nconf-dir=/etc/dnsmasq.d" >> /etc/dnsmasq.conf 259 | echo "启动 Dnsmasq 服务..." 260 | if check_sys packageManager yum; then 261 | if centosversion 6; then 262 | chkconfig dnsmasq on 263 | service dnsmasq start 264 | elif centosversion 7 || centosversion 8; then 265 | systemctl enable dnsmasq 266 | systemctl start dnsmasq 267 | fi 268 | elif check_sys packageManager apt; then 269 | systemctl enable dnsmasq 270 | systemctl restart dnsmasq 271 | fi 272 | cd /tmp 273 | rm -rf /tmp/dnsmasq-2.80 /tmp/dnsmasq-2.80.tar.gz /tmp/proxy-domains-disney.txt 274 | echo -e "[${green}Info${plain}] dnsmasq install complete..." 275 | } 276 | 277 | install_sniproxy(){ 278 | for aport in 80 443; do 279 | netstat -a -n -p | grep LISTEN | grep -P "\d+\.\d+\.\d+\.\d+:${aport}\s+" > /dev/null && echo -e "[${red}Error${plain}] required port ${aport} already in use\n" && exit 1 280 | done 281 | install_dependencies 282 | echo "安装SNI Proxy..." 283 | if check_sys packageManager yum; then 284 | rpm -qa | grep sniproxy >/dev/null 2>&1 285 | if [ $? -eq 0 ]; then 286 | rpm -e sniproxy 287 | fi 288 | elif check_sys packageManager apt; then 289 | dpkg -s sniproxy >/dev/null 2>&1 290 | if [ $? -eq 0 ]; then 291 | dpkg -r sniproxy 292 | fi 293 | fi 294 | bit=`uname -m` 295 | cd /tmp 296 | if [[ ${fastmode} = "0" ]]; then 297 | if [ -e sniproxy ]; then 298 | rm -rf sniproxy 299 | fi 300 | git clone https://github.com/dlundquist/sniproxy.git 301 | cd sniproxy 302 | fi 303 | if check_sys packageManager yum; then 304 | if [[ ${fastmode} = "1" ]]; then 305 | if [[ ${bit} = "x86_64" ]]; then 306 | download /tmp/sniproxy-0.6.0.el7.x86_64.rpm https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy-0.6.0.el7.x86_64.rpm 307 | error_detect_depends "yum -y install /tmp/sniproxy-0.6.0.el7.x86_64.rpm" 308 | rm -rf /tmp/sniproxy-0.6.0.el7.x86_64.rpm 309 | else 310 | echo -e "${red}暂不支持${bit}内核,请使用编译模式安装!${plain}" && exit 1 311 | fi 312 | else 313 | ./autogen.sh && ./configure && make dist 314 | if centosversion 6; then 315 | scl enable devtoolset-6 'rpmbuild --define "_sourcedir `pwd`" --define "_topdir /tmp/sniproxy/rpmbuild" --define "debug_package %{nil}" -ba redhat/sniproxy.spec' 316 | elif centosversion 7 || centosversion 8; then 317 | sed -i "s/\%configure CFLAGS\=\"-I\/usr\/include\/libev\"/\%configure CFLAGS\=\"-fPIC -I\/usr\/include\/libev\"/" redhat/sniproxy.spec 318 | rpmbuild --define "_sourcedir `pwd`" --define "_topdir /tmp/sniproxy/rpmbuild" --define "debug_package %{nil}" -ba redhat/sniproxy.spec 319 | fi 320 | error_detect_depends "yum -y install /tmp/sniproxy/rpmbuild/RPMS/x86_64/sniproxy-*.rpm" 321 | fi 322 | download /etc/init.d/sniproxy https://raw.githubusercontent.com/dlundquist/sniproxy/master/redhat/sniproxy.init && chmod +x /etc/init.d/sniproxy 323 | elif check_sys packageManager apt; then 324 | if [[ ${fastmode} = "1" ]]; then 325 | if [[ ${bit} = "x86_64" ]]; then 326 | download /tmp/sniproxy_0.6.0_amd64.deb https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy_0.6.0_amd64.deb 327 | error_detect_depends "dpkg -i --no-debsig /tmp/sniproxy_0.6.0_amd64.deb" 328 | rm -rf /tmp/sniproxy_0.6.0_amd64.deb 329 | elif [[ ${bit} = "i386" ]]; then 330 | download /tmp/sniproxy_0.6.0_i386.deb https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy_0.6.0_i386.deb 331 | error_detect_depends "dpkg -i --no-debsig /tmp/sniproxy_0.6.0_i386.deb" 332 | rm -rf /tmp/sniproxy_0.6.0_i386.deb 333 | else 334 | echo -e "${red}暂不支持${bit}内核,请使用编译模式安装!${plain}" && exit 1 335 | fi 336 | else 337 | ./autogen.sh && dpkg-buildpackage 338 | error_detect_depends "dpkg -i --no-debsig ../sniproxy_*.deb" 339 | rm -rf /tmp/sniproxy*.deb 340 | fi 341 | download /etc/init.d/sniproxy https://raw.githubusercontent.com/dlundquist/sniproxy/master/debian/init.d && chmod +x /etc/init.d/sniproxy 342 | download /etc/default/sniproxy https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/sniproxy.default 343 | fi 344 | [ ! -f /usr/sbin/sniproxy ] && echo -e "[${red}Error${plain}] 安装Sniproxy出现问题,请检查." && exit 1 345 | [ ! -f /etc/init.d/sniproxy ] && echo -e "[${red}Error${plain}] 下载Sniproxy启动文件出现问题,请检查." && exit 1 346 | download /etc/sniproxy.conf https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/sniproxy.conf 347 | download /tmp/sniproxy-domains.txt https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/proxy-domains-disney.txt 348 | sed -i -e 's/\./\\\./g' -e 's/^/ \.\*/' -e 's/$/\$ \*/' /tmp/sniproxy-domains.txt || (echo -e "[${red}Error:${plain}] Failed to configuration sniproxy." && exit 1) 349 | sed -i '/table {/r /tmp/sniproxy-domains.txt' /etc/sniproxy.conf || (echo -e "[${red}Error:${plain}] Failed to configuration sniproxy." && exit 1) 350 | if [ ! -e /var/log/sniproxy ]; then 351 | mkdir /var/log/sniproxy 352 | fi 353 | echo "启动 SNI Proxy 服务..." 354 | if check_sys packageManager yum; then 355 | if centosversion 6; then 356 | chkconfig sniproxy on > /dev/null 2>&1 357 | service sniproxy start || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 358 | elif centosversion 7 || centosversion 8; then 359 | systemctl enable sniproxy > /dev/null 2>&1 360 | systemctl start sniproxy || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 361 | fi 362 | elif check_sys packageManager apt; then 363 | systemctl daemon-reload 364 | systemctl enable sniproxy > /dev/null 2>&1 365 | systemctl restart sniproxy || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 366 | fi 367 | cd /tmp 368 | rm -rf /tmp/sniproxy/ 369 | rm -rf /tmp/sniproxy-domains.txt 370 | echo -e "[${green}Info${plain}] sniproxy install complete..." 371 | } 372 | 373 | install_check(){ 374 | if check_sys packageManager yum || check_sys packageManager apt; then 375 | if centosversion 5; then 376 | return 1 377 | fi 378 | return 0 379 | else 380 | return 1 381 | fi 382 | } 383 | 384 | ready_install(){ 385 | echo "检测您的系統..." 386 | if ! install_check; then 387 | echo -e "[${red}Error${plain}] Your OS is not supported to run it!" 388 | echo -e "Please change to CentOS 6+/Debian 8+/Ubuntu 16+ and try again." 389 | exit 1 390 | fi 391 | if check_sys packageManager yum; then 392 | error_detect_depends "yum -y install net-tools" 393 | elif check_sys packageManager apt; then 394 | error_detect_depends "apt-get -y install net-tools" 395 | fi 396 | disable_selinux 397 | if check_sys packageManager yum; then 398 | config_firewall 399 | fi 400 | echo -e "[${green}Info${plain}] Checking the system complete..." 401 | } 402 | 403 | hello(){ 404 | echo "" 405 | echo -e "${yellow}Dnsmasq + SNI Proxy自助安装脚本${plain}" 406 | echo -e "${yellow}支持系统: CentOS 6+, Debian8+, Ubuntu16+${plain}" 407 | echo "" 408 | } 409 | 410 | help(){ 411 | hello 412 | echo "使用方法:bash $0 [-h] [-i] [-f] [-id] [-is] [-fs] [-u] [-ud] [-us]" 413 | echo "" 414 | echo " -h , --help 显示帮助信息" 415 | echo " -i , --install 安装 Dnsmasq + SNI Proxy" 416 | echo " -f , --fastinstall 快速安装 Dnsmasq + SNI Proxy" 417 | echo " -id, --installdnsmasq 仅安装 Dnsmasq" 418 | echo " -is, --installsniproxy 仅安装 SNI Proxy" 419 | echo " -fs, --fastinstallsniproxy 快速安装 SNI Proxy" 420 | echo " -u , --uninstall 卸载 Dnsmasq + SNI Proxy" 421 | echo " -ud, --undnsmasq 卸载 Dnsmasq" 422 | echo " -us, --unsniproxy 卸载 SNI Proxy" 423 | echo "" 424 | } 425 | 426 | install_all(){ 427 | ports="53 80 443" 428 | publicip=$(get_ip) 429 | hello 430 | ready_install 431 | install_dnsmasq 432 | install_sniproxy 433 | echo "" 434 | echo -e "${yellow}Dnsmasq + SNI Proxy 已完成安装!${plain}" 435 | echo "" 436 | echo -e "${yellow}将您的DNS更改为 $(get_ip) 即可以观看DisneyPlus节目了。${plain}" 437 | echo "" 438 | } 439 | 440 | only_dnsmasq(){ 441 | ports="53" 442 | hello 443 | ready_install 444 | inputipcount=1 445 | echo -e "请输入SNIProxy服务器的IP地址" 446 | read -e -p "(默认为本机公网IP): " inputip 447 | while true; do 448 | if [ "${inputipcount}" == 3 ]; then 449 | echo -e "[${red}Error:${plain}] IP输入错误次数过多,请重新执行脚本。" 450 | exit 1 451 | fi 452 | if [ -z ${inputip} ]; then 453 | publicip=$(get_ip) 454 | break 455 | else 456 | check_ip ${inputip} 457 | if [ $? -eq 0 ]; then 458 | publicip=${inputip} 459 | break 460 | else 461 | echo -e "请重新输入SNIProxy服务器的IP地址" 462 | read -e -p "(默认为本机公网IP): " inputip 463 | fi 464 | fi 465 | inputipcount=`expr ${inputipcount} + 1` 466 | done 467 | install_dnsmasq 468 | echo "" 469 | echo -e "${yellow}Dnsmasq 已完成安装!${plain}" 470 | echo "" 471 | echo -e "${yellow}将您的DNS更改为 $(get_ip) 即可以观看DisneyPlus节目了。${plain}" 472 | echo "" 473 | } 474 | 475 | only_sniproxy(){ 476 | ports="80 443" 477 | hello 478 | ready_install 479 | install_sniproxy 480 | echo "" 481 | echo -e "${yellow}SNI Proxy 已完成安装!${plain}" 482 | echo "" 483 | echo -e "${yellow}将DisneyPlus的相关域名解析到 $(get_ip) 即可以观看DisneyPlus节目了。${plain}" 484 | echo "" 485 | } 486 | 487 | undnsmasq(){ 488 | echo -e "[${green}Info${plain}] Stoping dnsmasq services." 489 | if check_sys packageManager yum; then 490 | if centosversion 6; then 491 | chkconfig dnsmasq off > /dev/null 2>&1 492 | service dnsmasq stop || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 493 | elif centosversion 7 || centosversion 8; then 494 | systemctl disable dnsmasq > /dev/null 2>&1 495 | systemctl stop dnsmasq || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 496 | fi 497 | elif check_sys packageManager apt; then 498 | systemctl disable dnsmasq > /dev/null 2>&1 499 | systemctl stop dnsmasq || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 500 | fi 501 | echo -e "[${green}Info${plain}] Starting to uninstall dnsmasq services." 502 | if check_sys packageManager yum; then 503 | yum remove dnsmasq -y > /dev/null 2>&1 504 | if [ $? -ne 0 ]; then 505 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}dnsmasq${plain}" 506 | fi 507 | elif check_sys packageManager apt; then 508 | apt-get remove dnsmasq -y > /dev/null 2>&1 509 | if [ $? -ne 0 ]; then 510 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}dnsmasq${plain}" 511 | fi 512 | fi 513 | rm -rf /etc/dnsmasq.d/custom_netflix.conf 514 | echo -e "[${green}Info${plain}] services uninstall dnsmasq complete..." 515 | } 516 | 517 | unsniproxy(){ 518 | echo -e "[${green}Info${plain}] Stoping sniproxy services." 519 | if check_sys packageManager yum; then 520 | if centosversion 6; then 521 | chkconfig sniproxy off > /dev/null 2>&1 522 | service sniproxy stop || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 523 | elif centosversion 7 || centosversion 8; then 524 | systemctl disable sniproxy > /dev/null 2>&1 525 | systemctl stop sniproxy || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 526 | fi 527 | elif check_sys packageManager apt; then 528 | systemctl disable sniproxy > /dev/null 2>&1 529 | systemctl stop sniproxy || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 530 | fi 531 | echo -e "[${green}Info${plain}] Starting to uninstall sniproxy services." 532 | if check_sys packageManager yum; then 533 | yum remove sniproxy -y > /dev/null 2>&1 534 | if [ $? -ne 0 ]; then 535 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}sniproxy${plain}" 536 | fi 537 | elif check_sys packageManager apt; then 538 | apt-get remove sniproxy -y > /dev/null 2>&1 539 | if [ $? -ne 0 ]; then 540 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}sniproxy${plain}" 541 | fi 542 | fi 543 | rm -rf /etc/sniproxy.conf 544 | echo -e "[${green}Info${plain}] services uninstall sniproxy complete..." 545 | } 546 | 547 | confirm(){ 548 | echo -e "${yellow}是否继续执行?(n:取消/y:继续)${plain}" 549 | read -e -p "(默认:取消): " selection 550 | [ -z "${selection}" ] && selection="n" 551 | if [ ${selection} != "y" ]; then 552 | exit 0 553 | fi 554 | } 555 | 556 | if [[ $# = 1 ]];then 557 | key="$1" 558 | case $key in 559 | -i|--install) 560 | fastmode=0 561 | install_all 562 | ;; 563 | -f|--fastinstall) 564 | fastmode=1 565 | install_all 566 | ;; 567 | -id|--installdnsmasq) 568 | fastmode=0 569 | only_dnsmasq 570 | ;; 571 | -is|--installsniproxy) 572 | fastmode=0 573 | only_sniproxy 574 | ;; 575 | -fs|--fastinstallsniproxy) 576 | fastmode=1 577 | only_sniproxy 578 | ;; 579 | -u|--uninstall) 580 | hello 581 | echo -e "${yellow}正在执行卸载Dnsmasq和SNI Proxy.${plain}" 582 | confirm 583 | undnsmasq 584 | unsniproxy 585 | ;; 586 | -ud|--undnsmasq) 587 | hello 588 | echo -e "${yellow}正在执行卸载Dnsmasq.${plain}" 589 | confirm 590 | undnsmasq 591 | ;; 592 | -us|--unsniproxy) 593 | hello 594 | echo -e "${yellow}正在执行卸载SNI Proxy.${plain}" 595 | confirm 596 | unsniproxy 597 | ;; 598 | -h|--help|*) 599 | help 600 | ;; 601 | esac 602 | else 603 | help 604 | fi 605 | -------------------------------------------------------------------------------- /dnsmasq_sniproxy_nr.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | red='\033[0;31m' 6 | green='\033[0;32m' 7 | yellow='\033[0;33m' 8 | plain='\033[0m' 9 | 10 | [[ $EUID -ne 0 ]] && echo -e "[${red}Error${plain}] 请使用root用户来执行脚本!" && exit 1 11 | 12 | disable_selinux(){ 13 | if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then 14 | sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 15 | setenforce 0 16 | fi 17 | } 18 | 19 | check_sys(){ 20 | local checkType=$1 21 | local value=$2 22 | 23 | local release='' 24 | local systemPackage='' 25 | 26 | if [[ -f /etc/redhat-release ]]; then 27 | release="centos" 28 | systemPackage="yum" 29 | elif grep -Eqi "debian|raspbian" /etc/issue; then 30 | release="debian" 31 | systemPackage="apt" 32 | elif grep -Eqi "ubuntu" /etc/issue; then 33 | release="ubuntu" 34 | systemPackage="apt" 35 | elif grep -Eqi "centos|red hat|redhat" /etc/issue; then 36 | release="centos" 37 | systemPackage="yum" 38 | elif grep -Eqi "debian|raspbian" /proc/version; then 39 | release="debian" 40 | systemPackage="apt" 41 | elif grep -Eqi "ubuntu" /proc/version; then 42 | release="ubuntu" 43 | systemPackage="apt" 44 | elif grep -Eqi "centos|red hat|redhat" /proc/version; then 45 | release="centos" 46 | systemPackage="yum" 47 | fi 48 | 49 | if [[ "${checkType}" == "sysRelease" ]]; then 50 | if [ "${value}" == "${release}" ]; then 51 | return 0 52 | else 53 | return 1 54 | fi 55 | elif [[ "${checkType}" == "packageManager" ]]; then 56 | if [ "${value}" == "${systemPackage}" ]; then 57 | return 0 58 | else 59 | return 1 60 | fi 61 | fi 62 | } 63 | 64 | getversion(){ 65 | if [[ -s /etc/redhat-release ]]; then 66 | grep -oE "[0-9.]+" /etc/redhat-release 67 | else 68 | grep -oE "[0-9.]+" /etc/issue 69 | fi 70 | } 71 | 72 | centosversion(){ 73 | if check_sys sysRelease centos; then 74 | local code=$1 75 | local version="$(getversion)" 76 | local main_ver=${version%%.*} 77 | if [ "$main_ver" == "$code" ]; then 78 | return 0 79 | else 80 | return 1 81 | fi 82 | else 83 | return 1 84 | fi 85 | } 86 | 87 | get_ip(){ 88 | local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 ) 89 | [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com ) 90 | [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip ) 91 | echo ${IP} 92 | } 93 | 94 | check_ip(){ 95 | local checkip=$1 96 | local valid_check=$(echo $checkip|awk -F. '$1<=255&&$2<=255&&$3<=255&&$4<=255{print "yes"}') 97 | if echo $checkip|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then 98 | if [ ${valid_check:-no} == "yes" ]; then 99 | return 0 100 | else 101 | echo -e "[${red}Error${plain}] IP $checkip not available!" 102 | return 1 103 | fi 104 | else 105 | echo -e "[${red}Error${plain}] IP format error!" 106 | return 1 107 | fi 108 | } 109 | 110 | download(){ 111 | local filename=${1} 112 | echo -e "[${green}Info${plain}] ${filename} download configuration now..." 113 | wget --no-check-certificate -q -t3 -T60 -O ${1} ${2} 114 | if [ $? -ne 0 ]; then 115 | echo -e "[${red}Error${plain}] Download ${filename} failed." 116 | exit 1 117 | fi 118 | } 119 | 120 | error_detect_depends(){ 121 | local command=$1 122 | local depend=`echo "${command}" | awk '{print $4}'` 123 | echo -e "[${green}Info${plain}] Starting to install package ${depend}" 124 | ${command} > /dev/null 2>&1 125 | if [ $? -ne 0 ]; then 126 | echo -e "[${red}Error${plain}] Failed to install ${red}${depend}${plain}" 127 | exit 1 128 | fi 129 | } 130 | 131 | config_firewall(){ 132 | if centosversion 6; then 133 | /etc/init.d/iptables status > /dev/null 2>&1 134 | if [ $? -eq 0 ]; then 135 | for port in ${ports}; do 136 | iptables -L -n | grep -i ${port} > /dev/null 2>&1 137 | if [ $? -ne 0 ]; then 138 | iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${port} -j ACCEPT 139 | if [ ${port} == "53" ]; then 140 | iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${port} -j ACCEPT 141 | fi 142 | else 143 | echo -e "[${green}Info${plain}] port ${green}${port}${plain} already be enabled." 144 | fi 145 | done 146 | /etc/init.d/iptables save 147 | /etc/init.d/iptables restart 148 | else 149 | echo -e "[${yellow}Warning${plain}] iptables looks like not running or not installed, please enable port ${ports} manually if necessary." 150 | fi 151 | elif centosversion 7 || centosversion 8; then 152 | systemctl status firewalld > /dev/null 2>&1 153 | if [ $? -eq 0 ]; then 154 | default_zone=$(firewall-cmd --get-default-zone) 155 | for port in ${ports}; do 156 | firewall-cmd --permanent --zone=${default_zone} --add-port=${port}/tcp 157 | if [ ${port} == "53" ]; then 158 | firewall-cmd --permanent --zone=${default_zone} --add-port=${port}/udp 159 | fi 160 | firewall-cmd --reload 161 | done 162 | else 163 | echo -e "[${yellow}Warning${plain}] firewalld looks like not running or not installed, please enable port ${ports} manually if necessary." 164 | fi 165 | fi 166 | } 167 | 168 | install_dependencies(){ 169 | echo "安装依赖软件..." 170 | if check_sys packageManager yum; then 171 | echo -e "[${green}Info${plain}] Checking the EPEL repository..." 172 | if [ ! -f /etc/yum.repos.d/epel.repo ]; then 173 | yum install -y epel-release > /dev/null 2>&1 174 | fi 175 | [ ! -f /etc/yum.repos.d/epel.repo ] && echo -e "[${red}Error${plain}] Install EPEL repository failed, please check it." && exit 1 176 | [ ! "$(command -v yum-config-manager)" ] && yum install -y yum-utils > /dev/null 2>&1 177 | [ x"$(yum-config-manager epel | grep -w enabled | awk '{print $3}')" != x"True" ] && yum-config-manager --enable epel > /dev/null 2>&1 178 | echo -e "[${green}Info${plain}] Checking the EPEL repository complete..." 179 | 180 | if [[ ${fastmode} = "1" ]]; then 181 | yum_depends=( 182 | curl gettext-devel libev-devel pcre-devel perl udns-devel 183 | ) 184 | else 185 | yum_depends=( 186 | wget git autoconf automake curl gettext-devel libev-devel pcre-devel perl pkgconfig rpm-build udns-devel 187 | ) 188 | fi 189 | for depend in ${yum_depends[@]}; do 190 | error_detect_depends "yum -y install ${depend}" 191 | done 192 | if [[ ${fastmode} = "0" ]]; then 193 | if centosversion 6; then 194 | error_detect_depends "yum -y groupinstall development" 195 | error_detect_depends "yum -y install centos-release-scl" 196 | error_detect_depends "yum -y install devtoolset-6-gcc-c++" 197 | elif centosversion 7 || centosversion 8; then 198 | yum groups list development | grep Installed > /dev/null 2>&1 199 | if [[ $? -eq 0 ]]; then 200 | yum groups mark remove development -y > /dev/null 2>&1 201 | fi 202 | error_detect_depends "yum -y groupinstall development" 203 | fi 204 | fi 205 | elif check_sys packageManager apt; then 206 | if [[ ${fastmode} = "1" ]]; then 207 | apt_depends=( 208 | curl gettext libev-dev libpcre3-dev libudns-dev 209 | ) 210 | else 211 | apt_depends=( 212 | wget git autotools-dev cdbs debhelper dh-autoreconf dpkg-dev gettext libev-dev libpcre3-dev libudns-dev pkg-config fakeroot devscripts 213 | ) 214 | fi 215 | apt-get -y update 216 | for depend in ${apt_depends[@]}; do 217 | error_detect_depends "apt-get -y install ${depend}" 218 | done 219 | if [[ ${fastmode} = "0" ]]; then 220 | error_detect_depends "apt-get -y install build-essential" 221 | fi 222 | fi 223 | } 224 | 225 | install_dnsmasq(){ 226 | netstat -a -n -p | grep LISTEN | grep -P "\d+\.\d+\.\d+\.\d+:53\s+" > /dev/null && echo -e "[${red}Error${plain}] required port 53 already in use\n" && exit 1 227 | echo "安装Dnsmasq..." 228 | if check_sys packageManager yum; then 229 | error_detect_depends "yum -y install dnsmasq" 230 | if centosversion 6; then 231 | error_detect_depends "yum -y install make" 232 | error_detect_depends "yum -y install gcc-c++" 233 | cd /tmp/ 234 | if [ -e dnsmasq-2.80 ]; then 235 | rm -rf dnsmasq-2.80 236 | fi 237 | download dnsmasq-2.80.tar.gz http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.80.tar.gz 238 | tar -zxf dnsmasq-2.80.tar.gz 239 | cd dnsmasq-2.80 240 | make 241 | if [ $? -ne 0 ]; then 242 | echo -e "[${red}Error${plain}] dnsmasq upgrade failed." 243 | rm -rf /tmp/dnsmasq-2.80 /tmp/dnsmasq-2.80.tar.gz 244 | exit 1 245 | fi 246 | yes|cp -f /tmp/dnsmasq-2.80/src/dnsmasq /usr/sbin/dnsmasq && chmod 755 /usr/sbin/dnsmasq 247 | fi 248 | elif check_sys packageManager apt; then 249 | error_detect_depends "apt-get -y install dnsmasq" 250 | fi 251 | [ ! -f /usr/sbin/dnsmasq ] && echo -e "[${red}Error${plain}] 安装dnsmasq出现问题,请检查." && exit 1 252 | download /etc/dnsmasq.d/custom_netflix.conf https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq.conf 253 | download /tmp/proxy-domains-nr.txt https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/proxy-domains-nr.txt 254 | for domain in $(cat /tmp/proxy-domains-nr.txt); do 255 | printf "address=/${domain}/${publicip}\n"\ 256 | | tee -a /etc/dnsmasq.d/custom_netflix.conf > /dev/null 2>&1 257 | done 258 | [ "$(grep -x -E "(conf-dir=/etc/dnsmasq.d|conf-dir=/etc/dnsmasq.d,.bak|conf-dir=/etc/dnsmasq.d/,\*.conf|conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig)" /etc/dnsmasq.conf)" ] || echo -e "\nconf-dir=/etc/dnsmasq.d" >> /etc/dnsmasq.conf 259 | echo "启动 Dnsmasq 服务..." 260 | if check_sys packageManager yum; then 261 | if centosversion 6; then 262 | chkconfig dnsmasq on 263 | service dnsmasq start 264 | elif centosversion 7 || centosversion 8; then 265 | systemctl enable dnsmasq 266 | systemctl start dnsmasq 267 | fi 268 | elif check_sys packageManager apt; then 269 | systemctl enable dnsmasq 270 | systemctl restart dnsmasq 271 | fi 272 | cd /tmp 273 | rm -rf /tmp/dnsmasq-2.80 /tmp/dnsmasq-2.80.tar.gz /tmp/proxy-domains-nr.txt 274 | echo -e "[${green}Info${plain}] dnsmasq install complete..." 275 | } 276 | 277 | install_sniproxy(){ 278 | for aport in 80 443; do 279 | netstat -a -n -p | grep LISTEN | grep -P "\d+\.\d+\.\d+\.\d+:${aport}\s+" > /dev/null && echo -e "[${red}Error${plain}] required port ${aport} already in use\n" && exit 1 280 | done 281 | install_dependencies 282 | echo "安装SNI Proxy..." 283 | if check_sys packageManager yum; then 284 | rpm -qa | grep sniproxy >/dev/null 2>&1 285 | if [ $? -eq 0 ]; then 286 | rpm -e sniproxy 287 | fi 288 | elif check_sys packageManager apt; then 289 | dpkg -s sniproxy >/dev/null 2>&1 290 | if [ $? -eq 0 ]; then 291 | dpkg -r sniproxy 292 | fi 293 | fi 294 | bit=`uname -m` 295 | cd /tmp 296 | if [[ ${fastmode} = "0" ]]; then 297 | if [ -e sniproxy ]; then 298 | rm -rf sniproxy 299 | fi 300 | git clone https://github.com/dlundquist/sniproxy.git 301 | cd sniproxy 302 | fi 303 | if check_sys packageManager yum; then 304 | if [[ ${fastmode} = "1" ]]; then 305 | if [[ ${bit} = "x86_64" ]]; then 306 | download /tmp/sniproxy-0.6.0.el7.x86_64.rpm https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy-0.6.0.el7.x86_64.rpm 307 | error_detect_depends "yum -y install /tmp/sniproxy-0.6.0.el7.x86_64.rpm" 308 | rm -rf /tmp/sniproxy-0.6.0.el7.x86_64.rpm 309 | else 310 | echo -e "${red}暂不支持${bit}内核,请使用编译模式安装!${plain}" && exit 1 311 | fi 312 | else 313 | ./autogen.sh && ./configure && make dist 314 | if centosversion 6; then 315 | scl enable devtoolset-6 'rpmbuild --define "_sourcedir `pwd`" --define "_topdir /tmp/sniproxy/rpmbuild" --define "debug_package %{nil}" -ba redhat/sniproxy.spec' 316 | elif centosversion 7 || centosversion 8; then 317 | sed -i "s/\%configure CFLAGS\=\"-I\/usr\/include\/libev\"/\%configure CFLAGS\=\"-fPIC -I\/usr\/include\/libev\"/" redhat/sniproxy.spec 318 | rpmbuild --define "_sourcedir `pwd`" --define "_topdir /tmp/sniproxy/rpmbuild" --define "debug_package %{nil}" -ba redhat/sniproxy.spec 319 | fi 320 | error_detect_depends "yum -y install /tmp/sniproxy/rpmbuild/RPMS/x86_64/sniproxy-*.rpm" 321 | fi 322 | download /etc/init.d/sniproxy https://raw.githubusercontent.com/dlundquist/sniproxy/master/redhat/sniproxy.init && chmod +x /etc/init.d/sniproxy 323 | elif check_sys packageManager apt; then 324 | if [[ ${fastmode} = "1" ]]; then 325 | if [[ ${bit} = "x86_64" ]]; then 326 | download /tmp/sniproxy_0.6.0_amd64.deb https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy_0.6.0_amd64.deb 327 | error_detect_depends "dpkg -i --no-debsig /tmp/sniproxy_0.6.0_amd64.deb" 328 | rm -rf /tmp/sniproxy_0.6.0_amd64.deb 329 | elif [[ ${bit} = "i386" ]]; then 330 | download /tmp/sniproxy_0.6.0_i386.deb https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy_0.6.0_i386.deb 331 | error_detect_depends "dpkg -i --no-debsig /tmp/sniproxy_0.6.0_i386.deb" 332 | rm -rf /tmp/sniproxy_0.6.0_i386.deb 333 | else 334 | echo -e "${red}暂不支持${bit}内核,请使用编译模式安装!${plain}" && exit 1 335 | fi 336 | else 337 | ./autogen.sh && dpkg-buildpackage 338 | error_detect_depends "dpkg -i --no-debsig ../sniproxy_*.deb" 339 | rm -rf /tmp/sniproxy*.deb 340 | fi 341 | download /etc/init.d/sniproxy https://raw.githubusercontent.com/dlundquist/sniproxy/master/debian/init.d && chmod +x /etc/init.d/sniproxy 342 | download /etc/default/sniproxy https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/sniproxy.default 343 | fi 344 | [ ! -f /usr/sbin/sniproxy ] && echo -e "[${red}Error${plain}] 安装Sniproxy出现问题,请检查." && exit 1 345 | [ ! -f /etc/init.d/sniproxy ] && echo -e "[${red}Error${plain}] 下载Sniproxy启动文件出现问题,请检查." && exit 1 346 | download /etc/sniproxy.conf https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/sniproxy.conf 347 | download /tmp/sniproxy-domains-nr.txt https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/proxy-domains-nr.txt 348 | sed -i -e 's/\./\\\./g' -e 's/^/ \.\*/' -e 's/$/\$ \*/' /tmp/sniproxy-domains.txt || (echo -e "[${red}Error:${plain}] Failed to configuration sniproxy." && exit 1) 349 | sed -i '/table {/r /tmp/sniproxy-domains.txt' /etc/sniproxy.conf || (echo -e "[${red}Error:${plain}] Failed to configuration sniproxy." && exit 1) 350 | if [ ! -e /var/log/sniproxy ]; then 351 | mkdir /var/log/sniproxy 352 | fi 353 | echo "启动 SNI Proxy 服务..." 354 | if check_sys packageManager yum; then 355 | if centosversion 6; then 356 | chkconfig sniproxy on > /dev/null 2>&1 357 | service sniproxy start || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 358 | elif centosversion 7 || centosversion 8; then 359 | systemctl enable sniproxy > /dev/null 2>&1 360 | systemctl start sniproxy || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 361 | fi 362 | elif check_sys packageManager apt; then 363 | systemctl daemon-reload 364 | systemctl enable sniproxy > /dev/null 2>&1 365 | systemctl restart sniproxy || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 366 | fi 367 | cd /tmp 368 | rm -rf /tmp/sniproxy/ 369 | rm -rf /tmp/sniproxy-domains-nr.txt 370 | echo -e "[${green}Info${plain}] sniproxy install complete..." 371 | } 372 | 373 | install_check(){ 374 | if check_sys packageManager yum || check_sys packageManager apt; then 375 | if centosversion 5; then 376 | return 1 377 | fi 378 | return 0 379 | else 380 | return 1 381 | fi 382 | } 383 | 384 | ready_install(){ 385 | echo "检测您的系統..." 386 | if ! install_check; then 387 | echo -e "[${red}Error${plain}] Your OS is not supported to run it!" 388 | echo -e "Please change to CentOS 6+/Debian 8+/Ubuntu 16+ and try again." 389 | exit 1 390 | fi 391 | if check_sys packageManager yum; then 392 | error_detect_depends "yum -y install net-tools" 393 | elif check_sys packageManager apt; then 394 | error_detect_depends "apt-get -y install net-tools" 395 | fi 396 | disable_selinux 397 | if check_sys packageManager yum; then 398 | config_firewall 399 | fi 400 | echo -e "[${green}Info${plain}] Checking the system complete..." 401 | } 402 | 403 | hello(){ 404 | echo "" 405 | echo -e "${yellow}Dnsmasq + SNI Proxy自助安装脚本${plain}" 406 | echo -e "${yellow}支持系统: CentOS 6+, Debian8+, Ubuntu16+${plain}" 407 | echo "" 408 | } 409 | 410 | help(){ 411 | hello 412 | echo "使用方法:bash $0 [-h] [-i] [-f] [-id] [-is] [-fs] [-u] [-ud] [-us]" 413 | echo "" 414 | echo " -h , --help 显示帮助信息" 415 | echo " -i , --install 安装 Dnsmasq + SNI Proxy" 416 | echo " -f , --fastinstall 快速安装 Dnsmasq + SNI Proxy" 417 | echo " -id, --installdnsmasq 仅安装 Dnsmasq" 418 | echo " -is, --installsniproxy 仅安装 SNI Proxy" 419 | echo " -fs, --fastinstallsniproxy 快速安装 SNI Proxy" 420 | echo " -u , --uninstall 卸载 Dnsmasq + SNI Proxy" 421 | echo " -ud, --undnsmasq 卸载 Dnsmasq" 422 | echo " -us, --unsniproxy 卸载 SNI Proxy" 423 | echo "" 424 | } 425 | 426 | install_all(){ 427 | ports="53 80 443" 428 | publicip=$(get_ip) 429 | hello 430 | ready_install 431 | install_dnsmasq 432 | install_sniproxy 433 | echo "" 434 | echo -e "${yellow}Dnsmasq + SNI Proxy 已完成安装!${plain}" 435 | echo "" 436 | echo -e "${yellow}将您的DNS更改为 $(get_ip) 即可以用Nearoute之IP观看流媒体节目了。${plain}" 437 | echo "" 438 | } 439 | 440 | only_dnsmasq(){ 441 | ports="53" 442 | hello 443 | ready_install 444 | inputipcount=1 445 | echo -e "请输入SNIProxy服务器的IP地址" 446 | read -e -p "(默认为本机公网IP): " inputip 447 | while true; do 448 | if [ "${inputipcount}" == 3 ]; then 449 | echo -e "[${red}Error:${plain}] IP输入错误次数过多,请重新执行脚本。" 450 | exit 1 451 | fi 452 | if [ -z ${inputip} ]; then 453 | publicip=$(get_ip) 454 | break 455 | else 456 | check_ip ${inputip} 457 | if [ $? -eq 0 ]; then 458 | publicip=${inputip} 459 | break 460 | else 461 | echo -e "请重新输入SNIProxy服务器的IP地址" 462 | read -e -p "(默认为本机公网IP): " inputip 463 | fi 464 | fi 465 | inputipcount=`expr ${inputipcount} + 1` 466 | done 467 | install_dnsmasq 468 | echo "" 469 | echo -e "${yellow}Dnsmasq 已完成安装!${plain}" 470 | echo "" 471 | echo -e "${yellow}将您的DNS更改为 $(get_ip) 即可以用Nearoute之IP观看流媒体节目了。${plain}" 472 | echo "" 473 | } 474 | 475 | only_sniproxy(){ 476 | ports="80 443" 477 | hello 478 | ready_install 479 | install_sniproxy 480 | echo "" 481 | echo -e "${yellow}SNI Proxy 已完成安装!${plain}" 482 | echo "" 483 | echo -e "${yellow}将Netflix的相关域名解析到 $(get_ip) 即可以用Nearoute之IP观看流媒体节目了。${plain}" 484 | echo "" 485 | } 486 | 487 | undnsmasq(){ 488 | echo -e "[${green}Info${plain}] Stoping dnsmasq services." 489 | if check_sys packageManager yum; then 490 | if centosversion 6; then 491 | chkconfig dnsmasq off > /dev/null 2>&1 492 | service dnsmasq stop || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 493 | elif centosversion 7 || centosversion 8; then 494 | systemctl disable dnsmasq > /dev/null 2>&1 495 | systemctl stop dnsmasq || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 496 | fi 497 | elif check_sys packageManager apt; then 498 | systemctl disable dnsmasq > /dev/null 2>&1 499 | systemctl stop dnsmasq || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 500 | fi 501 | echo -e "[${green}Info${plain}] Starting to uninstall dnsmasq services." 502 | if check_sys packageManager yum; then 503 | yum remove dnsmasq -y > /dev/null 2>&1 504 | if [ $? -ne 0 ]; then 505 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}dnsmasq${plain}" 506 | fi 507 | elif check_sys packageManager apt; then 508 | apt-get remove dnsmasq -y > /dev/null 2>&1 509 | if [ $? -ne 0 ]; then 510 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}dnsmasq${plain}" 511 | fi 512 | fi 513 | rm -rf /etc/dnsmasq.d/custom_netflix.conf 514 | echo -e "[${green}Info${plain}] services uninstall dnsmasq complete..." 515 | } 516 | 517 | unsniproxy(){ 518 | echo -e "[${green}Info${plain}] Stoping sniproxy services." 519 | if check_sys packageManager yum; then 520 | if centosversion 6; then 521 | chkconfig sniproxy off > /dev/null 2>&1 522 | service sniproxy stop || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 523 | elif centosversion 7 || centosversion 8; then 524 | systemctl disable sniproxy > /dev/null 2>&1 525 | systemctl stop sniproxy || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 526 | fi 527 | elif check_sys packageManager apt; then 528 | systemctl disable sniproxy > /dev/null 2>&1 529 | systemctl stop sniproxy || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 530 | fi 531 | echo -e "[${green}Info${plain}] Starting to uninstall sniproxy services." 532 | if check_sys packageManager yum; then 533 | yum remove sniproxy -y > /dev/null 2>&1 534 | if [ $? -ne 0 ]; then 535 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}sniproxy${plain}" 536 | fi 537 | elif check_sys packageManager apt; then 538 | apt-get remove sniproxy -y > /dev/null 2>&1 539 | if [ $? -ne 0 ]; then 540 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}sniproxy${plain}" 541 | fi 542 | fi 543 | rm -rf /etc/sniproxy.conf 544 | echo -e "[${green}Info${plain}] services uninstall sniproxy complete..." 545 | } 546 | 547 | confirm(){ 548 | echo -e "${yellow}是否继续执行?(n:取消/y:继续)${plain}" 549 | read -e -p "(默认:取消): " selection 550 | [ -z "${selection}" ] && selection="n" 551 | if [ ${selection} != "y" ]; then 552 | exit 0 553 | fi 554 | } 555 | 556 | if [[ $# = 1 ]];then 557 | key="$1" 558 | case $key in 559 | -i|--install) 560 | fastmode=0 561 | install_all 562 | ;; 563 | -f|--fastinstall) 564 | fastmode=1 565 | install_all 566 | ;; 567 | -id|--installdnsmasq) 568 | fastmode=0 569 | only_dnsmasq 570 | ;; 571 | -is|--installsniproxy) 572 | fastmode=0 573 | only_sniproxy 574 | ;; 575 | -fs|--fastinstallsniproxy) 576 | fastmode=1 577 | only_sniproxy 578 | ;; 579 | -u|--uninstall) 580 | hello 581 | echo -e "${yellow}正在执行卸载Dnsmasq和SNI Proxy.${plain}" 582 | confirm 583 | undnsmasq 584 | unsniproxy 585 | ;; 586 | -ud|--undnsmasq) 587 | hello 588 | echo -e "${yellow}正在执行卸载Dnsmasq.${plain}" 589 | confirm 590 | undnsmasq 591 | ;; 592 | -us|--unsniproxy) 593 | hello 594 | echo -e "${yellow}正在执行卸载SNI Proxy.${plain}" 595 | confirm 596 | unsniproxy 597 | ;; 598 | -h|--help|*) 599 | help 600 | ;; 601 | esac 602 | else 603 | help 604 | fi 605 | -------------------------------------------------------------------------------- /dnsmasq_sniproxy_tw.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | red='\033[0;31m' 6 | green='\033[0;32m' 7 | yellow='\033[0;33m' 8 | plain='\033[0m' 9 | 10 | [[ $EUID -ne 0 ]] && echo -e "[${red}Error${plain}] 请使用root用户来执行脚本!" && exit 1 11 | 12 | disable_selinux(){ 13 | if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then 14 | sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 15 | setenforce 0 16 | fi 17 | } 18 | 19 | check_sys(){ 20 | local checkType=$1 21 | local value=$2 22 | 23 | local release='' 24 | local systemPackage='' 25 | 26 | if [[ -f /etc/redhat-release ]]; then 27 | release="centos" 28 | systemPackage="yum" 29 | elif grep -Eqi "debian|raspbian" /etc/issue; then 30 | release="debian" 31 | systemPackage="apt" 32 | elif grep -Eqi "ubuntu" /etc/issue; then 33 | release="ubuntu" 34 | systemPackage="apt" 35 | elif grep -Eqi "centos|red hat|redhat" /etc/issue; then 36 | release="centos" 37 | systemPackage="yum" 38 | elif grep -Eqi "debian|raspbian" /proc/version; then 39 | release="debian" 40 | systemPackage="apt" 41 | elif grep -Eqi "ubuntu" /proc/version; then 42 | release="ubuntu" 43 | systemPackage="apt" 44 | elif grep -Eqi "centos|red hat|redhat" /proc/version; then 45 | release="centos" 46 | systemPackage="yum" 47 | fi 48 | 49 | if [[ "${checkType}" == "sysRelease" ]]; then 50 | if [ "${value}" == "${release}" ]; then 51 | return 0 52 | else 53 | return 1 54 | fi 55 | elif [[ "${checkType}" == "packageManager" ]]; then 56 | if [ "${value}" == "${systemPackage}" ]; then 57 | return 0 58 | else 59 | return 1 60 | fi 61 | fi 62 | } 63 | 64 | getversion(){ 65 | if [[ -s /etc/redhat-release ]]; then 66 | grep -oE "[0-9.]+" /etc/redhat-release 67 | else 68 | grep -oE "[0-9.]+" /etc/issue 69 | fi 70 | } 71 | 72 | centosversion(){ 73 | if check_sys sysRelease centos; then 74 | local code=$1 75 | local version="$(getversion)" 76 | local main_ver=${version%%.*} 77 | if [ "$main_ver" == "$code" ]; then 78 | return 0 79 | else 80 | return 1 81 | fi 82 | else 83 | return 1 84 | fi 85 | } 86 | 87 | get_ip(){ 88 | local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 ) 89 | [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com ) 90 | [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip ) 91 | echo ${IP} 92 | } 93 | 94 | check_ip(){ 95 | local checkip=$1 96 | local valid_check=$(echo $checkip|awk -F. '$1<=255&&$2<=255&&$3<=255&&$4<=255{print "yes"}') 97 | if echo $checkip|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then 98 | if [ ${valid_check:-no} == "yes" ]; then 99 | return 0 100 | else 101 | echo -e "[${red}Error${plain}] IP $checkip not available!" 102 | return 1 103 | fi 104 | else 105 | echo -e "[${red}Error${plain}] IP format error!" 106 | return 1 107 | fi 108 | } 109 | 110 | download(){ 111 | local filename=${1} 112 | echo -e "[${green}Info${plain}] ${filename} download configuration now..." 113 | wget --no-check-certificate -q -t3 -T60 -O ${1} ${2} 114 | if [ $? -ne 0 ]; then 115 | echo -e "[${red}Error${plain}] Download ${filename} failed." 116 | exit 1 117 | fi 118 | } 119 | 120 | error_detect_depends(){ 121 | local command=$1 122 | local depend=`echo "${command}" | awk '{print $4}'` 123 | echo -e "[${green}Info${plain}] Starting to install package ${depend}" 124 | ${command} > /dev/null 2>&1 125 | if [ $? -ne 0 ]; then 126 | echo -e "[${red}Error${plain}] Failed to install ${red}${depend}${plain}" 127 | exit 1 128 | fi 129 | } 130 | 131 | config_firewall(){ 132 | if centosversion 6; then 133 | /etc/init.d/iptables status > /dev/null 2>&1 134 | if [ $? -eq 0 ]; then 135 | for port in ${ports}; do 136 | iptables -L -n | grep -i ${port} > /dev/null 2>&1 137 | if [ $? -ne 0 ]; then 138 | iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${port} -j ACCEPT 139 | if [ ${port} == "53" ]; then 140 | iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${port} -j ACCEPT 141 | fi 142 | else 143 | echo -e "[${green}Info${plain}] port ${green}${port}${plain} already be enabled." 144 | fi 145 | done 146 | /etc/init.d/iptables save 147 | /etc/init.d/iptables restart 148 | else 149 | echo -e "[${yellow}Warning${plain}] iptables looks like not running or not installed, please enable port ${ports} manually if necessary." 150 | fi 151 | elif centosversion 7 || centosversion 8; then 152 | systemctl status firewalld > /dev/null 2>&1 153 | if [ $? -eq 0 ]; then 154 | default_zone=$(firewall-cmd --get-default-zone) 155 | for port in ${ports}; do 156 | firewall-cmd --permanent --zone=${default_zone} --add-port=${port}/tcp 157 | if [ ${port} == "53" ]; then 158 | firewall-cmd --permanent --zone=${default_zone} --add-port=${port}/udp 159 | fi 160 | firewall-cmd --reload 161 | done 162 | else 163 | echo -e "[${yellow}Warning${plain}] firewalld looks like not running or not installed, please enable port ${ports} manually if necessary." 164 | fi 165 | fi 166 | } 167 | 168 | install_dependencies(){ 169 | echo "安装依赖软件..." 170 | if check_sys packageManager yum; then 171 | echo -e "[${green}Info${plain}] Checking the EPEL repository..." 172 | if [ ! -f /etc/yum.repos.d/epel.repo ]; then 173 | yum install -y epel-release > /dev/null 2>&1 174 | fi 175 | [ ! -f /etc/yum.repos.d/epel.repo ] && echo -e "[${red}Error${plain}] Install EPEL repository failed, please check it." && exit 1 176 | [ ! "$(command -v yum-config-manager)" ] && yum install -y yum-utils > /dev/null 2>&1 177 | [ x"$(yum-config-manager epel | grep -w enabled | awk '{print $3}')" != x"True" ] && yum-config-manager --enable epel > /dev/null 2>&1 178 | echo -e "[${green}Info${plain}] Checking the EPEL repository complete..." 179 | 180 | if [[ ${fastmode} = "1" ]]; then 181 | yum_depends=( 182 | curl gettext-devel libev-devel pcre-devel perl udns-devel 183 | ) 184 | else 185 | yum_depends=( 186 | wget git autoconf automake curl gettext-devel libev-devel pcre-devel perl pkgconfig rpm-build udns-devel 187 | ) 188 | fi 189 | for depend in ${yum_depends[@]}; do 190 | error_detect_depends "yum -y install ${depend}" 191 | done 192 | if [[ ${fastmode} = "0" ]]; then 193 | if centosversion 6; then 194 | error_detect_depends "yum -y groupinstall development" 195 | error_detect_depends "yum -y install centos-release-scl" 196 | error_detect_depends "yum -y install devtoolset-6-gcc-c++" 197 | elif centosversion 7 || centosversion 8; then 198 | yum groups list development | grep Installed > /dev/null 2>&1 199 | if [[ $? -eq 0 ]]; then 200 | yum groups mark remove development -y > /dev/null 2>&1 201 | fi 202 | error_detect_depends "yum -y groupinstall development" 203 | fi 204 | fi 205 | elif check_sys packageManager apt; then 206 | if [[ ${fastmode} = "1" ]]; then 207 | apt_depends=( 208 | curl gettext libev-dev libpcre3-dev libudns-dev 209 | ) 210 | else 211 | apt_depends=( 212 | wget git autotools-dev cdbs debhelper dh-autoreconf dpkg-dev gettext libev-dev libpcre3-dev libudns-dev pkg-config fakeroot devscripts 213 | ) 214 | fi 215 | apt-get -y update 216 | for depend in ${apt_depends[@]}; do 217 | error_detect_depends "apt-get -y install ${depend}" 218 | done 219 | if [[ ${fastmode} = "0" ]]; then 220 | error_detect_depends "apt-get -y install build-essential" 221 | fi 222 | fi 223 | } 224 | 225 | install_dnsmasq(){ 226 | netstat -a -n -p | grep LISTEN | grep -P "\d+\.\d+\.\d+\.\d+:53\s+" > /dev/null && echo -e "[${red}Error${plain}] required port 53 already in use\n" && exit 1 227 | echo "安装Dnsmasq..." 228 | if check_sys packageManager yum; then 229 | error_detect_depends "yum -y install dnsmasq" 230 | if centosversion 6; then 231 | error_detect_depends "yum -y install make" 232 | error_detect_depends "yum -y install gcc-c++" 233 | cd /tmp/ 234 | if [ -e dnsmasq-2.80 ]; then 235 | rm -rf dnsmasq-2.80 236 | fi 237 | download dnsmasq-2.80.tar.gz http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.80.tar.gz 238 | tar -zxf dnsmasq-2.80.tar.gz 239 | cd dnsmasq-2.80 240 | make 241 | if [ $? -ne 0 ]; then 242 | echo -e "[${red}Error${plain}] dnsmasq upgrade failed." 243 | rm -rf /tmp/dnsmasq-2.80 /tmp/dnsmasq-2.80.tar.gz 244 | exit 1 245 | fi 246 | yes|cp -f /tmp/dnsmasq-2.80/src/dnsmasq /usr/sbin/dnsmasq && chmod 755 /usr/sbin/dnsmasq 247 | fi 248 | elif check_sys packageManager apt; then 249 | error_detect_depends "apt-get -y install dnsmasq" 250 | fi 251 | [ ! -f /usr/sbin/dnsmasq ] && echo -e "[${red}Error${plain}] 安装dnsmasq出现问题,请检查." && exit 1 252 | download /etc/dnsmasq.d/custom_netflix.conf https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq.conf 253 | download /tmp/proxy-domains-tw.txt https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/proxy-domains-tw.txt 254 | for domain in $(cat /tmp/proxy-domains-tw.txt); do 255 | printf "address=/${domain}/${publicip}\n"\ 256 | | tee -a /etc/dnsmasq.d/custom_netflix.conf > /dev/null 2>&1 257 | done 258 | [ "$(grep -x -E "(conf-dir=/etc/dnsmasq.d|conf-dir=/etc/dnsmasq.d,.bak|conf-dir=/etc/dnsmasq.d/,\*.conf|conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig)" /etc/dnsmasq.conf)" ] || echo -e "\nconf-dir=/etc/dnsmasq.d" >> /etc/dnsmasq.conf 259 | echo "启动 Dnsmasq 服务..." 260 | if check_sys packageManager yum; then 261 | if centosversion 6; then 262 | chkconfig dnsmasq on 263 | service dnsmasq start 264 | elif centosversion 7 || centosversion 8; then 265 | systemctl enable dnsmasq 266 | systemctl start dnsmasq 267 | fi 268 | elif check_sys packageManager apt; then 269 | systemctl enable dnsmasq 270 | systemctl restart dnsmasq 271 | fi 272 | cd /tmp 273 | rm -rf /tmp/dnsmasq-2.80 /tmp/dnsmasq-2.80.tar.gz /tmp/proxy-domains-tw.txt 274 | echo -e "[${green}Info${plain}] dnsmasq install complete..." 275 | } 276 | 277 | install_sniproxy(){ 278 | for aport in 80 443; do 279 | netstat -a -n -p | grep LISTEN | grep -P "\d+\.\d+\.\d+\.\d+:${aport}\s+" > /dev/null && echo -e "[${red}Error${plain}] required port ${aport} already in use\n" && exit 1 280 | done 281 | install_dependencies 282 | echo "安装SNI Proxy..." 283 | if check_sys packageManager yum; then 284 | rpm -qa | grep sniproxy >/dev/null 2>&1 285 | if [ $? -eq 0 ]; then 286 | rpm -e sniproxy 287 | fi 288 | elif check_sys packageManager apt; then 289 | dpkg -s sniproxy >/dev/null 2>&1 290 | if [ $? -eq 0 ]; then 291 | dpkg -r sniproxy 292 | fi 293 | fi 294 | bit=`uname -m` 295 | cd /tmp 296 | if [[ ${fastmode} = "0" ]]; then 297 | if [ -e sniproxy ]; then 298 | rm -rf sniproxy 299 | fi 300 | git clone https://github.com/dlundquist/sniproxy.git 301 | cd sniproxy 302 | fi 303 | if check_sys packageManager yum; then 304 | if [[ ${fastmode} = "1" ]]; then 305 | if [[ ${bit} = "x86_64" ]]; then 306 | download /tmp/sniproxy-0.6.0.el7.x86_64.rpm https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy-0.6.0.el7.x86_64.rpm 307 | error_detect_depends "yum -y install /tmp/sniproxy-0.6.0.el7.x86_64.rpm" 308 | rm -rf /tmp/sniproxy-0.6.0.el7.x86_64.rpm 309 | else 310 | echo -e "${red}暂不支持${bit}内核,请使用编译模式安装!${plain}" && exit 1 311 | fi 312 | else 313 | ./autogen.sh && ./configure && make dist 314 | if centosversion 6; then 315 | scl enable devtoolset-6 'rpmbuild --define "_sourcedir `pwd`" --define "_topdir /tmp/sniproxy/rpmbuild" --define "debug_package %{nil}" -ba redhat/sniproxy.spec' 316 | elif centosversion 7 || centosversion 8; then 317 | sed -i "s/\%configure CFLAGS\=\"-I\/usr\/include\/libev\"/\%configure CFLAGS\=\"-fPIC -I\/usr\/include\/libev\"/" redhat/sniproxy.spec 318 | rpmbuild --define "_sourcedir `pwd`" --define "_topdir /tmp/sniproxy/rpmbuild" --define "debug_package %{nil}" -ba redhat/sniproxy.spec 319 | fi 320 | error_detect_depends "yum -y install /tmp/sniproxy/rpmbuild/RPMS/x86_64/sniproxy-*.rpm" 321 | fi 322 | download /etc/init.d/sniproxy https://raw.githubusercontent.com/dlundquist/sniproxy/master/redhat/sniproxy.init && chmod +x /etc/init.d/sniproxy 323 | elif check_sys packageManager apt; then 324 | if [[ ${fastmode} = "1" ]]; then 325 | if [[ ${bit} = "x86_64" ]]; then 326 | download /tmp/sniproxy_0.6.0_amd64.deb https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy_0.6.0_amd64.deb 327 | error_detect_depends "dpkg -i --no-debsig /tmp/sniproxy_0.6.0_amd64.deb" 328 | rm -rf /tmp/sniproxy_0.6.0_amd64.deb 329 | elif [[ ${bit} = "i386" ]]; then 330 | download /tmp/sniproxy_0.6.0_i386.deb https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy_0.6.0_i386.deb 331 | error_detect_depends "dpkg -i --no-debsig /tmp/sniproxy_0.6.0_i386.deb" 332 | rm -rf /tmp/sniproxy_0.6.0_i386.deb 333 | else 334 | echo -e "${red}暂不支持${bit}内核,请使用编译模式安装!${plain}" && exit 1 335 | fi 336 | else 337 | ./autogen.sh && dpkg-buildpackage 338 | error_detect_depends "dpkg -i --no-debsig ../sniproxy_*.deb" 339 | rm -rf /tmp/sniproxy*.deb 340 | fi 341 | download /etc/init.d/sniproxy https://raw.githubusercontent.com/dlundquist/sniproxy/master/debian/init.d && chmod +x /etc/init.d/sniproxy 342 | download /etc/default/sniproxy https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/sniproxy.default 343 | fi 344 | [ ! -f /usr/sbin/sniproxy ] && echo -e "[${red}Error${plain}] 安装Sniproxy出现问题,请检查." && exit 1 345 | [ ! -f /etc/init.d/sniproxy ] && echo -e "[${red}Error${plain}] 下载Sniproxy启动文件出现问题,请检查." && exit 1 346 | download /etc/sniproxy.conf https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/sniproxy.conf 347 | download /tmp/sniproxy-domains.txt https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/proxy-domains-tw.txt 348 | sed -i -e 's/\./\\\./g' -e 's/^/ \.\*/' -e 's/$/\$ \*/' /tmp/sniproxy-domains.txt || (echo -e "[${red}Error:${plain}] Failed to configuration sniproxy." && exit 1) 349 | sed -i '/table {/r /tmp/sniproxy-domains.txt' /etc/sniproxy.conf || (echo -e "[${red}Error:${plain}] Failed to configuration sniproxy." && exit 1) 350 | if [ ! -e /var/log/sniproxy ]; then 351 | mkdir /var/log/sniproxy 352 | fi 353 | echo "启动 SNI Proxy 服务..." 354 | if check_sys packageManager yum; then 355 | if centosversion 6; then 356 | chkconfig sniproxy on > /dev/null 2>&1 357 | service sniproxy start || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 358 | elif centosversion 7 || centosversion 8; then 359 | systemctl enable sniproxy > /dev/null 2>&1 360 | systemctl start sniproxy || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 361 | fi 362 | elif check_sys packageManager apt; then 363 | systemctl daemon-reload 364 | systemctl enable sniproxy > /dev/null 2>&1 365 | systemctl restart sniproxy || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 366 | fi 367 | cd /tmp 368 | rm -rf /tmp/sniproxy/ 369 | rm -rf /tmp/sniproxy-domains.txt 370 | echo -e "[${green}Info${plain}] sniproxy install complete..." 371 | } 372 | 373 | install_check(){ 374 | if check_sys packageManager yum || check_sys packageManager apt; then 375 | if centosversion 5; then 376 | return 1 377 | fi 378 | return 0 379 | else 380 | return 1 381 | fi 382 | } 383 | 384 | ready_install(){ 385 | echo "检测您的系統..." 386 | if ! install_check; then 387 | echo -e "[${red}Error${plain}] Your OS is not supported to run it!" 388 | echo -e "Please change to CentOS 6+/Debian 8+/Ubuntu 16+ and try again." 389 | exit 1 390 | fi 391 | if check_sys packageManager yum; then 392 | error_detect_depends "yum -y install net-tools" 393 | elif check_sys packageManager apt; then 394 | error_detect_depends "apt-get -y install net-tools" 395 | fi 396 | disable_selinux 397 | if check_sys packageManager yum; then 398 | config_firewall 399 | fi 400 | echo -e "[${green}Info${plain}] Checking the system complete..." 401 | } 402 | 403 | hello(){ 404 | echo "" 405 | echo -e "${yellow}Dnsmasq + SNI Proxy自助安装脚本${plain}" 406 | echo -e "${yellow}支持系统: CentOS 6+, Debian8+, Ubuntu16+${plain}" 407 | echo "" 408 | } 409 | 410 | help(){ 411 | hello 412 | echo "使用方法:bash $0 [-h] [-i] [-f] [-id] [-is] [-fs] [-u] [-ud] [-us]" 413 | echo "" 414 | echo " -h , --help 显示帮助信息" 415 | echo " -i , --install 安装 Dnsmasq + SNI Proxy" 416 | echo " -f , --fastinstall 快速安装 Dnsmasq + SNI Proxy" 417 | echo " -id, --installdnsmasq 仅安装 Dnsmasq" 418 | echo " -is, --installsniproxy 仅安装 SNI Proxy" 419 | echo " -fs, --fastinstallsniproxy 快速安装 SNI Proxy" 420 | echo " -u , --uninstall 卸载 Dnsmasq + SNI Proxy" 421 | echo " -ud, --undnsmasq 卸载 Dnsmasq" 422 | echo " -us, --unsniproxy 卸载 SNI Proxy" 423 | echo "" 424 | } 425 | 426 | install_all(){ 427 | ports="53 80 443" 428 | publicip=$(get_ip) 429 | hello 430 | ready_install 431 | install_dnsmasq 432 | install_sniproxy 433 | echo "" 434 | echo -e "${yellow}Dnsmasq + SNI Proxy 已完成安装!${plain}" 435 | echo "" 436 | echo -e "${yellow}将您的DNS更改为 $(get_ip) 即可以观看台湾流媒体节目了。${plain}" 437 | echo "" 438 | } 439 | 440 | only_dnsmasq(){ 441 | ports="53" 442 | hello 443 | ready_install 444 | inputipcount=1 445 | echo -e "请输入SNIProxy服务器的IP地址" 446 | read -e -p "(默认为本机公网IP): " inputip 447 | while true; do 448 | if [ "${inputipcount}" == 3 ]; then 449 | echo -e "[${red}Error:${plain}] IP输入错误次数过多,请重新执行脚本。" 450 | exit 1 451 | fi 452 | if [ -z ${inputip} ]; then 453 | publicip=$(get_ip) 454 | break 455 | else 456 | check_ip ${inputip} 457 | if [ $? -eq 0 ]; then 458 | publicip=${inputip} 459 | break 460 | else 461 | echo -e "请重新输入SNIProxy服务器的IP地址" 462 | read -e -p "(默认为本机公网IP): " inputip 463 | fi 464 | fi 465 | inputipcount=`expr ${inputipcount} + 1` 466 | done 467 | install_dnsmasq 468 | echo "" 469 | echo -e "${yellow}Dnsmasq 已完成安装!${plain}" 470 | echo "" 471 | echo -e "${yellow}将您的DNS更改为 $(get_ip) 即可以观看台湾流媒体节目了。${plain}" 472 | echo "" 473 | } 474 | 475 | only_sniproxy(){ 476 | ports="80 443" 477 | hello 478 | ready_install 479 | install_sniproxy 480 | echo "" 481 | echo -e "${yellow}SNI Proxy 已完成安装!${plain}" 482 | echo "" 483 | echo -e "${yellow}将台湾流媒体的相关域名解析到 $(get_ip) 即可以观看台湾流媒体节目了。${plain}" 484 | echo "" 485 | } 486 | 487 | undnsmasq(){ 488 | echo -e "[${green}Info${plain}] Stoping dnsmasq services." 489 | if check_sys packageManager yum; then 490 | if centosversion 6; then 491 | chkconfig dnsmasq off > /dev/null 2>&1 492 | service dnsmasq stop || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 493 | elif centosversion 7 || centosversion 8; then 494 | systemctl disable dnsmasq > /dev/null 2>&1 495 | systemctl stop dnsmasq || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 496 | fi 497 | elif check_sys packageManager apt; then 498 | systemctl disable dnsmasq > /dev/null 2>&1 499 | systemctl stop dnsmasq || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 500 | fi 501 | echo -e "[${green}Info${plain}] Starting to uninstall dnsmasq services." 502 | if check_sys packageManager yum; then 503 | yum remove dnsmasq -y > /dev/null 2>&1 504 | if [ $? -ne 0 ]; then 505 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}dnsmasq${plain}" 506 | fi 507 | elif check_sys packageManager apt; then 508 | apt-get remove dnsmasq -y > /dev/null 2>&1 509 | if [ $? -ne 0 ]; then 510 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}dnsmasq${plain}" 511 | fi 512 | fi 513 | rm -rf /etc/dnsmasq.d/custom_netflix.conf 514 | echo -e "[${green}Info${plain}] services uninstall dnsmasq complete..." 515 | } 516 | 517 | unsniproxy(){ 518 | echo -e "[${green}Info${plain}] Stoping sniproxy services." 519 | if check_sys packageManager yum; then 520 | if centosversion 6; then 521 | chkconfig sniproxy off > /dev/null 2>&1 522 | service sniproxy stop || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 523 | elif centosversion 7 || centosversion 8; then 524 | systemctl disable sniproxy > /dev/null 2>&1 525 | systemctl stop sniproxy || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 526 | fi 527 | elif check_sys packageManager apt; then 528 | systemctl disable sniproxy > /dev/null 2>&1 529 | systemctl stop sniproxy || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 530 | fi 531 | echo -e "[${green}Info${plain}] Starting to uninstall sniproxy services." 532 | if check_sys packageManager yum; then 533 | yum remove sniproxy -y > /dev/null 2>&1 534 | if [ $? -ne 0 ]; then 535 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}sniproxy${plain}" 536 | fi 537 | elif check_sys packageManager apt; then 538 | apt-get remove sniproxy -y > /dev/null 2>&1 539 | if [ $? -ne 0 ]; then 540 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}sniproxy${plain}" 541 | fi 542 | fi 543 | rm -rf /etc/sniproxy.conf 544 | echo -e "[${green}Info${plain}] services uninstall sniproxy complete..." 545 | } 546 | 547 | confirm(){ 548 | echo -e "${yellow}是否继续执行?(n:取消/y:继续)${plain}" 549 | read -e -p "(默认:取消): " selection 550 | [ -z "${selection}" ] && selection="n" 551 | if [ ${selection} != "y" ]; then 552 | exit 0 553 | fi 554 | } 555 | 556 | if [[ $# = 1 ]];then 557 | key="$1" 558 | case $key in 559 | -i|--install) 560 | fastmode=0 561 | install_all 562 | ;; 563 | -f|--fastinstall) 564 | fastmode=1 565 | install_all 566 | ;; 567 | -id|--installdnsmasq) 568 | fastmode=0 569 | only_dnsmasq 570 | ;; 571 | -is|--installsniproxy) 572 | fastmode=0 573 | only_sniproxy 574 | ;; 575 | -fs|--fastinstallsniproxy) 576 | fastmode=1 577 | only_sniproxy 578 | ;; 579 | -u|--uninstall) 580 | hello 581 | echo -e "${yellow}正在执行卸载Dnsmasq和SNI Proxy.${plain}" 582 | confirm 583 | undnsmasq 584 | unsniproxy 585 | ;; 586 | -ud|--undnsmasq) 587 | hello 588 | echo -e "${yellow}正在执行卸载Dnsmasq.${plain}" 589 | confirm 590 | undnsmasq 591 | ;; 592 | -us|--unsniproxy) 593 | hello 594 | echo -e "${yellow}正在执行卸载SNI Proxy.${plain}" 595 | confirm 596 | unsniproxy 597 | ;; 598 | -h|--help|*) 599 | help 600 | ;; 601 | esac 602 | else 603 | help 604 | fi 605 | -------------------------------------------------------------------------------- /dnsmasq_sniproxy_youtube.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | red='\033[0;31m' 6 | green='\033[0;32m' 7 | yellow='\033[0;33m' 8 | plain='\033[0m' 9 | 10 | [[ $EUID -ne 0 ]] && echo -e "[${red}Error${plain}] 请使用root用户来执行脚本!" && exit 1 11 | 12 | disable_selinux(){ 13 | if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then 14 | sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 15 | setenforce 0 16 | fi 17 | } 18 | 19 | check_sys(){ 20 | local checkType=$1 21 | local value=$2 22 | 23 | local release='' 24 | local systemPackage='' 25 | 26 | if [[ -f /etc/redhat-release ]]; then 27 | release="centos" 28 | systemPackage="yum" 29 | elif grep -Eqi "debian|raspbian" /etc/issue; then 30 | release="debian" 31 | systemPackage="apt" 32 | elif grep -Eqi "ubuntu" /etc/issue; then 33 | release="ubuntu" 34 | systemPackage="apt" 35 | elif grep -Eqi "centos|red hat|redhat" /etc/issue; then 36 | release="centos" 37 | systemPackage="yum" 38 | elif grep -Eqi "debian|raspbian" /proc/version; then 39 | release="debian" 40 | systemPackage="apt" 41 | elif grep -Eqi "ubuntu" /proc/version; then 42 | release="ubuntu" 43 | systemPackage="apt" 44 | elif grep -Eqi "centos|red hat|redhat" /proc/version; then 45 | release="centos" 46 | systemPackage="yum" 47 | fi 48 | 49 | if [[ "${checkType}" == "sysRelease" ]]; then 50 | if [ "${value}" == "${release}" ]; then 51 | return 0 52 | else 53 | return 1 54 | fi 55 | elif [[ "${checkType}" == "packageManager" ]]; then 56 | if [ "${value}" == "${systemPackage}" ]; then 57 | return 0 58 | else 59 | return 1 60 | fi 61 | fi 62 | } 63 | 64 | getversion(){ 65 | if [[ -s /etc/redhat-release ]]; then 66 | grep -oE "[0-9.]+" /etc/redhat-release 67 | else 68 | grep -oE "[0-9.]+" /etc/issue 69 | fi 70 | } 71 | 72 | centosversion(){ 73 | if check_sys sysRelease centos; then 74 | local code=$1 75 | local version="$(getversion)" 76 | local main_ver=${version%%.*} 77 | if [ "$main_ver" == "$code" ]; then 78 | return 0 79 | else 80 | return 1 81 | fi 82 | else 83 | return 1 84 | fi 85 | } 86 | 87 | get_ip(){ 88 | local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 ) 89 | [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com ) 90 | [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip ) 91 | echo ${IP} 92 | } 93 | 94 | check_ip(){ 95 | local checkip=$1 96 | local valid_check=$(echo $checkip|awk -F. '$1<=255&&$2<=255&&$3<=255&&$4<=255{print "yes"}') 97 | if echo $checkip|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then 98 | if [ ${valid_check:-no} == "yes" ]; then 99 | return 0 100 | else 101 | echo -e "[${red}Error${plain}] IP $checkip not available!" 102 | return 1 103 | fi 104 | else 105 | echo -e "[${red}Error${plain}] IP format error!" 106 | return 1 107 | fi 108 | } 109 | 110 | download(){ 111 | local filename=${1} 112 | echo -e "[${green}Info${plain}] ${filename} download configuration now..." 113 | wget --no-check-certificate -q -t3 -T60 -O ${1} ${2} 114 | if [ $? -ne 0 ]; then 115 | echo -e "[${red}Error${plain}] Download ${filename} failed." 116 | exit 1 117 | fi 118 | } 119 | 120 | error_detect_depends(){ 121 | local command=$1 122 | local depend=`echo "${command}" | awk '{print $4}'` 123 | echo -e "[${green}Info${plain}] Starting to install package ${depend}" 124 | ${command} > /dev/null 2>&1 125 | if [ $? -ne 0 ]; then 126 | echo -e "[${red}Error${plain}] Failed to install ${red}${depend}${plain}" 127 | exit 1 128 | fi 129 | } 130 | 131 | config_firewall(){ 132 | if centosversion 6; then 133 | /etc/init.d/iptables status > /dev/null 2>&1 134 | if [ $? -eq 0 ]; then 135 | for port in ${ports}; do 136 | iptables -L -n | grep -i ${port} > /dev/null 2>&1 137 | if [ $? -ne 0 ]; then 138 | iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${port} -j ACCEPT 139 | if [ ${port} == "53" ]; then 140 | iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${port} -j ACCEPT 141 | fi 142 | else 143 | echo -e "[${green}Info${plain}] port ${green}${port}${plain} already be enabled." 144 | fi 145 | done 146 | /etc/init.d/iptables save 147 | /etc/init.d/iptables restart 148 | else 149 | echo -e "[${yellow}Warning${plain}] iptables looks like not running or not installed, please enable port ${ports} manually if necessary." 150 | fi 151 | elif centosversion 7 || centosversion 8; then 152 | systemctl status firewalld > /dev/null 2>&1 153 | if [ $? -eq 0 ]; then 154 | default_zone=$(firewall-cmd --get-default-zone) 155 | for port in ${ports}; do 156 | firewall-cmd --permanent --zone=${default_zone} --add-port=${port}/tcp 157 | if [ ${port} == "53" ]; then 158 | firewall-cmd --permanent --zone=${default_zone} --add-port=${port}/udp 159 | fi 160 | firewall-cmd --reload 161 | done 162 | else 163 | echo -e "[${yellow}Warning${plain}] firewalld looks like not running or not installed, please enable port ${ports} manually if necessary." 164 | fi 165 | fi 166 | } 167 | 168 | install_dependencies(){ 169 | echo "安装依赖软件..." 170 | if check_sys packageManager yum; then 171 | echo -e "[${green}Info${plain}] Checking the EPEL repository..." 172 | if [ ! -f /etc/yum.repos.d/epel.repo ]; then 173 | yum install -y epel-release > /dev/null 2>&1 174 | fi 175 | [ ! -f /etc/yum.repos.d/epel.repo ] && echo -e "[${red}Error${plain}] Install EPEL repository failed, please check it." && exit 1 176 | [ ! "$(command -v yum-config-manager)" ] && yum install -y yum-utils > /dev/null 2>&1 177 | [ x"$(yum-config-manager epel | grep -w enabled | awk '{print $3}')" != x"True" ] && yum-config-manager --enable epel > /dev/null 2>&1 178 | echo -e "[${green}Info${plain}] Checking the EPEL repository complete..." 179 | 180 | if [[ ${fastmode} = "1" ]]; then 181 | yum_depends=( 182 | curl gettext-devel libev-devel pcre-devel perl udns-devel 183 | ) 184 | else 185 | yum_depends=( 186 | wget git autoconf automake curl gettext-devel libev-devel pcre-devel perl pkgconfig rpm-build udns-devel 187 | ) 188 | fi 189 | for depend in ${yum_depends[@]}; do 190 | error_detect_depends "yum -y install ${depend}" 191 | done 192 | if [[ ${fastmode} = "0" ]]; then 193 | if centosversion 6; then 194 | error_detect_depends "yum -y groupinstall development" 195 | error_detect_depends "yum -y install centos-release-scl" 196 | error_detect_depends "yum -y install devtoolset-6-gcc-c++" 197 | elif centosversion 7 || centosversion 8; then 198 | yum groups list development | grep Installed > /dev/null 2>&1 199 | if [[ $? -eq 0 ]]; then 200 | yum groups mark remove development -y > /dev/null 2>&1 201 | fi 202 | error_detect_depends "yum -y groupinstall development" 203 | fi 204 | fi 205 | elif check_sys packageManager apt; then 206 | if [[ ${fastmode} = "1" ]]; then 207 | apt_depends=( 208 | curl gettext libev-dev libpcre3-dev libudns-dev 209 | ) 210 | else 211 | apt_depends=( 212 | wget git autotools-dev cdbs debhelper dh-autoreconf dpkg-dev gettext libev-dev libpcre3-dev libudns-dev pkg-config fakeroot devscripts 213 | ) 214 | fi 215 | apt-get -y update 216 | for depend in ${apt_depends[@]}; do 217 | error_detect_depends "apt-get -y install ${depend}" 218 | done 219 | if [[ ${fastmode} = "0" ]]; then 220 | error_detect_depends "apt-get -y install build-essential" 221 | fi 222 | fi 223 | } 224 | 225 | install_dnsmasq(){ 226 | netstat -a -n -p | grep LISTEN | grep -P "\d+\.\d+\.\d+\.\d+:53\s+" > /dev/null && echo -e "[${red}Error${plain}] required port 53 already in use\n" && exit 1 227 | echo "安装Dnsmasq..." 228 | if check_sys packageManager yum; then 229 | error_detect_depends "yum -y install dnsmasq" 230 | if centosversion 6; then 231 | error_detect_depends "yum -y install make" 232 | error_detect_depends "yum -y install gcc-c++" 233 | cd /tmp/ 234 | if [ -e dnsmasq-2.80 ]; then 235 | rm -rf dnsmasq-2.80 236 | fi 237 | download dnsmasq-2.80.tar.gz http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.80.tar.gz 238 | tar -zxf dnsmasq-2.80.tar.gz 239 | cd dnsmasq-2.80 240 | make 241 | if [ $? -ne 0 ]; then 242 | echo -e "[${red}Error${plain}] dnsmasq upgrade failed." 243 | rm -rf /tmp/dnsmasq-2.80 /tmp/dnsmasq-2.80.tar.gz 244 | exit 1 245 | fi 246 | yes|cp -f /tmp/dnsmasq-2.80/src/dnsmasq /usr/sbin/dnsmasq && chmod 755 /usr/sbin/dnsmasq 247 | fi 248 | elif check_sys packageManager apt; then 249 | error_detect_depends "apt-get -y install dnsmasq" 250 | fi 251 | [ ! -f /usr/sbin/dnsmasq ] && echo -e "[${red}Error${plain}] 安装dnsmasq出现问题,请检查." && exit 1 252 | download /etc/dnsmasq.d/custom_netflix.conf https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/dnsmasq.conf 253 | download /tmp/proxy-domains-youtube.txt https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/proxy-domains-youtube.txt 254 | for domain in $(cat /tmp/proxy-domains-youtube.txt); do 255 | printf "address=/${domain}/${publicip}\n"\ 256 | | tee -a /etc/dnsmasq.d/custom_netflix.conf > /dev/null 2>&1 257 | done 258 | [ "$(grep -x -E "(conf-dir=/etc/dnsmasq.d|conf-dir=/etc/dnsmasq.d,.bak|conf-dir=/etc/dnsmasq.d/,\*.conf|conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig)" /etc/dnsmasq.conf)" ] || echo -e "\nconf-dir=/etc/dnsmasq.d" >> /etc/dnsmasq.conf 259 | echo "启动 Dnsmasq 服务..." 260 | if check_sys packageManager yum; then 261 | if centosversion 6; then 262 | chkconfig dnsmasq on 263 | service dnsmasq start 264 | elif centosversion 7 || centosversion 8; then 265 | systemctl enable dnsmasq 266 | systemctl start dnsmasq 267 | fi 268 | elif check_sys packageManager apt; then 269 | systemctl enable dnsmasq 270 | systemctl restart dnsmasq 271 | fi 272 | cd /tmp 273 | rm -rf /tmp/dnsmasq-2.80 /tmp/dnsmasq-2.80.tar.gz /tmp/proxy-domains-youtube.txt 274 | echo -e "[${green}Info${plain}] dnsmasq install complete..." 275 | } 276 | 277 | install_sniproxy(){ 278 | for aport in 80 443; do 279 | netstat -a -n -p | grep LISTEN | grep -P "\d+\.\d+\.\d+\.\d+:${aport}\s+" > /dev/null && echo -e "[${red}Error${plain}] required port ${aport} already in use\n" && exit 1 280 | done 281 | install_dependencies 282 | echo "安装SNI Proxy..." 283 | if check_sys packageManager yum; then 284 | rpm -qa | grep sniproxy >/dev/null 2>&1 285 | if [ $? -eq 0 ]; then 286 | rpm -e sniproxy 287 | fi 288 | elif check_sys packageManager apt; then 289 | dpkg -s sniproxy >/dev/null 2>&1 290 | if [ $? -eq 0 ]; then 291 | dpkg -r sniproxy 292 | fi 293 | fi 294 | bit=`uname -m` 295 | cd /tmp 296 | if [[ ${fastmode} = "0" ]]; then 297 | if [ -e sniproxy ]; then 298 | rm -rf sniproxy 299 | fi 300 | git clone https://github.com/dlundquist/sniproxy.git 301 | cd sniproxy 302 | fi 303 | if check_sys packageManager yum; then 304 | if [[ ${fastmode} = "1" ]]; then 305 | if [[ ${bit} = "x86_64" ]]; then 306 | download /tmp/sniproxy-0.6.0.el7.x86_64.rpm https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy-0.6.0.el7.x86_64.rpm 307 | error_detect_depends "yum -y install /tmp/sniproxy-0.6.0.el7.x86_64.rpm" 308 | rm -rf /tmp/sniproxy-0.6.0.el7.x86_64.rpm 309 | else 310 | echo -e "${red}暂不支持${bit}内核,请使用编译模式安装!${plain}" && exit 1 311 | fi 312 | else 313 | ./autogen.sh && ./configure && make dist 314 | if centosversion 6; then 315 | scl enable devtoolset-6 'rpmbuild --define "_sourcedir `pwd`" --define "_topdir /tmp/sniproxy/rpmbuild" --define "debug_package %{nil}" -ba redhat/sniproxy.spec' 316 | elif centosversion 7 || centosversion 8; then 317 | sed -i "s/\%configure CFLAGS\=\"-I\/usr\/include\/libev\"/\%configure CFLAGS\=\"-fPIC -I\/usr\/include\/libev\"/" redhat/sniproxy.spec 318 | rpmbuild --define "_sourcedir `pwd`" --define "_topdir /tmp/sniproxy/rpmbuild" --define "debug_package %{nil}" -ba redhat/sniproxy.spec 319 | fi 320 | error_detect_depends "yum -y install /tmp/sniproxy/rpmbuild/RPMS/x86_64/sniproxy-*.rpm" 321 | fi 322 | download /etc/init.d/sniproxy https://raw.githubusercontent.com/dlundquist/sniproxy/master/redhat/sniproxy.init && chmod +x /etc/init.d/sniproxy 323 | elif check_sys packageManager apt; then 324 | if [[ ${fastmode} = "1" ]]; then 325 | if [[ ${bit} = "x86_64" ]]; then 326 | download /tmp/sniproxy_0.6.0_amd64.deb https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy_0.6.0_amd64.deb 327 | error_detect_depends "dpkg -i --no-debsig /tmp/sniproxy_0.6.0_amd64.deb" 328 | rm -rf /tmp/sniproxy_0.6.0_amd64.deb 329 | elif [[ ${bit} = "i386" ]]; then 330 | download /tmp/sniproxy_0.6.0_i386.deb https://github.com/codionx/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy_0.6.0_i386.deb 331 | error_detect_depends "dpkg -i --no-debsig /tmp/sniproxy_0.6.0_i386.deb" 332 | rm -rf /tmp/sniproxy_0.6.0_i386.deb 333 | else 334 | echo -e "${red}暂不支持${bit}内核,请使用编译模式安装!${plain}" && exit 1 335 | fi 336 | else 337 | ./autogen.sh && dpkg-buildpackage 338 | error_detect_depends "dpkg -i --no-debsig ../sniproxy_*.deb" 339 | rm -rf /tmp/sniproxy*.deb 340 | fi 341 | download /etc/init.d/sniproxy https://raw.githubusercontent.com/dlundquist/sniproxy/master/debian/init.d && chmod +x /etc/init.d/sniproxy 342 | download /etc/default/sniproxy https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/sniproxy.default 343 | fi 344 | [ ! -f /usr/sbin/sniproxy ] && echo -e "[${red}Error${plain}] 安装Sniproxy出现问题,请检查." && exit 1 345 | [ ! -f /etc/init.d/sniproxy ] && echo -e "[${red}Error${plain}] 下载Sniproxy启动文件出现问题,请检查." && exit 1 346 | download /etc/sniproxy.conf https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/sniproxy.conf 347 | download /tmp/sniproxy-domains.txt https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/master/proxy-domains-youtube.txt 348 | sed -i -e 's/\./\\\./g' -e 's/^/ \.\*/' -e 's/$/\$ \*/' /tmp/sniproxy-domains.txt || (echo -e "[${red}Error:${plain}] Failed to configuration sniproxy." && exit 1) 349 | sed -i '/table {/r /tmp/sniproxy-domains.txt' /etc/sniproxy.conf || (echo -e "[${red}Error:${plain}] Failed to configuration sniproxy." && exit 1) 350 | if [ ! -e /var/log/sniproxy ]; then 351 | mkdir /var/log/sniproxy 352 | fi 353 | echo "启动 SNI Proxy 服务..." 354 | if check_sys packageManager yum; then 355 | if centosversion 6; then 356 | chkconfig sniproxy on > /dev/null 2>&1 357 | service sniproxy start || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 358 | elif centosversion 7 || centosversion 8; then 359 | systemctl enable sniproxy > /dev/null 2>&1 360 | systemctl start sniproxy || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 361 | fi 362 | elif check_sys packageManager apt; then 363 | systemctl daemon-reload 364 | systemctl enable sniproxy > /dev/null 2>&1 365 | systemctl restart sniproxy || (echo -e "[${red}Error:${plain}] Failed to start sniproxy." && exit 1) 366 | fi 367 | cd /tmp 368 | rm -rf /tmp/sniproxy/ 369 | rm -rf /tmp/sniproxy-domains.txt 370 | echo -e "[${green}Info${plain}] sniproxy install complete..." 371 | } 372 | 373 | install_check(){ 374 | if check_sys packageManager yum || check_sys packageManager apt; then 375 | if centosversion 5; then 376 | return 1 377 | fi 378 | return 0 379 | else 380 | return 1 381 | fi 382 | } 383 | 384 | ready_install(){ 385 | echo "检测您的系統..." 386 | if ! install_check; then 387 | echo -e "[${red}Error${plain}] Your OS is not supported to run it!" 388 | echo -e "Please change to CentOS 6+/Debian 8+/Ubuntu 16+ and try again." 389 | exit 1 390 | fi 391 | if check_sys packageManager yum; then 392 | error_detect_depends "yum -y install net-tools" 393 | elif check_sys packageManager apt; then 394 | error_detect_depends "apt-get -y install net-tools" 395 | fi 396 | disable_selinux 397 | if check_sys packageManager yum; then 398 | config_firewall 399 | fi 400 | echo -e "[${green}Info${plain}] Checking the system complete..." 401 | } 402 | 403 | hello(){ 404 | echo "" 405 | echo -e "${yellow}Dnsmasq + SNI Proxy自助安装脚本${plain}" 406 | echo -e "${yellow}支持系统: CentOS 6+, Debian8+, Ubuntu16+${plain}" 407 | echo "" 408 | } 409 | 410 | help(){ 411 | hello 412 | echo "使用方法:bash $0 [-h] [-i] [-f] [-id] [-is] [-fs] [-u] [-ud] [-us]" 413 | echo "" 414 | echo " -h , --help 显示帮助信息" 415 | echo " -i , --install 安装 Dnsmasq + SNI Proxy" 416 | echo " -f , --fastinstall 快速安装 Dnsmasq + SNI Proxy" 417 | echo " -id, --installdnsmasq 仅安装 Dnsmasq" 418 | echo " -is, --installsniproxy 仅安装 SNI Proxy" 419 | echo " -fs, --fastinstallsniproxy 快速安装 SNI Proxy" 420 | echo " -u , --uninstall 卸载 Dnsmasq + SNI Proxy" 421 | echo " -ud, --undnsmasq 卸载 Dnsmasq" 422 | echo " -us, --unsniproxy 卸载 SNI Proxy" 423 | echo "" 424 | } 425 | 426 | install_all(){ 427 | ports="53 80 443" 428 | publicip=$(get_ip) 429 | hello 430 | ready_install 431 | install_dnsmasq 432 | install_sniproxy 433 | echo "" 434 | echo -e "${yellow}Dnsmasq + SNI Proxy 已完成安装!${plain}" 435 | echo "" 436 | echo -e "${yellow}将您的DNS更改为 $(get_ip) 即可以观看Youtube节目了。${plain}" 437 | echo "" 438 | } 439 | 440 | only_dnsmasq(){ 441 | ports="53" 442 | hello 443 | ready_install 444 | inputipcount=1 445 | echo -e "请输入SNIProxy服务器的IP地址" 446 | read -e -p "(默认为本机公网IP): " inputip 447 | while true; do 448 | if [ "${inputipcount}" == 3 ]; then 449 | echo -e "[${red}Error:${plain}] IP输入错误次数过多,请重新执行脚本。" 450 | exit 1 451 | fi 452 | if [ -z ${inputip} ]; then 453 | publicip=$(get_ip) 454 | break 455 | else 456 | check_ip ${inputip} 457 | if [ $? -eq 0 ]; then 458 | publicip=${inputip} 459 | break 460 | else 461 | echo -e "请重新输入SNIProxy服务器的IP地址" 462 | read -e -p "(默认为本机公网IP): " inputip 463 | fi 464 | fi 465 | inputipcount=`expr ${inputipcount} + 1` 466 | done 467 | install_dnsmasq 468 | echo "" 469 | echo -e "${yellow}Dnsmasq 已完成安装!${plain}" 470 | echo "" 471 | echo -e "${yellow}将您的DNS更改为 $(get_ip) 即可以观看Youtube节目了。${plain}" 472 | echo "" 473 | } 474 | 475 | only_sniproxy(){ 476 | ports="80 443" 477 | hello 478 | ready_install 479 | install_sniproxy 480 | echo "" 481 | echo -e "${yellow}SNI Proxy 已完成安装!${plain}" 482 | echo "" 483 | echo -e "${yellow}将Youtube的相关域名解析到 $(get_ip) 即可以观看Youtube节目了。${plain}" 484 | echo "" 485 | } 486 | 487 | undnsmasq(){ 488 | echo -e "[${green}Info${plain}] Stoping dnsmasq services." 489 | if check_sys packageManager yum; then 490 | if centosversion 6; then 491 | chkconfig dnsmasq off > /dev/null 2>&1 492 | service dnsmasq stop || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 493 | elif centosversion 7 || centosversion 8; then 494 | systemctl disable dnsmasq > /dev/null 2>&1 495 | systemctl stop dnsmasq || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 496 | fi 497 | elif check_sys packageManager apt; then 498 | systemctl disable dnsmasq > /dev/null 2>&1 499 | systemctl stop dnsmasq || echo -e "[${red}Error:${plain}] Failed to stop dnsmasq." 500 | fi 501 | echo -e "[${green}Info${plain}] Starting to uninstall dnsmasq services." 502 | if check_sys packageManager yum; then 503 | yum remove dnsmasq -y > /dev/null 2>&1 504 | if [ $? -ne 0 ]; then 505 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}dnsmasq${plain}" 506 | fi 507 | elif check_sys packageManager apt; then 508 | apt-get remove dnsmasq -y > /dev/null 2>&1 509 | if [ $? -ne 0 ]; then 510 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}dnsmasq${plain}" 511 | fi 512 | fi 513 | rm -rf /etc/dnsmasq.d/custom_netflix.conf 514 | echo -e "[${green}Info${plain}] services uninstall dnsmasq complete..." 515 | } 516 | 517 | unsniproxy(){ 518 | echo -e "[${green}Info${plain}] Stoping sniproxy services." 519 | if check_sys packageManager yum; then 520 | if centosversion 6; then 521 | chkconfig sniproxy off > /dev/null 2>&1 522 | service sniproxy stop || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 523 | elif centosversion 7 || centosversion 8; then 524 | systemctl disable sniproxy > /dev/null 2>&1 525 | systemctl stop sniproxy || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 526 | fi 527 | elif check_sys packageManager apt; then 528 | systemctl disable sniproxy > /dev/null 2>&1 529 | systemctl stop sniproxy || echo -e "[${red}Error:${plain}] Failed to stop sniproxy." 530 | fi 531 | echo -e "[${green}Info${plain}] Starting to uninstall sniproxy services." 532 | if check_sys packageManager yum; then 533 | yum remove sniproxy -y > /dev/null 2>&1 534 | if [ $? -ne 0 ]; then 535 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}sniproxy${plain}" 536 | fi 537 | elif check_sys packageManager apt; then 538 | apt-get remove sniproxy -y > /dev/null 2>&1 539 | if [ $? -ne 0 ]; then 540 | echo -e "[${red}Error${plain}] Failed to uninstall ${red}sniproxy${plain}" 541 | fi 542 | fi 543 | rm -rf /etc/sniproxy.conf 544 | echo -e "[${green}Info${plain}] services uninstall sniproxy complete..." 545 | } 546 | 547 | confirm(){ 548 | echo -e "${yellow}是否继续执行?(n:取消/y:继续)${plain}" 549 | read -e -p "(默认:取消): " selection 550 | [ -z "${selection}" ] && selection="n" 551 | if [ ${selection} != "y" ]; then 552 | exit 0 553 | fi 554 | } 555 | 556 | if [[ $# = 1 ]];then 557 | key="$1" 558 | case $key in 559 | -i|--install) 560 | fastmode=0 561 | install_all 562 | ;; 563 | -f|--fastinstall) 564 | fastmode=1 565 | install_all 566 | ;; 567 | -id|--installdnsmasq) 568 | fastmode=0 569 | only_dnsmasq 570 | ;; 571 | -is|--installsniproxy) 572 | fastmode=0 573 | only_sniproxy 574 | ;; 575 | -fs|--fastinstallsniproxy) 576 | fastmode=1 577 | only_sniproxy 578 | ;; 579 | -u|--uninstall) 580 | hello 581 | echo -e "${yellow}正在执行卸载Dnsmasq和SNI Proxy.${plain}" 582 | confirm 583 | undnsmasq 584 | unsniproxy 585 | ;; 586 | -ud|--undnsmasq) 587 | hello 588 | echo -e "${yellow}正在执行卸载Dnsmasq.${plain}" 589 | confirm 590 | undnsmasq 591 | ;; 592 | -us|--unsniproxy) 593 | hello 594 | echo -e "${yellow}正在执行卸载SNI Proxy.${plain}" 595 | confirm 596 | unsniproxy 597 | ;; 598 | -h|--help|*) 599 | help 600 | ;; 601 | esac 602 | else 603 | help 604 | fi 605 | -------------------------------------------------------------------------------- /proxy-domains-all.txt: -------------------------------------------------------------------------------- 1 | akadns.net 2 | akam.net 3 | akamai.com 4 | akamai.net 5 | akamaiedge.net 6 | akamaihd.net 7 | akamaistream.net 8 | akamaitech.net 9 | akamaitechnologies.com 10 | akamaitechnologies.fr 11 | akamaized.net 12 | edgekey.net 13 | edgesuite.net 14 | srip.net 15 | footprint.net 16 | level3.net 17 | llnwd.net 18 | edgecastcdn.net 19 | cloudfront.net 20 | netflix.com 21 | netflix.net 22 | nflximg.com 23 | nflximg.net 24 | nflxvideo.net 25 | nflxso.net 26 | nflxext.com 27 | hulu.com 28 | huluim.com 29 | hbonow.com 30 | hbogo.com 31 | hbo.com 32 | amazon.com 33 | amazon.co.uk 34 | amazonvideo.com 35 | crackle.com 36 | pandora.com 37 | vudu.com 38 | blinkbox.com 39 | abc.com 40 | fox.com 41 | theplatform.com 42 | nbc.com 43 | nbcuni.com 44 | ip2location.com 45 | pbs.org 46 | warnerbros.com 47 | southpark.cc.com 48 | cbs.com 49 | brightcove.com 50 | cwtv.com 51 | spike.com 52 | go.com 53 | mtv.com 54 | mtvnservices.com 55 | playstation.net 56 | uplynk.com 57 | maxmind.com 58 | disney.com 59 | disneyjunior.com 60 | adobedtm.com 61 | bam.nr-data.net 62 | bamgrid.com 63 | braze.com 64 | cdn.optimizely.com 65 | cdn.registerdisney.go.com 66 | cws.conviva.com 67 | d9.flashtalking.com 68 | disney-plus.net 69 | disney-portal.my.onetrust.com 70 | disney.demdex.net 71 | disney.my.sentry.io 72 | disneyplus.bn5x.net 73 | disneyplus.com 74 | disneyplus.com.ssl.sc.omtrdc.net 75 | disneystreaming.com 76 | dssott.com 77 | execute-api.us-east-1.amazonaws.com 78 | js-agent.newrelic.com 79 | xboxlive.com 80 | lovefilm.com 81 | turner.com 82 | amctv.com 83 | sho.com 84 | mog.com 85 | wdtvlive.com 86 | beinsportsconnect.tv 87 | beinsportsconnect.net 88 | fig.bbc.co.uk 89 | open.live.bbc.co.uk 90 | sa.bbc.co.uk 91 | www.bbc.co.uk 92 | crunchyroll.com 93 | ifconfig.co 94 | omtrdc.net 95 | sling.com 96 | movetv.com 97 | happyon.jp 98 | abema.tv 99 | hulu.jp 100 | optus.com.au 101 | optusnet.com.au 102 | gamer.com.tw 103 | bahamut.com.tw 104 | hinet.net 105 | youtubei.googleapis.com 106 | yt3.ggpht.com 107 | ggpht.cn 108 | ggpht.com 109 | googlevideo.com 110 | gvt2.com 111 | withyoutube.com 112 | youtu.be 113 | youtube-nocookie.com 114 | youtube.ae 115 | youtube.al 116 | youtube.am 117 | youtube.at 118 | youtube.az 119 | youtube.ba 120 | youtube.be 121 | youtube.bg 122 | youtube.bh 123 | youtube.bo 124 | youtube.by 125 | youtube.ca 126 | youtube.cat 127 | youtube.ch 128 | youtube.cl 129 | youtube.co 130 | youtube.co.ae 131 | youtube.co.at 132 | youtube.co.cr 133 | youtube.co.hu 134 | youtube.co.id 135 | youtube.co.il 136 | youtube.co.in 137 | youtube.co.jp 138 | youtube.co.ke 139 | youtube.co.kr 140 | youtube.co.ma 141 | youtube.co.nz 142 | youtube.co.th 143 | youtube.co.tz 144 | youtube.co.ug 145 | youtube.co.uk 146 | youtube.co.ve 147 | youtube.co.za 148 | youtube.co.zw 149 | youtube.com 150 | youtube.com.ar 151 | youtube.com.au 152 | youtube.com.az 153 | youtube.com.bd 154 | youtube.com.bh 155 | youtube.com.bo 156 | youtube.com.br 157 | youtube.com.by 158 | youtube.com.co 159 | youtube.com.do 160 | youtube.com.ec 161 | youtube.com.ee 162 | youtube.com.eg 163 | youtube.com.es 164 | youtube.com.gh 165 | youtube.com.gr 166 | youtube.com.gt 167 | youtube.com.hk 168 | youtube.com.hn 169 | youtube.com.hr 170 | youtube.com.jm 171 | youtube.com.jo 172 | youtube.com.kw 173 | youtube.com.lb 174 | youtube.com.lv 175 | youtube.com.ly 176 | youtube.com.mk 177 | youtube.com.mt 178 | youtube.com.mx 179 | youtube.com.my 180 | youtube.com.ng 181 | youtube.com.ni 182 | youtube.com.om 183 | youtube.com.pa 184 | youtube.com.pe 185 | youtube.com.ph 186 | youtube.com.pk 187 | youtube.com.pt 188 | youtube.com.py 189 | youtube.com.qa 190 | youtube.com.ro 191 | youtube.com.sa 192 | youtube.com.sg 193 | youtube.com.sv 194 | youtube.com.tn 195 | youtube.com.tr 196 | youtube.com.tw 197 | youtube.com.ua 198 | youtube.com.uy 199 | youtube.com.ve 200 | youtube.cr 201 | youtube.cz 202 | youtube.de 203 | youtube.dk 204 | youtube.ee 205 | youtube.es 206 | youtube.fi 207 | youtube.fr 208 | youtube.ge 209 | youtube.gr 210 | youtube.gt 211 | youtube.hk 212 | youtube.hr 213 | youtube.hu 214 | youtube.ie 215 | youtube.in 216 | youtube.iq 217 | youtube.is 218 | youtube.it 219 | youtube.jo 220 | youtube.jp 221 | youtube.kr 222 | youtube.kz 223 | youtube.la 224 | youtube.lk 225 | youtube.lt 226 | youtube.lu 227 | youtube.lv 228 | youtube.ly 229 | youtube.ma 230 | youtube.md 231 | youtube.me 232 | youtube.mk 233 | youtube.mn 234 | youtube.mx 235 | youtube.my 236 | youtube.ng 237 | youtube.ni 238 | youtube.nl 239 | youtube.no 240 | youtube.pa 241 | youtube.pe 242 | youtube.ph 243 | youtube.pk 244 | youtube.pl 245 | youtube.pr 246 | youtube.pt 247 | youtube.qa 248 | youtube.ro 249 | youtube.rs 250 | youtube.ru 251 | youtube.sa 252 | youtube.se 253 | youtube.sg 254 | youtube.si 255 | youtube.sk 256 | youtube.sn 257 | youtube.soy 258 | youtube.sv 259 | youtube.tn 260 | youtube.tv 261 | youtube.ua 262 | youtube.ug 263 | youtube.uy 264 | youtube.vn 265 | youtubeeducation.com 266 | youtubefanfest.com 267 | youtubegaming.com 268 | youtubego.co.id 269 | youtubego.co.in 270 | youtubego.com 271 | youtubego.com.br 272 | youtubego.id 273 | youtubego.in 274 | youtubei.googleapis.com 275 | youtubekids.com 276 | youtubemobilesupport.com 277 | yt.be 278 | ytimg.com 279 | d1v5ir2lpwr8os.cloudfront.net 280 | d22qjgkvxw22r6.cloudfront.net 281 | d25xi40x97liuc.cloudfront.net 282 | d27xxe7juh1us6.cloudfront.net 283 | dmqdd6hw24ucf.cloudfront.net 284 | aiv-cdn.net 285 | aiv-delivery.net 286 | amazonprimevideo.cn 287 | amazonprimevideo.com.cn 288 | amazonprimevideos.com 289 | amazonvideo.cc 290 | amazonvideo.com 291 | atv-ps.amazon.com 292 | avodmp4s3ww-a.akamaihd.net 293 | fls-na.amazon.com 294 | llnwd.net 295 | media-amazon.com 296 | prime-video.com 297 | primevideo.cc 298 | primevideo.com 299 | primevideo.info 300 | primevideo.org 301 | primevideo.tv 302 | -------------------------------------------------------------------------------- /proxy-domains-disney.txt: -------------------------------------------------------------------------------- 1 | 20thcenturystudios.com.au 2 | 20thcenturystudios.com.br 3 | 20thcenturystudios.jp 4 | abc-studios.com 5 | abc.com 6 | adobedtm.com 7 | adventuresbydisney.com 8 | babble.com 9 | babyzone.com 10 | bam.nr-data.net 11 | bamgrid.com 12 | beautyandthebeastmusical.co.uk 13 | braze.com 14 | cdn.optimizely.com 15 | conviva.com 16 | d9.flashtalking.com 17 | dilcdn.com 18 | disney-asia.com 19 | disney-discount.com 20 | disney-plus.net 21 | disney-portal.my.onetrust.com 22 | disney-studio.com 23 | disney-studio.net 24 | disney.asia 25 | disney.be 26 | disney.bg 27 | disney.ca 28 | disney.ch 29 | disney.co.il 30 | disney.co.jp 31 | disney.co.kr 32 | disney.co.th 33 | disney.co.uk 34 | disney.co.za 35 | disney.com 36 | disney.com.au 37 | disney.com.br 38 | disney.com.hk 39 | disney.com.tw 40 | disney.cz 41 | disney.de 42 | disney.demdex.net 43 | disney.dk 44 | disney.es 45 | disney.fi 46 | disney.fr 47 | disney.gr 48 | disney.hu 49 | disney.id 50 | disney.in 51 | disney.io 52 | disney.it 53 | disney.my 54 | disney.my.sentry.io 55 | disney.nl 56 | disney.no 57 | disney.ph 58 | disney.pl 59 | disney.pt 60 | disney.ro 61 | disney.ru 62 | disney.se 63 | disney.sg 64 | disneyadsales.com 65 | disneyarena.com 66 | disneyaulani.com 67 | disneybaby.com 68 | disneycareers.com 69 | disneychannelonstage.com 70 | disneychannelroadtrip.com 71 | disneycruisebrasil.com 72 | disneyenconcert.com 73 | disneyiejobs.com 74 | disneyinflight.com 75 | disneyinternational.com 76 | disneyinternationalhd.com 77 | disneyjunior.com 78 | disneyjuniortreataday.com 79 | disneylatino.com 80 | disneymagicmoments.co.il 81 | disneymagicmoments.co.uk 82 | disneymagicmoments.co.za 83 | disneymagicmoments.de 84 | disneymagicmoments.es 85 | disneymagicmoments.fr 86 | disneymagicmoments.gen.tr 87 | disneymagicmoments.gr 88 | disneymagicmoments.it 89 | disneymagicmoments.pl 90 | disneymagicmomentsme.com 91 | disneyme.com 92 | disneymeetingsandevents.com 93 | disneymovieinsiders.com 94 | disneymusicpromotion.com 95 | disneynewseries.com 96 | disneynow.com 97 | disneypeoplesurveys.com 98 | disneyplus.bn5x.net 99 | disneyplus.com 100 | disneyplus.com.ssl.sc.omtrdc.net 101 | disneyredirects.com 102 | disneysrivieraresort.com 103 | disneystore.com 104 | disneystreaming.com 105 | disneysubscription.com 106 | disneytickets.co.uk 107 | disneyturkiye.com.tr 108 | disneytvajobs.com 109 | disneyworld-go.com 110 | dmed.technology 111 | dssott.com 112 | dtci.co 113 | dtci.technology 114 | edgedatg.com 115 | espn.co.uk 116 | espn.com 117 | espn.hb.omtrdc.net 118 | espn.net 119 | espncdn.com 120 | espndotcom.tt.omtrdc.net 121 | espnqa.com 122 | execute-api.us-east-1.amazonaws.com 123 | go-disneyworldgo.com 124 | go.com 125 | js-agent.newrelic.com 126 | marvel.com 127 | marvel10thanniversary.com 128 | marveldimensionofheroes.com 129 | marvelparty.net 130 | marvelpinball.com 131 | marvelsdoubleagent.com 132 | marvelspotlightplays.com 133 | marvelsuperheroseptember.com 134 | marvelsuperwar.com 135 | mickey.tv 136 | moviesanywhere.com 137 | natgeomaps.com 138 | nationalgeographic.com 139 | nationalgeographicpartners.com 140 | ngeo.com 141 | nomadlandmovie.ch 142 | playmation.com 143 | shopdisney.com 144 | shops-disney.com 145 | sorcerersarena.com 146 | spaindisney.com 147 | star-brasil.com 148 | star-latam.com 149 | starwars.com 150 | starwarsgalacticstarcruiser.com 151 | starwarskids.com 152 | streamingdisney.net 153 | themarvelexperiencetour.com 154 | thestationbymaker.com 155 | thisispolaris.com 156 | watchdisneyfe.com 157 | watchespn.com 158 | -------------------------------------------------------------------------------- /proxy-domains-nr.txt: -------------------------------------------------------------------------------- 1 | akadns.net 2 | akam.net 3 | akamai.com 4 | akamai.net 5 | akamaiedge.net 6 | akamaihd.net 7 | akamaistream.net 8 | akamaitech.net 9 | akamaitechnologies.com 10 | akamaitechnologies.fr 11 | akamaized.net 12 | edgekey.net 13 | edgesuite.net 14 | srip.net 15 | footprint.net 16 | level3.net 17 | llnwd.net 18 | edgecastcdn.net 19 | cloudfront.net 20 | netflix.com 21 | netflix.net 22 | nflximg.com 23 | nflximg.net 24 | nflxvideo.net 25 | nflxso.net 26 | nflxext.com 27 | hulu.com 28 | huluim.com 29 | hbonow.com 30 | hbogo.com 31 | hbo.com 32 | amazon.com 33 | amazon.co.uk 34 | amazonvideo.com 35 | crackle.com 36 | pandora.com 37 | vudu.com 38 | blinkbox.com 39 | abc.com 40 | fox.com 41 | theplatform.com 42 | nbc.com 43 | nbcuni.com 44 | ip2location.com 45 | pbs.org 46 | warnerbros.com 47 | southpark.cc.com 48 | cbs.com 49 | brightcove.com 50 | cwtv.com 51 | spike.com 52 | go.com 53 | mtv.com 54 | mtvnservices.com 55 | playstation.net 56 | uplynk.com 57 | maxmind.com 58 | disney.com 59 | disneyjunior.com 60 | adobedtm.com 61 | bam.nr-data.net 62 | bamgrid.com 63 | braze.com 64 | cdn.optimizely.com 65 | cdn.registerdisney.go.com 66 | cws.conviva.com 67 | d9.flashtalking.com 68 | disney-plus.net 69 | disney-portal.my.onetrust.com 70 | disney.demdex.net 71 | disney.my.sentry.io 72 | disneyplus.bn5x.net 73 | disneyplus.com 74 | disneyplus.com.ssl.sc.omtrdc.net 75 | disneystreaming.com 76 | dssott.com 77 | execute-api.us-east-1.amazonaws.com 78 | js-agent.newrelic.com 79 | xboxlive.com 80 | lovefilm.com 81 | turner.com 82 | amctv.com 83 | sho.com 84 | mog.com 85 | wdtvlive.com 86 | beinsportsconnect.tv 87 | beinsportsconnect.net 88 | fig.bbc.co.uk 89 | open.live.bbc.co.uk 90 | sa.bbc.co.uk 91 | www.bbc.co.uk 92 | crunchyroll.com 93 | ifconfig.co 94 | omtrdc.net 95 | sling.com 96 | movetv.com 97 | happyon.jp 98 | abema.tv 99 | hulu.jp 100 | optus.com.au 101 | optusnet.com.au 102 | gamer.com.tw 103 | bahamut.com.tw 104 | hinet.net 105 | d1v5ir2lpwr8os.cloudfront.net 106 | d22qjgkvxw22r6.cloudfront.net 107 | d25xi40x97liuc.cloudfront.net 108 | d27xxe7juh1us6.cloudfront.net 109 | dmqdd6hw24ucf.cloudfront.net 110 | aiv-cdn.net 111 | aiv-delivery.net 112 | amazonprimevideo.cn 113 | amazonprimevideo.com.cn 114 | amazonprimevideos.com 115 | amazonvideo.cc 116 | amazonvideo.com 117 | atv-ps.amazon.com 118 | avodmp4s3ww-a.akamaihd.net 119 | fls-na.amazon.com 120 | llnwd.net 121 | media-amazon.com 122 | prime-video.com 123 | primevideo.cc 124 | primevideo.com 125 | primevideo.info 126 | primevideo.org 127 | primevideo.tv 128 | -------------------------------------------------------------------------------- /proxy-domains-tw.txt: -------------------------------------------------------------------------------- 1 | control.kochava.com 2 | d151l6v8er5bdm.cloudfront.net 3 | d1sgwhnao7452x.cloudfront.net 4 | dazn-api.com 5 | dazn.com 6 | dazndn.com 7 | dc2-vodhls-perform.secure.footprint.net 8 | dca-ll-livedazn-dznlivejp.s.llnwi.net 9 | dcalivedazn.akamaized.net 10 | dcblivedazn.akamaized.net 11 | indazn.com 12 | indaznlab.com 13 | intercom.io 14 | logx.optimizely.com 15 | s.yimg.jp 16 | sentry.io 17 | voddazn 18 | 20thcenturystudios.com.au 19 | 20thcenturystudios.com.br 20 | 20thcenturystudios.jp 21 | abc-studios.com 22 | abc.com 23 | adobedtm.com 24 | adventuresbydisney.com 25 | babble.com 26 | babyzone.com 27 | bam.nr-data.net 28 | bamgrid.com 29 | beautyandthebeastmusical.co.uk 30 | braze.com 31 | cdn.optimizely.com 32 | conviva.com 33 | d9.flashtalking.com 34 | dilcdn.com 35 | disney-asia.com 36 | disney-discount.com 37 | disney-plus.net 38 | disney-portal.my.onetrust.com 39 | disney-studio.com 40 | disney-studio.net 41 | disney.asia 42 | disney.be 43 | disney.bg 44 | disney.ca 45 | disney.ch 46 | disney.co.il 47 | disney.co.jp 48 | disney.co.kr 49 | disney.co.th 50 | disney.co.uk 51 | disney.co.za 52 | disney.com 53 | disney.com.au 54 | disney.com.br 55 | disney.com.hk 56 | disney.com.tw 57 | disney.cz 58 | disney.de 59 | disney.demdex.net 60 | disney.dk 61 | disney.es 62 | disney.fi 63 | disney.fr 64 | disney.gr 65 | disney.hu 66 | disney.id 67 | disney.in 68 | disney.io 69 | disney.it 70 | disney.my 71 | disney.my.sentry.io 72 | disney.nl 73 | disney.no 74 | disney.ph 75 | disney.pl 76 | disney.pt 77 | disney.ro 78 | disney.ru 79 | disney.se 80 | disney.sg 81 | disneyadsales.com 82 | disneyarena.com 83 | disneyaulani.com 84 | disneybaby.com 85 | disneycareers.com 86 | disneychannelonstage.com 87 | disneychannelroadtrip.com 88 | disneycruisebrasil.com 89 | disneyenconcert.com 90 | disneyiejobs.com 91 | disneyinflight.com 92 | disneyinternational.com 93 | disneyinternationalhd.com 94 | disneyjunior.com 95 | disneyjuniortreataday.com 96 | disneylatino.com 97 | disneymagicmoments.co.il 98 | disneymagicmoments.co.uk 99 | disneymagicmoments.co.za 100 | disneymagicmoments.de 101 | disneymagicmoments.es 102 | disneymagicmoments.fr 103 | disneymagicmoments.gen.tr 104 | disneymagicmoments.gr 105 | disneymagicmoments.it 106 | disneymagicmoments.pl 107 | disneymagicmomentsme.com 108 | disneyme.com 109 | disneymeetingsandevents.com 110 | disneymovieinsiders.com 111 | disneymusicpromotion.com 112 | disneynewseries.com 113 | disneynow.com 114 | disneypeoplesurveys.com 115 | disneyplus.bn5x.net 116 | disneyplus.com 117 | disneyplus.com.ssl.sc.omtrdc.net 118 | disneyredirects.com 119 | disneysrivieraresort.com 120 | disneystore.com 121 | disneystreaming.com 122 | disneysubscription.com 123 | disneytickets.co.uk 124 | disneyturkiye.com.tr 125 | disneytvajobs.com 126 | disneyworld-go.com 127 | dmed.technology 128 | dssott.com 129 | dtci.co 130 | dtci.technology 131 | edgedatg.com 132 | espn.co.uk 133 | espn.com 134 | espn.hb.omtrdc.net 135 | espn.net 136 | espncdn.com 137 | espndotcom.tt.omtrdc.net 138 | espnqa.com 139 | execute-api.us-east-1.amazonaws.com 140 | go-disneyworldgo.com 141 | go.com 142 | js-agent.newrelic.com 143 | marvel.com 144 | marvel10thanniversary.com 145 | marveldimensionofheroes.com 146 | marvelparty.net 147 | marvelpinball.com 148 | marvelsdoubleagent.com 149 | marvelspotlightplays.com 150 | marvelsuperheroseptember.com 151 | marvelsuperwar.com 152 | mickey.tv 153 | moviesanywhere.com 154 | natgeomaps.com 155 | nationalgeographic.com 156 | nationalgeographicpartners.com 157 | ngeo.com 158 | nomadlandmovie.ch 159 | playmation.com 160 | shopdisney.com 161 | shops-disney.com 162 | sorcerersarena.com 163 | spaindisney.com 164 | star-brasil.com 165 | star-latam.com 166 | starwars.com 167 | starwarsgalacticstarcruiser.com 168 | starwarskids.com 169 | streamingdisney.net 170 | themarvelexperiencetour.com 171 | thestationbymaker.com 172 | thisispolaris.com 173 | watchdisneyfe.com 174 | watchespn.com 175 | api.fast.com 176 | netflix.com.edgesuite.net 177 | fast.com 178 | netflix.ca 179 | netflix.com 180 | netflix.com.edgesuite.net 181 | netflix.net 182 | netflixdnstest0.com 183 | netflixdnstest1.com 184 | netflixdnstest10.com 185 | netflixdnstest2.com 186 | netflixdnstest3.com 187 | netflixdnstest4.com 188 | netflixdnstest5.com 189 | netflixdnstest6.com 190 | netflixdnstest7.com 191 | netflixdnstest8.com 192 | netflixdnstest9.com 193 | netflixinvestor.com 194 | netflixtechblog.com 195 | nflxext.com 196 | nflximg.com 197 | nflximg.net 198 | nflxsearch.net 199 | nflxso.net 200 | nflxvideo.net 201 | youtubei.googleapis.com 202 | yt3.ggpht.com 203 | ggpht.cn 204 | ggpht.com 205 | googlevideo.com 206 | gvt2.com 207 | withyoutube.com 208 | youtu.be 209 | youtube-nocookie.com 210 | youtube.ae 211 | youtube.al 212 | youtube.am 213 | youtube.at 214 | youtube.az 215 | youtube.ba 216 | youtube.be 217 | youtube.bg 218 | youtube.bh 219 | youtube.bo 220 | youtube.by 221 | youtube.ca 222 | youtube.cat 223 | youtube.ch 224 | youtube.cl 225 | youtube.co 226 | youtube.co.ae 227 | youtube.co.at 228 | youtube.co.cr 229 | youtube.co.hu 230 | youtube.co.id 231 | youtube.co.il 232 | youtube.co.in 233 | youtube.co.jp 234 | youtube.co.ke 235 | youtube.co.kr 236 | youtube.co.ma 237 | youtube.co.nz 238 | youtube.co.th 239 | youtube.co.tz 240 | youtube.co.ug 241 | youtube.co.uk 242 | youtube.co.ve 243 | youtube.co.za 244 | youtube.co.zw 245 | youtube.com 246 | youtube.com.ar 247 | youtube.com.au 248 | youtube.com.az 249 | youtube.com.bd 250 | youtube.com.bh 251 | youtube.com.bo 252 | youtube.com.br 253 | youtube.com.by 254 | youtube.com.co 255 | youtube.com.do 256 | youtube.com.ec 257 | youtube.com.ee 258 | youtube.com.eg 259 | youtube.com.es 260 | youtube.com.gh 261 | youtube.com.gr 262 | youtube.com.gt 263 | youtube.com.hk 264 | youtube.com.hn 265 | youtube.com.hr 266 | youtube.com.jm 267 | youtube.com.jo 268 | youtube.com.kw 269 | youtube.com.lb 270 | youtube.com.lv 271 | youtube.com.ly 272 | youtube.com.mk 273 | youtube.com.mt 274 | youtube.com.mx 275 | youtube.com.my 276 | youtube.com.ng 277 | youtube.com.ni 278 | youtube.com.om 279 | youtube.com.pa 280 | youtube.com.pe 281 | youtube.com.ph 282 | youtube.com.pk 283 | youtube.com.pt 284 | youtube.com.py 285 | youtube.com.qa 286 | youtube.com.ro 287 | youtube.com.sa 288 | youtube.com.sg 289 | youtube.com.sv 290 | youtube.com.tn 291 | youtube.com.tr 292 | youtube.com.tw 293 | youtube.com.ua 294 | youtube.com.uy 295 | youtube.com.ve 296 | youtube.cr 297 | youtube.cz 298 | youtube.de 299 | youtube.dk 300 | youtube.ee 301 | youtube.es 302 | youtube.fi 303 | youtube.fr 304 | youtube.ge 305 | youtube.gr 306 | youtube.gt 307 | youtube.hk 308 | youtube.hr 309 | youtube.hu 310 | youtube.ie 311 | youtube.in 312 | youtube.iq 313 | youtube.is 314 | youtube.it 315 | youtube.jo 316 | youtube.jp 317 | youtube.kr 318 | youtube.kz 319 | youtube.la 320 | youtube.lk 321 | youtube.lt 322 | youtube.lu 323 | youtube.lv 324 | youtube.ly 325 | youtube.ma 326 | youtube.md 327 | youtube.me 328 | youtube.mk 329 | youtube.mn 330 | youtube.mx 331 | youtube.my 332 | youtube.ng 333 | youtube.ni 334 | youtube.nl 335 | youtube.no 336 | youtube.pa 337 | youtube.pe 338 | youtube.ph 339 | youtube.pk 340 | youtube.pl 341 | youtube.pr 342 | youtube.pt 343 | youtube.qa 344 | youtube.ro 345 | youtube.rs 346 | youtube.ru 347 | youtube.sa 348 | youtube.se 349 | youtube.sg 350 | youtube.si 351 | youtube.sk 352 | youtube.sn 353 | youtube.soy 354 | youtube.sv 355 | youtube.tn 356 | youtube.tv 357 | youtube.ua 358 | youtube.ug 359 | youtube.uy 360 | youtube.vn 361 | youtubeeducation.com 362 | youtubefanfest.com 363 | youtubegaming.com 364 | youtubego.co.id 365 | youtubego.co.in 366 | youtubego.com 367 | youtubego.com.br 368 | youtubego.id 369 | youtubego.in 370 | youtubei.googleapis.com 371 | youtubekids.com 372 | youtubemobilesupport.com 373 | yt.be 374 | ytimg.com 375 | d1v5ir2lpwr8os.cloudfront.net 376 | d22qjgkvxw22r6.cloudfront.net 377 | d25xi40x97liuc.cloudfront.net 378 | d27xxe7juh1us6.cloudfront.net 379 | dmqdd6hw24ucf.cloudfront.net 380 | aiv-cdn.net 381 | aiv-delivery.net 382 | amazonprimevideo.cn 383 | amazonprimevideo.com.cn 384 | amazonprimevideos.com 385 | amazonvideo.cc 386 | amazonvideo.com 387 | atv-ps.amazon.com 388 | avodmp4s3ww-a.akamaihd.net 389 | fls-na.amazon.com 390 | llnwd.net 391 | media-amazon.com 392 | prime-video.com 393 | primevideo.cc 394 | primevideo.com 395 | primevideo.info 396 | primevideo.org 397 | primevideo.tv 398 | bcbolt446c5271-a.akamaihd.net 399 | edge.api.brightcove.com 400 | bigbigchannel.com.hk 401 | bigbigshop.com 402 | content.jwplatform.com 403 | encoretvb.com 404 | mytvsuper.com 405 | mytvsuperlimited.hb.omtrdc.net 406 | mytvsuperlimited.sc.omtrdc.net 407 | tvb.com 408 | tvb.com.au 409 | tvbanywhere.com 410 | tvbanywhere.com.sg 411 | tvbc.com.cn 412 | tvbeventpower.com.hk 413 | tvbusa.com 414 | tvbweekly.com 415 | tvmedia.net.au 416 | videos-f.jwpsrv.com 417 | audio-ak-spotify-com.akamaized.net 418 | byspotify.com 419 | heads4-ak-spotify-com.akamaized.net 420 | pscdn.co 421 | scdn.co 422 | spoti.fi 423 | spotify-com.akamaized.net 424 | spotify-everywhere.com 425 | spotify.com 426 | spotify.design 427 | spotifycdn.com 428 | spotifycdn.net 429 | spotifycharts.com 430 | spotifycodes.com 431 | spotifyforbrands.com 432 | spotifyjobs.com 433 | spotify.com 434 | kktv-theater.kk.stream 435 | kktv.com.tw 436 | kktv.me 437 | itvfreemobile-hichannel.cdn.hinet.net 438 | litv.tv 439 | d17lx9ucc6k9fc.cloudfront.net 440 | d3c7rimkq79yfu.cloudfront.net 441 | d3pgb93pk7bvxj.cloudfront.net 442 | d3vm9lcxb6xcm4.cloudfront.net 443 | chocotv.com.tw 444 | line-cdn.net 445 | line-scdn.net 446 | linetv.tw 447 | 44wilhpljf.execute-api.ap-southeast-1.amazonaws.com 448 | bcbolthboa-a.akamaihd.net 449 | cf-images.ap-southeast-1.prod.boltdns.net 450 | dai3fd1oh325y.cloudfront.net 451 | hboasia1-i.akamaihd.net 452 | hboasia2-i.akamaihd.net 453 | hboasia3-i.akamaihd.net 454 | hboasia4-i.akamaihd.net 455 | hboasia5-i.akamaihd.net 456 | hboasialive.akamaized.net 457 | hbogoprod-vod.akamaized.net 458 | hbolb.onwardsmg.com 459 | hbounify-prod.evergent.com 460 | players.brightcove.net 461 | s3-ap-southeast-1.amazonaws.com 462 | wmff.warnermediacdn.com 463 | hbogoasia.com 464 | hbogoasia.hk 465 | hbogoasia 466 | bahamut.akamaized.net 467 | gamer-cds.cdn.hinet.net 468 | gamer2-cds.cdn.hinet.net 469 | bahamut.com.tw 470 | gamer.com.tw 471 | apm-misaka.biliapi.net 472 | p-bstarstatic.akamaized.net 473 | p.bstarstatic.com 474 | upos-bstar-mirrorakam.akamaized.net 475 | upos-bstar1-mirrorakam.akamaized.net 476 | biliintl.com 477 | -------------------------------------------------------------------------------- /proxy-domains-youtube.txt: -------------------------------------------------------------------------------- 1 | youtubei.googleapis.com 2 | yt3.ggpht.com 3 | ggpht.cn 4 | ggpht.com 5 | googlevideo.com 6 | gvt2.com 7 | withyoutube.com 8 | youtu.be 9 | youtube-nocookie.com 10 | youtube.ae 11 | youtube.al 12 | youtube.am 13 | youtube.at 14 | youtube.az 15 | youtube.ba 16 | youtube.be 17 | youtube.bg 18 | youtube.bh 19 | youtube.bo 20 | youtube.by 21 | youtube.ca 22 | youtube.cat 23 | youtube.ch 24 | youtube.cl 25 | youtube.co 26 | youtube.co.ae 27 | youtube.co.at 28 | youtube.co.cr 29 | youtube.co.hu 30 | youtube.co.id 31 | youtube.co.il 32 | youtube.co.in 33 | youtube.co.jp 34 | youtube.co.ke 35 | youtube.co.kr 36 | youtube.co.ma 37 | youtube.co.nz 38 | youtube.co.th 39 | youtube.co.tz 40 | youtube.co.ug 41 | youtube.co.uk 42 | youtube.co.ve 43 | youtube.co.za 44 | youtube.co.zw 45 | youtube.com 46 | youtube.com.ar 47 | youtube.com.au 48 | youtube.com.az 49 | youtube.com.bd 50 | youtube.com.bh 51 | youtube.com.bo 52 | youtube.com.br 53 | youtube.com.by 54 | youtube.com.co 55 | youtube.com.do 56 | youtube.com.ec 57 | youtube.com.ee 58 | youtube.com.eg 59 | youtube.com.es 60 | youtube.com.gh 61 | youtube.com.gr 62 | youtube.com.gt 63 | youtube.com.hk 64 | youtube.com.hn 65 | youtube.com.hr 66 | youtube.com.jm 67 | youtube.com.jo 68 | youtube.com.kw 69 | youtube.com.lb 70 | youtube.com.lv 71 | youtube.com.ly 72 | youtube.com.mk 73 | youtube.com.mt 74 | youtube.com.mx 75 | youtube.com.my 76 | youtube.com.ng 77 | youtube.com.ni 78 | youtube.com.om 79 | youtube.com.pa 80 | youtube.com.pe 81 | youtube.com.ph 82 | youtube.com.pk 83 | youtube.com.pt 84 | youtube.com.py 85 | youtube.com.qa 86 | youtube.com.ro 87 | youtube.com.sa 88 | youtube.com.sg 89 | youtube.com.sv 90 | youtube.com.tn 91 | youtube.com.tr 92 | youtube.com.tw 93 | youtube.com.ua 94 | youtube.com.uy 95 | youtube.com.ve 96 | youtube.cr 97 | youtube.cz 98 | youtube.de 99 | youtube.dk 100 | youtube.ee 101 | youtube.es 102 | youtube.fi 103 | youtube.fr 104 | youtube.ge 105 | youtube.gr 106 | youtube.gt 107 | youtube.hk 108 | youtube.hr 109 | youtube.hu 110 | youtube.ie 111 | youtube.in 112 | youtube.iq 113 | youtube.is 114 | youtube.it 115 | youtube.jo 116 | youtube.jp 117 | youtube.kr 118 | youtube.kz 119 | youtube.la 120 | youtube.lk 121 | youtube.lt 122 | youtube.lu 123 | youtube.lv 124 | youtube.ly 125 | youtube.ma 126 | youtube.md 127 | youtube.me 128 | youtube.mk 129 | youtube.mn 130 | youtube.mx 131 | youtube.my 132 | youtube.ng 133 | youtube.ni 134 | youtube.nl 135 | youtube.no 136 | youtube.pa 137 | youtube.pe 138 | youtube.ph 139 | youtube.pk 140 | youtube.pl 141 | youtube.pr 142 | youtube.pt 143 | youtube.qa 144 | youtube.ro 145 | youtube.rs 146 | youtube.ru 147 | youtube.sa 148 | youtube.se 149 | youtube.sg 150 | youtube.si 151 | youtube.sk 152 | youtube.sn 153 | youtube.soy 154 | youtube.sv 155 | youtube.tn 156 | youtube.tv 157 | youtube.ua 158 | youtube.ug 159 | youtube.uy 160 | youtube.vn 161 | youtubeeducation.com 162 | youtubefanfest.com 163 | youtubegaming.com 164 | youtubego.co.id 165 | youtubego.co.in 166 | youtubego.com 167 | youtubego.com.br 168 | youtubego.id 169 | youtubego.in 170 | youtubei.googleapis.com 171 | youtubekids.com 172 | youtubemobilesupport.com 173 | yt.be 174 | ytimg.com 175 | -------------------------------------------------------------------------------- /sniproxy.conf: -------------------------------------------------------------------------------- 1 | user daemon 2 | pidfile /var/tmp/sniproxy.pid 3 | 4 | error_log { 5 | syslog daemon 6 | priority notice 7 | } 8 | 9 | resolver { 10 | nameserver 8.8.8.8 11 | nameserver 8.8.4.4 # local dns should be better 12 | mode ipv4_only 13 | } 14 | listener 0.0.0.0:80 { 15 | proto http 16 | access_log { 17 | filename /var/log/sniproxy/http_access.log 18 | priority notice 19 | } 20 | } 21 | listener 0.0.0.0:443 { 22 | proto tls 23 | access_log { 24 | filename /var/log/sniproxy/https_access.log 25 | priority notice 26 | } 27 | } 28 | 29 | table { 30 | 31 | } -------------------------------------------------------------------------------- /sniproxy.default: -------------------------------------------------------------------------------- 1 | # Defaults for sniproxy initscript 2 | 3 | # This file has two functions: 4 | # 1) to completely disable starting sniproxy, 5 | # 2) to select an alternative config file 6 | # by setting DAEMON_ARGS to -c 7 | 8 | # Additional options that are passed to the Daemon. 9 | DAEMON_ARGS="-c /etc/sniproxy.conf" 10 | 11 | # Whether or not to run the sniproxy daemon; set to 0 to disable, 1 to enable. 12 | ENABLED=1 13 | 14 | -------------------------------------------------------------------------------- /sniproxy/sniproxy-0.6.0.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/7fff0af62a8a9441905d42b424b6b1ed8ff2eab0/sniproxy/sniproxy-0.6.0.el6.x86_64.rpm -------------------------------------------------------------------------------- /sniproxy/sniproxy-0.6.0.el7.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/7fff0af62a8a9441905d42b424b6b1ed8ff2eab0/sniproxy/sniproxy-0.6.0.el7.x86_64.rpm -------------------------------------------------------------------------------- /sniproxy/sniproxy-0.6.0.el8.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/7fff0af62a8a9441905d42b424b6b1ed8ff2eab0/sniproxy/sniproxy-0.6.0.el8.x86_64.rpm -------------------------------------------------------------------------------- /sniproxy/sniproxy_0.6.0_amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/7fff0af62a8a9441905d42b424b6b1ed8ff2eab0/sniproxy/sniproxy_0.6.0_amd64.deb -------------------------------------------------------------------------------- /sniproxy/sniproxy_0.6.0_i386.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codionx/dnsmasq_sniproxy_install/7fff0af62a8a9441905d42b424b6b1ed8ff2eab0/sniproxy/sniproxy_0.6.0_i386.deb --------------------------------------------------------------------------------