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 ...
随机推荐
- PHP数学函数
Abs: 取得绝对值. Acos: 取得反余弦值. Asin: 取得反正弦值. Atan: 取得反正切值. Atan2: 计算二数的反正切值. base_convert: 转换数字的进位方式. Bin ...
- maven pom.xml
什么是pom? pom作为项目对象模型.通过xml表示maven项目,使用pom.xml来实现.主要描述了项目:包括配置文件:开发者需要遵循的规则,缺陷管理系统,组织和licenses,项目的u ...
- 【SPI】Polling Interrupt DMA
三種將資料在I/O間傳送的方法有 1. Polling2. Interrupt-driven I/O3. DMA(Direct Memory Access) Polling:最簡單的方式讓I/O de ...
- [NOI 2006] 最大获利 80分
最后两点怎么搞都要30s+,但是我不会什么优化啊…暂时就这样吧.Dinic的时间复杂度是O(N^2*M) 这题和TDL的幼儿园模板是一样的. 这次写网络流给自己计时了,大约是40min左右,后来都跑去 ...
- SVN使用说明
一,安装客户端SVN 1.下载 "svn小乌龟"后,进行安装.如下图: 安装完成后,右键项目文件夹就可以看到如下: 2:checkout项目文件. 新建或者进入目录下(比如qian ...
- oracle 数据库信息查询
/*查询当前用户表信息/ select A.column_name 字段名, A.data_type 数据类型, A.data_length 长度, A.data_precisi ...
- Leetcode_实现zigzag的转换_20161228
#include<iostream> //#include<valarray> #include<vector> #include<string> us ...
- Dojo的subscribe和publish的简单使用
问题描述: 假设在你的页面有一个对话框,对话框中包含FilteringSelect这样的需要store的控件,在打开对话框时需要对这个控件做两件事情,一是给该控件的store填充数据,二是要给该控件设 ...
- Android深度探索--HAL与驱动开发----第二章读书笔记
1. 底层开发工具包括: JDk6或者以上版本:Eclipse3.4或以上版本:ADT(用于开发Android应用程序),CDT(用于开发AndroidNDK程序):Android SDK:Andro ...
- OpenSuse Caffe CNN库 配置
参考官方文档:http://caffe.berkeleyvision.org/installation.html 1. 安装CUDA 参考 http://www.cnblogs.com/sunshy/ ...