name: tor-middle-relay
version: 0.3.2.9-1
# hey, remember to alter the date in 'daemon' on version changes.
summary: a safe-to-own, yet essential middle node in the Tor network
description: |
  Tor is composed of a client, at least three middle nodes, and a public
  endpoint, and the result is that privacy-seeking users bounce their web
  traffic, ftp, ssh, etc. around the network, and recipients, observers, and
  even the relays themselves have difficulty tracking the source of the stream. 

  This package provides only the middle nodes, which are essential for a robust
  network, but don't provide an entry point or create an exit point; or 25%
  of installations offer to be an second-hop entry-point to aid users in 
  restrivtive regions.

  https://www.eff.org/torchallenge/what-is-tor.html
confinement: strict
grade: stable

apps:
  configure:
    command: sh -u $SNAP/configure

  tor:
    command: sh -u $SNAP/daemon
    daemon: simple
    plugs:
      - network
      - network-bind

  unbound:
    command: unbound -c $SNAP/unboundconf-dont-daemonize
    daemon: simple
    plugs:
      - network
      - network-bind

  monitor:
    command: sh -u $SNAP/monitor
    plugs:
      - network

parts:
  tor:
    plugin: autotools
    source: https://www.torproject.org/dist/tor-0.3.2.9.tar.gz
    configflags:
      - --disable-silent-rules
      - --disable-asciidoc
      - --enable-gcc-warnings
    after:
      - tor-fw-helper
    prime:
      - bin/tor
      - lib/*/librt.so*
      - lib/*/libgcrypt.so*
      - usr/lib/*/libevent-*.so*
    stage-packages:
      - libevent-2.0-5
      - unbound

  config:
    plugin: dump
    source: .
    prime: [ monitor, configure, daemon, torrc-defaults, torrc-template ]

  tor-fw-helper:
    plugin: go
    source: https://git.torproject.org/tor-fw-helper.git
    source-type: git
    source-branch: master   # TODO use tag!
    #https://gitweb.torproject.org/tor-fw-helper.git/
    after: [ go ]

  obfs:
    plugin: go
    source: https://git.torproject.org/pluggable-transports/obfs4.git
    source-type: git
    source-tag: obfs4proxy-0.0.7
    after: [ go ]

  nyx:
    plugin: nil
    stage-packages:
      - tor-arm
    prime:
      - bin/*
      - -bin/2to3*
      - -bin/pdb*
      - -bin/pydoc*
      - -bin/netstat
      - -usr/lib/gcc
      - usr/bin/python2.7
      - usr/share/arm
      - usr/share/pyshared
      - usr/lib/python2.7/abc.py
      - usr/lib/python2.7/atexit.py
      - usr/lib/python2.7/base64.py
      - usr/lib/python2.7/calendar.py
      - usr/lib/python2.7/codecs.py
      - usr/lib/python2.7/collections.py
      - usr/lib/python2.7/ConfigParser.py
      - usr/lib/python2.7/copy.py
      - usr/lib/python2.7/copy_reg.py
      - usr/lib/python2.7/ctypes/_endian.py
      - usr/lib/python2.7/ctypes/util.py
      - usr/lib/python2.7/ctypes/__init__.py
      - usr/lib/python2.7/curses/ascii.py
      - usr/lib/python2.7/curses/textpad.py
      - usr/lib/python2.7/curses/__init__.py
      - usr/lib/python2.7/curses/wrapper.py
      - usr/lib/python2.7/dist-packages/TorCtl
      - usr/lib/python2.7/distutils/errors.py
      - usr/lib/python2.7/distutils/sysconfig.py
      - usr/lib/python2.7/distutils/__init__.py
      - usr/lib/python2.7/encodings/aliases.py
      - usr/lib/python2.7/encodings/ascii.py
      - usr/lib/python2.7/encodings/__init__.py
      - usr/lib/python2.7/fnmatch.py
      - usr/lib/python2.7/functools.py
      - usr/lib/python2.7/genericpath.py
      - usr/lib/python2.7/getopt.py
      - usr/lib/python2.7/getpass.py
      - usr/lib/python2.7/hashlib.py
      - usr/lib/python2.7/heapq.py
      - usr/lib/python2.7/io.py
      - usr/lib/python2.7/keyword.py
      - usr/lib/python2.7/lib-dynload/_ctypes.*.so
      - usr/lib/python2.7/lib-dynload/_curses.*.so
      - usr/lib/python2.7/lib-dynload/_hashlib.*.so
      - usr/lib/python2.7/lib-dynload/_ssl.*.so
      - usr/lib/python2.7/lib-dynload/termios.*.so
      - usr/lib/python2.7/linecache.py
      - usr/lib/python2.7/locale.py
      - usr/lib/python2.7/logging/__init__.py
      - usr/lib/python2.7/os.py
      - usr/lib/python2.7/platform.py
      - usr/lib/python2.7/plat-*/_sysconfigdata_nd.py
      - usr/lib/python2.7/posixpath.py
      - usr/lib/python2.7/Queue.py
      - usr/lib/python2.7/random.py
      - usr/lib/python2.7/re.py
      - usr/lib/python2.7/shutil.py
      - usr/lib/python2.7/site.py
      - usr/lib/python2.7/socket.py
      - usr/lib/python2.7/sre_compile.py
      - usr/lib/python2.7/sre_constants.py
      - usr/lib/python2.7/sre_parse.py
      - usr/lib/python2.7/stat.py
      - usr/lib/python2.7/string.py
      - usr/lib/python2.7/struct.py
      - usr/lib/python2.7/sysconfig.py
      - usr/lib/python2.7/tempfile.py
      - usr/lib/python2.7/threading.py
      - usr/lib/python2.7/traceback.py
      - usr/lib/python2.7/types.py
      - usr/lib/python2.7/UserDict.py
      - usr/lib/python2.7/warnings.py
      - usr/lib/python2.7/weakref.py
      - usr/lib/python2.7/_abcoll.py
      - usr/lib/python2.7/_strptime.py
      - usr/lib/python2.7/_sysconfigdata.py
      - usr/lib/python2.7/_weakrefset.py
      - usr/lib/python2.7/__future__.py

build-packages:
  - libssl-dev
  - liblzma-dev
  - libevent-dev
