Skip to content

Commit 31b74e1

Browse files
committed
add CLI easyconn_7.6.8
1 parent dd32b88 commit 31b74e1

File tree

4 files changed

+137
-11
lines changed

4 files changed

+137
-11
lines changed

easyconnect-in-docker/deploy-cli.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
# Copyright (C) 2021 shmilee
3+
4+
# EC version to run, 7.6.8
5+
VERSION="${1:-7.6.8}"
6+
# EC data repo dir
7+
DATAREPO="${2:-./ECDATA}"
8+
9+
EasyConnectDir=/usr/share/sangfor/EasyConnect
10+
HOSTECDIR="${DATAREPO}/EasyConnect_cli_x64_v$VERSION"
11+
12+
deploy_data() {
13+
# deb url
14+
urlprefix='http://download.sangfor.com.cn/download/product/sslvpn/pkg'
15+
if [ x"$VERSION" = x"7.6.8" ]; then
16+
deburl="$urlprefix/linux_broken/easyconn_7.6.8.2-ubuntu_amd64.deb"
17+
else
18+
echo ">> Not supported CLI EC version: $VERSION"
19+
exit 1
20+
fi
21+
# download & extract deb
22+
if [ ! -d "${DATAREPO}" ]; then
23+
mkdir -pv "${DATAREPO}"
24+
fi
25+
debfile="${DATAREPO}/EasyConnect_cli_x64_v$VERSION.deb"
26+
if [ ! -f "${debfile}" ]; then
27+
wget -c "${deburl}" -O "${debfile}"
28+
fi
29+
if [ ! -d "${HOSTECDIR}" ]; then
30+
mkdir /tmp/ec-tmp
31+
bsdtar -v -x -f "${debfile}" -C /tmp/ec-tmp
32+
bsdtar -v -x -f /tmp/ec-tmp/data.tar.* -C /tmp/ec-tmp
33+
mv -v /tmp/ec-tmp/${EasyConnectDir} "${HOSTECDIR}"
34+
rm -r /tmp/ec-tmp/
35+
fi
36+
echo -n $VERSION >"${HOSTECDIR}/ecversion"
37+
if [ ! -f "${HOSTECDIR}/EasyConnect" ]; then
38+
ln -s ./resources/bin/easyconn "${HOSTECDIR}/EasyConnect"
39+
fi
40+
if [ ! -f "${HOSTECDIR}/hook_script.sh" ]; then
41+
cp -v ./hook_script.sh "${HOSTECDIR}/hook_script.sh"
42+
fi
43+
if [ ! -f "${HOSTECDIR}/start.sh" ]; then
44+
cp -v ./start.sh "${HOSTECDIR}/start.sh"
45+
fi
46+
if [ ! -x "${HOSTECDIR}/start.sh" ]; then
47+
chmod +x "${HOSTECDIR}/start.sh"
48+
fi
49+
}
50+
51+
deploy_data

easyconnect-in-docker/hook_script.sh

+21-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,21 @@ hook_fix763_login() { #{{{
131131
) &
132132
} #}}}
133133

