inital
This commit is contained in:
commit
925e63eece
4
.dockerignore
Normal file
4
.dockerignore
Normal file
|
@ -0,0 +1,4 @@
|
|||
Dockerfile
|
||||
.dockerignore
|
||||
.git
|
||||
.gitignore
|
35
Dockerfile
Normal file
35
Dockerfile
Normal file
|
@ -0,0 +1,35 @@
|
|||
FROM ubuntu:15.04
|
||||
|
||||
VOLUME /var/lib/docker
|
||||
|
||||
RUN bash /usr/local/bin/install_docker
|
||||
|
||||
ADD ./dind/wrapdocker /usr/local/bin/wrapdocker
|
||||
|
||||
RUN chmod +x /usr/local/bin/wrapdocker
|
||||
|
||||
COPY ./env.sh /usr/local/bin/set_env
|
||||
|
||||
COPY ./shutdown.sh /usr/local/bin/stop-tor-router
|
||||
|
||||
COPY ./startup.sh /usr/local/bin/stop-tor-router
|
||||
|
||||
COPY ./tor-router.sh /usr/local/bin/tor-router
|
||||
|
||||
COPY ./new_ip.sh /usr/local/bin/new-ip
|
||||
|
||||
RUN chmod -v +x /usr/local/bin/set_env
|
||||
|
||||
RUN chmod -v +x /usr/local/bin/stop-tor-router
|
||||
|
||||
RUN chmod -v +x /usr/local/bin/start-tor-router
|
||||
|
||||
RUN chmod -v +x /usr/local/bin/tor-router
|
||||
|
||||
RUN chmod -v +x /usr/local/bin/new-ip
|
||||
|
||||
EXPOSE 9050
|
||||
|
||||
ENV TOR_INSTANCES 5
|
||||
|
||||
CMD ["/usr/local/bin/tor-router"]
|
10
Makefile
Normal file
10
Makefile
Normal file
|
@ -0,0 +1,10 @@
|
|||
all: dind .drone.yml
|
||||
|
||||
clean:
|
||||
rm -f .drone.yml
|
||||
|
||||
dind:
|
||||
git subtree add --prefix dind https://github.com/jpetazzo/dind.git master --squash
|
||||
|
||||
.drone.yml:
|
||||
wget -qO- http://bit.ly/drone-yml-php | php > .drone.yml
|
5
env.sh
Executable file
5
env.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
export TOR_INSTANCES=${TOR_INSTANCES:=5}
|
||||
export TOR_PORT=${TOR_PORT:=9050}
|
||||
export INSTANCE_PREFIX="tor-"
|
||||
export IP_ADDRESS=$1
|
||||
export CONTROL_PORT_DIR=$2
|
20
new_ip.sh
Executable file
20
new_ip.sh
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Sends a HUP signal to Tor instances, generating a new IP
|
||||
|
||||
source env.sh
|
||||
|
||||
index="0"
|
||||
|
||||
while [ $index -lt $TOR_INSTANCES ]
|
||||
do
|
||||
current_instance="$INSTANCE_PREFIX$index"
|
||||
|
||||
echo "sending signal to $current_instance..."
|
||||
docker exec -t $current_instance /bin/bash -c 'pgrep -f tor | xargs kill -HUP'
|
||||
index=$[$index+1]
|
||||
done
|
||||
|
||||
sleep 1
|
||||
|
||||
exit 0
|
30
package.json
Normal file
30
package.json
Normal file
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "tor-router",
|
||||
"version": "0.0.1",
|
||||
"author": [
|
||||
{
|
||||
"name": "Zachary Boyd",
|
||||
"email": "zacharyboyd@zacharyboyd.nyc"
|
||||
}
|
||||
],
|
||||
"repository": [
|
||||
{
|
||||
"type": "docker",
|
||||
"url": "http://docker.io/znetstar"
|
||||
},
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://bitbucket.org/znetstar/tor-router"
|
||||
}
|
||||
],
|
||||
"homepage": "",
|
||||
"dependencies": {
|
||||
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "make"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
}
|
||||
}
|
23
shutdown.sh
Executable file
23
shutdown.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
source env.sh
|
||||
|
||||
index="0"
|
||||
|
||||
while [ $index -lt $TOR_INSTANCES ]
|
||||
do
|
||||
current_instance=$INSTANCE_PREFIX$index
|
||||
echo "shutting down $current_instance"
|
||||
docker rm -f $current_instance
|
||||
index=$[index+1]
|
||||
done
|
||||
|
||||
echo "stop haproxy"
|
||||
docker rm -f haproxy
|
||||
|
||||
echo "closing port"
|
||||
sudo iptables -A INPUT -p tcp --dport 9050 -j REJECT
|
||||
|
||||
#sleep 5
|
||||
|
||||
exit 0
|
77
startup.sh
Executable file
77
startup.sh
Executable file
|
@ -0,0 +1,77 @@
|
|||
#!/bin/bash
|
||||
|
||||
source env.sh
|
||||
|
||||
TEMP_HA_CONFIG=$(mktemp)
|
||||
TOR_CMD='tor --MaxCircuitDirtiness 60 --RunAsDaemon 0 --CookieAuthentication 0 --controlport 0.0.0.0:9051 --HashedControlPassword 16:4E9480609FC7089F604C83E788481164C25C205288E17D9E5E73EB050B --PidFile tor.pid --SocksPort 0.0.0.0:9150 --DataDirectory /data/tor --ExcludeSingleHopRelays 0 --NewCircuitPeriod 30 --EnforceDistinctSubnets 0 --AllowDotExit 1'
|
||||
|
||||
index="0"
|
||||
|
||||
#docker -d &
|
||||
|
||||
while [ $index -lt $TOR_INSTANCES ]
|
||||
do
|
||||
current_instance="$INSTANCE_PREFIX$index"
|
||||
echo "removing instance $current_instance..."
|
||||
docker kill $current_instance
|
||||
docker rm -f $current_instance
|
||||
echo "instance $current_instance removed"
|
||||
|
||||
# control_port=$(cat $2/$current_instance)
|
||||
echo "instnce $current_instance will be assigned control port control port $control_port"
|
||||
|
||||
echo "creating instance $current_instance..."
|
||||
docker run --name $current_instance -d -v /data --restart="on-failure" nagev/tor $TOR_CMD
|
||||
echo "instance $current_instance created"
|
||||
index=$[$index+1]
|
||||
done
|
||||
|
||||
echo "removing haproxy..."
|
||||
docker kill haproxy
|
||||
docker rm -f haproxy
|
||||
echo "writing config..."
|
||||
cat << EOF > $TEMP_HA_CONFIG
|
||||
global
|
||||
user root
|
||||
group root
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option dontlognull
|
||||
timeout connect 5000ms
|
||||
timeout client 50000ms
|
||||
timeout server 50000ms
|
||||
errorfile 400 /usr/local/etc/haproxy/errors/400.http
|
||||
errorfile 403 /usr/local/etc/haproxy/errors/403.http
|
||||
errorfile 408 /usr/local/etc/haproxy/errors/408.http
|
||||
errorfile 500 /usr/local/etc/haproxy/errors/500.http
|
||||
errorfile 502 /usr/local/etc/haproxy/errors/502.http
|
||||
errorfile 503 /usr/local/etc/haproxy/errors/503.http
|
||||
errorfile 504 /usr/local/etc/haproxy/errors/504.http
|
||||
EOF
|
||||
|
||||
echo "listen socks :$TOR_PORT" > $TEMP_HA_CONFIG
|
||||
|
||||
cat <<-EOF >> $TEMP_HA_CONFIG
|
||||
mode tcp
|
||||
balance roundrobin
|
||||
EOF
|
||||
|
||||
index="0"
|
||||
instances=""
|
||||
while [ $index -lt $TOR_INSTANCES ]
|
||||
do
|
||||
current_instance=$INSTANCE_PREFIX$index
|
||||
instances=$instances" --link $current_instance:$current_instance"
|
||||
cat <<-EOF >> $TEMP_HA_CONFIG
|
||||
server $current_instance $current_instance:9150 check
|
||||
EOF
|
||||
index=$[$index+1]
|
||||
done
|
||||
|
||||
echo "starting haproxy..."
|
||||
docker run -d -p 9050:9050 --name haproxy $instances -v $TEMP_HA_CONFIG:/usr/local/etc/haproxy/haproxy.cfg:ro haproxy:1.5.9
|
||||
echo "tor server setup is complete"
|
||||
|
||||
exit 0
|
16
tor-router.sh
Normal file
16
tor-router.sh
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
wrapdocker &
|
||||
sleep 5
|
||||
|
||||
echo 'starting tor router...'
|
||||
/usr/local/bin/start-tor-router
|
||||
|
||||
docker kill haproxy
|
||||
docker start -a -i haproxy
|
||||
|
||||
echo 'stopping tor router...'
|
||||
/usr/local/bin/stop-tor-router
|
||||
start-stop-daemon --stop --pidfile "/var/run/docker.pid"
|
||||
|
||||
exit 0
|
Loading…
Reference in a new issue