Skip to content

Commit b86af02

Browse files
author
Silvio Gohl
committed
init
1 parent 8c7a356 commit b86af02

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

Dockerfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM msoap/shell2http
2+
3+
ARG CONFDIR=/config
4+
ENV CONFDIR=${CONFDIR}
5+
COPY config ${CONFDIR}
6+
7+
COPY pac.sh /usr/local/bin/pac.sh
8+
RUN chmod -R +x /usr/local/bin
9+
10+
ENV PORT=8080
11+
12+
ENV DEFAULTCONFIG=default
13+
14+
ENTRYPOINT /app/shell2http -form -no-index -export-vars=CONFDIR -port ${PORT} \
15+
/proxy.pac 'CONFIG=${v_conf} IP=${v_ip} PORT=${v_port} pac.sh'
16+

config/example.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
example.org
2+
example.net

pac.sh

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/sh
2+
3+
if [[ -z ${IP} ]]
4+
then
5+
6+
IP="proxy"
7+
8+
fi
9+
10+
if [[ -z ${PORT} ]]
11+
then
12+
13+
PORT=3128
14+
15+
fi
16+
17+
if [[ -z ${CONF} ]]
18+
then
19+
20+
CONF=${DEFAULTCONFIG}
21+
22+
fi
23+
24+
CONF=${CONFDIR}/${CONF%.txt}.txt
25+
26+
echo "
27+
function FindProxyForURL( url, host )
28+
{
29+
30+
var proxyserver = \"${IP}:${PORT}\";
31+
32+
var proxylist = new Array(
33+
"
34+
35+
while read DOMAIN
36+
do
37+
38+
[ -z "$DOMAIN" ] && continue
39+
40+
echo " '${DOMAIN}',"
41+
42+
done < ${CONF}
43+
44+
echo " );"
45+
46+
echo "
47+
for (var i = 0; i < proxylist.length; i++)
48+
{
49+
var value = proxylist[i];
50+
51+
if (shExpMatch(host, value))
52+
{
53+
return \"PROXY \"+proxyserver;
54+
}
55+
}
56+
57+
return "DIRECT";
58+
}
59+
"
60+

0 commit comments

Comments
 (0)