134+
## exec easyconn
135+
start_easyconn() {
136+
local params="-v"
137+
[ -n "$ECADDRESS" ] && params+=" -d $ECADDRESS"
138+
[ -n "$ECUSER" ] && params+=" -u $ECUSER"
139+
[ -n "$ECPASSWD" ] && params+=" -p $ECPASSWD"
140+
141+
run_cmd easyconn foreground login $params
142+
keep='K'
143+
while [ x"$keep" != x'XXX' ]; do
144+
read -p " -> Enter 'XXX' to exit:" keep
145+
done
146+
run_cmd easyconn foreground logout
147+
}
148+
134149
## reload main
135150
main() {
136151
echo "Running hook main ..."
@@ -144,6 +159,11 @@ main() {
144159
# ignore: URLWIN=1, shell/open_browser.sh. Use xdg-open in host.
145160

146161
run_cmd EasyMonitor
147-
start_EC
162+
163+
if [ x"$TYPE" = x"CLI" ]; then
164+
start_easyconn
165+
else
166+
start_EC
167+
fi
148168
}
149169

easyconnect-in-docker/readme.md

+48-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ docker build --rm -t shmilee/easyconnect:$tag -f Dockerfile .
1010

1111
# run
1212

13-
## deb url
13+
## package files
1414

1515
* [7.6.3](http://download.sangfor.com.cn/download/product/sslvpn/pkg/linux_01/EasyConnect_x64.deb)
1616
* [7.6.7](http://download.sangfor.com.cn/download/product/sslvpn/pkg/linux_767/EasyConnect_x64_7_6_7_3.deb)
17+
* 7.6.8 CLI: `easyconn_7.6.8.2-ubuntu_amd64.deb`, `md5: 88371f0dc336c5021e213e10745cf47c`
1718

18-
## deploy & start
19+
## GUI deploy & start
1920

2021
```bash
2122
./deploy.sh <ec version> <ec data repo>
@@ -93,6 +94,51 @@ non-network local connections being removed from access control list
9394
Stop watching url.
9495
```
9596

97+
## CLI deploy & start
98+
99+
```bash
100+
./deploy-cli.sh 7.6.8 $HOME/.ECDATA # example
101+
```
102+
103+
```bash
104+
tag=210223
105+
TYPE=CLI $HOME/.ECDATA/EasyConnect_cli_x64_v7.6.8/start.sh $tag -e TYPE=CLI -p 3600:1080
106+
# output
107+
>>> Host Dir to mount: /home/xxx/.ECDATA/EasyConnect_cli_x64_v7.6.8
108+
source hook_script.sh ...
109+
Running hook main ...
110+
Run hook_danted
111+
Run CMD: /usr/share/sangfor/EasyConnect/resources/bin/EasyMonitor
112+
Start EasyMonitor success!
113+
Run CMD: /usr/share/sangfor/EasyConnect/resources/bin/easyconn login -v
114+
No previous user logged in!
115+
No previous user logged in!
116+
vpn adress: vpn.xxx.cn:443
117+
Get https://vpn.xxx.cn:443/por/login_auth.csp ...
118+
Get https://vpn.xxx.cn:443/por/login_auth.csp Done, code=200
119+
Cipher Suite: AES128-SHA
120+
Begin detect listen port of ECAgent ...
121+
Read listen port of ECAgent from file: 54530
122+
Done detect listen port of ECAgent, result: 54530!
123+
Get https://127.0.0.1:54530/ECAgent ...
124+
Get https://127.0.0.1:54530/ECAgent Done, code=200
125+
username: xxxx
126+
password: xxxx
127+
Authenticating user "xxxx" by password ...
128+
Post https://vpn.xxx.cn:443/por/login_psw.csp ...
129+
Post https://vpn.xxx.cn:443/por/login_psw.csp Done, code=200
130+
Get https://127.0.0.1:54530/ECAgent ...
131+
Get https://127.0.0.1:54530/ECAgent Done, code=200
132+
Get https://127.0.0.1:54530/ECAgent ...
133+
Get https://127.0.0.1:54530/ECAgent Done, code=200
134+
user "xxxx" login successfully!
135+
Start easyconn success!
136+
-> Enter 'XXX' to exit:XXX
137+
Run CMD: /usr/share/sangfor/EasyConnect/resources/bin/easyconn logout
138+
user "xxxx" is already logged out!
139+
Start easyconn success!
140+
```
141+
96142
## desktop file
97143

98144
* edit `Exec` options in `ec-7.6.x.desktop`

easyconnect-in-docker/start.sh

+17-8
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ if [ x"$1" = x"-h" -o x"$1" = x"--help" ]; then
1212
>> Usage:
1313
$0 <image tag> <params>
1414
TYPE=VNC $0 <image tag> <params>
15+
TYPE=CLI $0 <image tag> <params>
1516
>> params example:
1617
# iptable : -e IPTABLES=1 -e IPTABLES_LEGACY=1
1718
# danted : -e NODANTED=1 OR -p 127.0.0.1:1080:1080
1819
# TYPE=VNC : -e TYPE=VNC -e PASSWORD=x -e ECPASSWORD= -p 127.0.0.1:5901:5901
1920
# sshd : -e SSHD=1 -e ROOTPASSWD=x1 -p 127.0.0.1:2222:22
21+
# TYPE=CLI : -e TYPE=CLI -e ECADDRESS=x:p -e ECUSER= -e ECPASSWORD=
2022
EOF
2123
exit 0
2224
fi
@@ -39,9 +41,21 @@ watch_url() {
3941
rm "${HOSTECDIR}"/tmp-url
4042
}
4143

42-
watch_url &
4344
use="${TYPE:-X11}"
44-
if [ x"$use" = xX11 ]; then
45+
if [ x"$use" = xVNC ]; then
46+
watch_url &
47+
docker run --rm --device /dev/net/tun --cap-add NET_ADMIN -t \
48+
-v ${HOSTECDIR}:${EasyConnectDir} \
49+
$params \
50+
shmilee/easyconnect:$tag
51+
echo 'NEWURL: #BREAK#' >>"${HOSTECDIR}"/tmp-url
52+
elif [ x"$use" = xCLI ]; then
53+
docker run --rm --device /dev/net/tun --cap-add NET_ADMIN -i -t \
54+
-v ${HOSTECDIR}:${EasyConnectDir} \
55+
$params \
56+
shmilee/easyconnect:$tag
57+
else
58+
watch_url &
4559
xhost +LOCAL:
4660
docker run --rm --device /dev/net/tun --cap-add NET_ADMIN \
4761
-v ${HOSTECDIR}:${EasyConnectDir} \
@@ -51,12 +65,7 @@ if [ x"$use" = xX11 ]; then
5165
$params \
5266
shmilee/easyconnect:$tag
5367
xhost -LOCAL:
54-
else
55-
docker run --rm --device /dev/net/tun --cap-add NET_ADMIN -t \
56-
-v ${HOSTECDIR}:${EasyConnectDir} \
57-
$params \
58-
shmilee/easyconnect:$tag
68+
echo 'NEWURL: #BREAK#' >>"${HOSTECDIR}"/tmp-url
5969
fi
6070

61-
echo 'NEWURL: #BREAK#' >>"${HOSTECDIR}"/tmp-url
6271
exit 0

0 commit comments

Comments
 (0)