stunnel-client
#!/bin/bash
# giving user passwordless sudo privileges
USER=`whoami`
MYPATH=$(cat /etc/passwd|grep $USER|awk -F: '{print $6}')
# need to be run as root
if [[ "$EUID" -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
#parse args
while getopts "c:i:p:I:P:z:h" arg
do
case $arg in
c) CONFIG=$OPTARG
if [[ ! -f "$CONFIG" ]]; then
echo " unvalid arg for -c, ple make sure the config file is exist "
exit 1
fi
;;
i) PROXY_IP=${OPTARG:-127.0.0.1} ;;
p) PROXY_PORT=${OPTARG:-8888} ;;
I) SERVER_IP=$OPTARG ;;
P) SERVER_PORT=$OPTARG ;;
z) ZTE_PROXY=${OPTARG:-proxysh.zte.com.cn} ;;
h)
echo " -------------args for setting up stunnel--------------------"
echo " -c: client certification"
echo " -i: proxy ip, default to localhost
echo " -p: proxy port, default to 8888"
echo " -I: server ip
echo " -P: server port listened in server"
echo " -z: zte proxy, need to be consistent with system network set"
echo "-------------------------------------------------------------"
exit 0
;;
?) echo "unvalid arg"
exit 1
;;
esac
done
if [[ ! $CONFIG || ! $SERVER_IP || ! $SERVER_PORT ]]; then
echo " need args, ple use -h for help..."
exit 1
fi
HTTP_PROXY=http://$PROXY_IP:$PROXY_PORT
NO_PROXY=localhost,127.0.0.1,10.*.*.*/8
# use internal apt-source
INTER_APT_SOURCE=10.62.99.232
function use_internal_apt_source {
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bk
sudo cat <<EOF >/etc/apt/sources.list
deb http://$INTER_APT_SOURCE/common/ubuntu trusty main restricted multiverse universe
deb http://$INTER_APT_SOURCE/common/ubuntu trusty-security main restricted multiverse universe
deb http://$INTER_APT_SOURCE/common/ubuntu trusty-updates main restricted multiverse universe
deb http://$INTER_APT_SOURCE/common/ubuntu trusty-proposed main restricted multiverse universe
deb http://$inter_apt_source/common/ubuntu trusty-backports main restricted multiverse universe
EOF
sudo apt-get update
}
# if use internal apt-source to install stunnel,
# after install stunnel successfully, ple change back original apt-source
function change_back_apt_source {
sudo mv /etc/apt/sources.list.bk /etc/apt/sources.list
}
# (optional) if can not connect to wwww, user internal apt-source
use_internal_apt_source
sudo apt-get install -y stunnel
# (optional) no matter if stunnel package is installed, change back to origin apt-source
change_back_apt_source
sudo cat << EOF > /etc/stunnel/client.conf
chroot = /var/lib/stunnel4/
setuid = stunnel4
setgid = stunnel4
pid = /stunnel4-client.pid
client = yes
cert = /etc/stunnel/client.pem
sslVersion = SSLv3
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
[squid]
accept = $PROXY_PORT
protocol = connect
protocolHost = $SERVER_IP:$SERVER_PORT
connect = $ZTE_PROXY:80
EOF
sudo cp $CONFIG /etc/stunnel/client.pem
sudo sed -i -r "s/ENABLED=0/ENABLED=1/g" /etc/default/stunnel4
# restart stunnel
sudo service stunnel4 restart
#config proxy: append to $MYPATH/.profile
cat <<EOF >> /$MYPATH/.profile
export http_proxy=$HTTP_PROXY
export https_proxy=$HTTP_PROXY
export no_proxy=$NO_PROXY
EOF
sudo cat <<EOF > /etc/apt/apt.conf
Acquire::http::proxy \"$HTTP_PROXY/\";
Acquire::https::proxy \"$HTTP_PROXY/\";
EOF
source $MYPATH/.profile
sudo apt-get update
stunnel-client的更多相关文章
- Stunnel使用2
1.首先测试一下stunnel.exe,是否能正常运行,正常的话,不会报错,在桌面右下角位置显示. 2.第一步完成后,打开stunnel.conf,对stunnel进行配置,需要修改一下几项:(mys ...
- squid+stunnel+用户密码认证的三种玩法
没办法,应用越来越深入,就会越来越多要求. squid+stunnel+用户密码认证的场景至少以下三个,我会遇到. 1,标准玩法 在服务器上建一个SQUID,加密码认证,然后,其它人通过它上网.(不要 ...
- AWS + Stunnel + Squid ***
[需求] 第一,能***. 第二,在企业网络要能突破端口限制. [原理] 利用AWS提供的一年免费EC2服务,搭建一台自己的VPS,在VPS中利用Stunnel与本机建立加密连接,将本地http请求通 ...
- stunnel-server
#!/bin/bash # need to be run as root ]]; then echo "must to be run as root" exit fi # givi ...
- 【原】基于64位Centos6.2的mcrouter使用简介
此文转载必须注明原文地址,请尊重作者的劳动成果! http://www.cnblogs.com/lyongerr/p/5040071.html 目录 文档控制... 2 1 mcrouter简介.. ...
- 用ccproxy + stunnel做个加密代理
https://www.stunnel.org/downloads.html ccproxy + stunnel做个加密http代理和socks5代理 目前国内用户无法访问某些国外网站,如http:/ ...
- stunnel+CCProxy,搭建加密代理
总所周知,不可抗拒的特别有用心的原因,我们无法访问youtube,picasa,Twitter……国外优秀网站,很多人采用了代理服务器的方法访问. 如果您有一台放在海外的服务器,这个就好办了.下载一个 ...
- Windows系统Stunnel客户端的配置
Stunnel官方就有Windows版本,到下面的地址下载: https://www.stunnel.org/downloads.html 选择”stunnel-X.XX-installer.exe“ ...
- Stunnel使用
建立加密隧道 使用 Stunnel 建立加密隧道 附件中的 Server 和 Clinet 都是已经配置好了的,只需修改 Server 的 stunnel.conf 的 connect 为实际的ip ...
随机推荐
- [CodeForces - 712D]Memory and Scores (DP 或者 生成函数)
题目大意: 两个人玩取数游戏,第一个人分数一开始是a,第二个分数一开始是b,接下来t轮,每轮两人都选择一个[-k,k]范围内的整数,加到自己的分数里,求有多少种情况使得t轮结束后a的分数比b高. ( ...
- Fragment的startActivityForResult和Activity的startActivityForResult的区别
2016-08-30 18:22:33 前提:我们的APP要兼容Api level 11以前的,所以必须用FragmentActivity 1.对于Fragment的,我们很多时候都会在Activit ...
- [翻译]PYTHON中如何使用*ARGS和**KWARGS
[翻译]Python中如何使用*args和**kwargs 函数定义 函数调用 不知道有没有人翻译了,看到了,很短,顺手一翻 原文地址 入口 或者可以叫做,在Python中如何使用可变长参数列表 函数 ...
- python学习09——字典(3)
今天写了一道python字典题目,用了上次字典(2)中的方法,代码如下: json = {', 'IP':'10.0.0.1'} def find_value(themap, word): if wo ...
- ssi项目(1)环境搭建
1.环境准备 导包(jdk1.8只支持spring4.0以上的版本) mysql驱动包 c3p0驱动包 mybatis包 spring-core.spring-aop.spring-web.sprin ...
- MicroERP数据初始化SQL脚本
--use MicroERP insert into tbUserGroup(GroupName,Remark) values('管理员组','具备所有权限')insert into tbUser(L ...
- Spark机器学习读书笔记-CH04
[root@demo1 ch04]# spark-shell --master yarn --jars /root/studio/jblas-1.2.3.jar scala> val rawDa ...
- SpringMVC-DispatcheServlet
1 HandlerMapping->HandlerAdapter->ViewResolver ->HandlerExceptionResolver 2
- Java基础之类的初始化顺序
对于静态变量.静态初始化块.变量.初始化块.构造器,它们的初始化顺序依次是 (静态变量.静态初始化块)>(变量.初始化块)>构造器 对于继承的情况: 1. 父类--静态变量 2. 父 ...
- Nginx的静态资源缓存以及压缩
Nginx是一款轻量级的网页服务器.反向代理器以及电子邮件代理服务器.Nginx采用的是异步非阻塞的通信机制(epoll模型),支持更大的并发连接.所谓的epoll模型:当事件没有准备好时,就放入ep ...