Merge branch 'testing'

This commit is contained in:
AntiTree 2016-07-09 19:46:05 -04:00
commit b1f07efb6a
7 changed files with 62 additions and 69 deletions

View File

@ -16,48 +16,49 @@
FROM debian:jessie
MAINTAINER Antitree antitree@protonmail.com
# Sets which version of tor to use. See the Tor Projects git page for available tags
# Examples:
# * tor-0.2.8.4-rc
# * tor-0.2.7.6
# * tor-0.2.7.5
# * release-0.2.1
ENV TOR_VER="master"
#ENV TOR_VER="release-0.2.1"
# Sets the nickname if you didn't set one, default ports, and the path
# where to mount the key material used by the clients.
ENV TOR_NICKNAME=Tor4 \
TERM=xterm \
ENV TERM=xterm \
TOR_ORPORT=7000 \
TOR_DIRPORT=9030 \
TOR_DIR=/tor
# Add the official torproject.org Debian Tor repository
# - this will always build/install the latest stable version
COPY ./config/tor-apt-sources.list /etc/apt/sources.list.d/
# Build & Install:
# - add the gpg key used to sign the packages
# - install build dependencies (and nano)
# - add a 'builder' user for compiling the package as a non-root user
# - build Tor in ~/debian-packages and install the new Tor package
# - backup torrc & cleanup all dependencies and caches
# - adds only 13 MB to the Debian base image (without obfsproxy, which adds another 60 MB)
# TODO: Allow selection of which version of tor to build
RUN gpg --keyserver keys.gnupg.net --recv 886DDD89 && \
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add - && \
apt-get update && \
build_deps="build-essential fakeroot devscripts quilt libssl-dev zlib1g-dev libevent-dev \
asciidoc docbook-xml docbook-xsl xmlto dh-apparmor libseccomp-dev dh-systemd \
libsystemd-dev pkg-config dh-autoreconf hardening-includes" && \
# Install build dependencies
RUN apt-get update && \
build_deps="build-essential automake libssl-dev zlib1g-dev libevent-dev ca-certificates\
dh-apparmor libseccomp-dev dh-systemd \
git" && \
DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install $build_deps \
obfsproxy \
tor-geoipdb \
init-system-helpers \
pwgen \
nano && \
adduser --disabled-password --gecos "" builder && \
su builder -c 'mkdir -v ~/debian-packages; cd ~/debian-packages && \
apt-get -y source tor && \
cd tor-* && \
debuild -rfakeroot -uc -us' && \
dpkg -i /home/builder/debian-packages/tor_*.deb && \
mv -v /etc/tor/torrc /etc/tor/torrc.default && \
deluser --remove-home builder && \
pwgen
# Build tor
# clone the latest from the tor repos
# autogen, configure, make, and install tor
# cleanup after
RUN mkdir /src && \
cd /src && \
git clone https://git.torproject.org/tor.git && \
cd tor && \
git checkout ${TOR_VER}
RUN ./autogen.sh && \
./configure --disable-asciidoc && \
make && \
make install && \
apt-get -y purge --auto-remove $build_deps && \
apt-get clean && rm -r /var/lib/apt/lists/*
apt-get clean && rm -r /var/lib/apt/lists/* && \
rm -rf /src/*
# Copy the base tor configuration file
COPY ./config/torrc* /etc/tor/

View File

@ -1,5 +1,5 @@
# Run Tor as a regular user (do not change this)
User debian-tor
#User debian-tor
TestingTorNetwork 1

View File

@ -1,7 +1,7 @@
version: '2'
services:
da1:
image: antitree/private-tor
image: antitree/private-tor-test
expose:
- "7000"
- "9030"
@ -11,7 +11,7 @@ services:
## Needed to keep track of other nodes
- ./tor:/tor
da2:
image: antitree/private-tor
image: antitree/private-tor-test
expose:
- "7000"
- "9030"
@ -21,7 +21,7 @@ services:
## Needed to keep track of other nodes
- ./tor:/tor
da3:
image: antitree/private-tor
image: antitree/private-tor-test
expose:
- "7000"
- "9030"
@ -31,7 +31,7 @@ services:
## Needed to keep track of other nodes
- ./tor:/tor
relay:
image: antitree/private-tor
image: antitree/private-tor-test
expose:
- "7000"
- "9030"
@ -45,7 +45,7 @@ services:
- da2
- da3
exit:
image: antitree/private-tor
image: antitree/private-tor-test
expose:
- "7000"
- "9030"
@ -59,7 +59,7 @@ services:
- da2
- da3
client:
image: antitree/private-tor
image: antitree/private-tor-test
ports:
# Setups a listener on host machine
- "9050:9050"

View File

@ -7,6 +7,6 @@ RELAY=$(cat $TOR_DIR/$TOR_NICK/fingerprint|awk -F " " '{print $2}')
SERVICE=$(grep "dir-address" $TOR_DIR/$TOR_NICK/keys/* | awk -F " " '{print $2}')
IPADDR=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
TORRC="DirAuthority $NICK orport=${TOR_ORPORT} no-v2 v3ident=$AUTH $SERVICE $RELAY"
TORRC="DirAuthority $TOR_NICK orport=${TOR_ORPORT} no-v2 v3ident=$AUTH $SERVICE $RELAY"
echo $TORRC

View File

@ -3,35 +3,18 @@ set -o errexit
# Fudge the sleep to try and keep the consensus
#FUDGE=$(( ( RANDOM % 100) + 20 ))
FUDGE=30
FUDGE=3
echo -e "\n========================================================"
# If DataDirectory or secret_id_key is mounted here, it must be owned by the debian-tor user
chown -Rv debian-tor:debian-tor ${TOR_DIR}
if [ ! -e /tor-config-done ]; then
touch /tor-config-done # only run this once
# Add a Nickname, if none has been set in torrc
if ! grep -q '^Nickname ' /etc/tor/torrc; then
if [ ${TOR_NICKNAME} == "Tor4" ]; then
# if user did not change the default Nickname, genetrate a random pronounceable one
RPW=$(pwgen -0A 10)
export TOR_NICKNAME=${ROLE}${RPW}
echo "Setting random Nickname: ${TOR_NICKNAME}"
else
echo "Setting chosen Nickname: ${TOR_NICKNAME}"
fi
echo -e "\nNickname ${TOR_NICKNAME}" >> /etc/tor/torrc
fi
# Add ContactInfo from env variable, if none has been set in torrc
if ! grep -q '^ContactInfo ' /etc/tor/torrc; then
if [ -n "${CONTACT_EMAIL}" ]; then
echo "Setting Contact Email: ${CONTACT_EMAIL}"
echo -e "\nContactInfo ${CONTACT_EMAIL}" >> /etc/tor/torrc
fi
fi
# Generate a random name
RPW=$(pwgen -0A 10)
export TOR_NICKNAME=${ROLE}${RPW}
echo "Setting random Nickname: ${TOR_NICKNAME}"
echo -e "\nNickname ${TOR_NICKNAME}" >> /etc/tor/torrc
# Host specific modifications to the torrc file
echo -e "DataDirectory ${TOR_DIR}/${TOR_NICKNAME}" >> /etc/tor/torrc
@ -43,7 +26,6 @@ if [ ! -e /tor-config-done ]; then
fi
echo -e "HashedControlPassword ${TOR_CONTROL_PWD}" >> /etc/tor/torrc
# Changes to the torrc file based on the desired role
case ${ROLE} in
DA)
@ -54,13 +36,11 @@ if [ ! -e /tor-config-done ]; then
echo -e "ExitPolicy accept *:*" >> /etc/tor/torrc
KEYPATH=${TOR_DIR}/${TOR_NICKNAME}/keys
mkdir -p ${KEYPATH}
chown -Rv debian-tor:debian-tor ${TOR_DIR}
echo "password" | tor-gencert --create-identity-key -m 12 -a ${TOR_IP}:${TOR_DIRPORT} \
-i ${KEYPATH}/authority_identity_key \
-s ${KEYPATH}/authority_signing_key \
-c ${KEYPATH}/authority_certificate \
--passphrase-fd 0
chown -Rv debian-tor:debian-tor ${TOR_DIR}
tor --list-fingerprint --orport 1 \
--dirserver "x 127.0.0.1:1 ffffffffffffffffffffffffffffffffffffffff" \
--datadirectory ${TOR_DIR}/${TOR_NICKNAME}
@ -97,7 +77,6 @@ if [ ! -e /tor-config-done ]; then
sleep $FUDGE
cat ${TOR_DIR}/torrc.da >> /etc/tor/torrc
fi
echo -e "\n========================================================"

12
util/README.md Normal file
View File

@ -0,0 +1,12 @@
## Utils
This folder contains various scripts to let you perform
functions on your tor instance. Many of these are from the
[Stem Website](https://stem.torproject.org) which has
additional documentation on functions you can perform.
Other examples:
Use tor-prompt to interact with a docker process:
```tor-prompt -i 172.16.0.3:9051``

View File

@ -3,5 +3,6 @@ from stem.control import Controller
with Controller.from_port(port = 9051) as controller:
controller.authenticate("password")
print("List of relays found on the network:")
for desc in controller.get_network_statuses():
print("found relay %s (%s)" % (desc.nickname, desc.fingerprint))
print("%s (%s) at %s" % (desc.nickname, desc.fingerprint, desc.address))