1. 21 Apr, 2016 1 commit
    • Philipp Winter's avatar
      Refactor logging and enable logging to file. · 52ac9c18
      Philipp Winter authored
      This commit adds the command line options "-o" and "--logfile" that
      enable logging to file.  This functionality required minor restructuring
      that led to a simplification of the logging code.  In particular:
      
      - We get rid of log.py because it was never really necessary.
      
      - We use named loggers, so it's easier to figure out what module logged
        a given message.
      
      - We rename our logging object from "logger" to "log" to make the code
        more readable.
      
      - The restructuring means that we now also get to see Stem's logging
        messages.
      52ac9c18
  2. 15 Apr, 2016 3 commits
  3. 14 Apr, 2016 1 commit
    • Philipp Winter's avatar
      Add command line option for random build delays. · a20713b7
      Philipp Winter authored
      This command line option hopefully makes it a little bit more difficult
      for vigilant adversaries to discover our scanning activity.  It adds a
      random value to the time delay between two subsequent circuit creations.
      As a result, if an adversary monitors circuit creation timings, our
      signal should be less periodic and thus less obvious.
      
      We implement this feature by exposing a command line argument that
      determines a random time delay in the interval [0, DELAY_NOISE).  This
      delay is then either added to or subtracted from (both with probability
      0.5) the given build delay.  By default, the argument is 0, and
      therefore not in effect.
      a20713b7
  4. 13 Apr, 2016 1 commit
  5. 11 Apr, 2016 4 commits
    • Philipp Winter's avatar
      Fix PyPy 2.6.1 issue. · fd102fea
      Philipp Winter authored
      Travis CI discovered that PyPy in version 2.6.1 apparently lacks the
      ENOTSUP variable.  This commit defines the variable if it does not exist
      already.  The exact test error was:
      
        ============================= test session starts ==============================
      
        platform linux2 -- Python 2.7.10[pypy-2.6.1-final], pytest-2.8.5, py-1.4.31, pluggy-0.3.1
      
        rootdir: /home/travis/build/NullHypothesis/exitmap, inifile:
      
        plugins: cov-2.2.1
      
        collected 8 items / 1 errors
      
        test/test_relayselector.py .
      
        test/test_stats.py .
      
        test/test_util.py ......
      
        ==================================== ERRORS ====================================
      
        ____________________ ERROR collecting test/test_torsocks.py ____________________
      
        test/test_torsocks.py:24: in <module>
      
            import torsocks
      
        src/torsocks.py:61: in <module>
      
            0x07: errno.ENOTSUP,      # Command not supported / protocol error
      
        E   AttributeError: 'module' object has no attribute 'ENOTSUP'
      fd102fea
    • Philipp Winter's avatar
      Remove broken unit tests. · 6bfa04a9
      Philipp Winter authored
      After torsocks.py and relayselector.py have been refactored, we will
      have to rewrite the unit tests.
      6bfa04a9
    • Philipp Winter's avatar
      Use correct variable. · 4a2665f0
      Philipp Winter authored
      4a2665f0
    • Philipp Winter's avatar
      Merge pull request #48 from zackw/master · d3d197a9
      Philipp Winter authored
      RFC: New module 'rtt' and a bunch of changes in aid of what it does
      d3d197a9
  6. 29 Mar, 2016 5 commits
    • Zack Weinberg's avatar
      New module rtt.py, which measures round-trip times through exits. · bf40a5fc
      Zack Weinberg authored
      The preceding changes are all in aid of this module.  Note that it
      currently isn't 100% robust.  It works well for _one_ exit, but
      if you try to run it over many destinations and all exits, fewer
      and fewer connections will work correctly as time goes by.  I could
      use some debugging help.
      
      selectors34.py and six.py are third-party code licensed under MIT-like
      licenses.  They are backports of Python 3.(>=4) standard library
      functionality to Python 2, and redistributing them in this fashion
      is encouraged by their authors.
      bf40a5fc
    • Zack Weinberg's avatar
      Tell probe() what destinations it can connect to via each exit. · a9f6091a
      Zack Weinberg authored
      Formerly, only exits that could connect to _all_ of a module's requested
      destinations were included in the set of exits to be probed.  Now,
      instead, every exit that can connect to _at least one_ of a module's
      requested destinations will be included, and probe() receives a new
      keyword argument, destinations=, that tells it which destinations it
      can use for each exit.  (The destinations list will be a proper subset
      of module.destinations, with all hostnames resolved to IP addresses.)
      
      This does not affect the behavior of any existing module, because all
      of the existing modules use only a single destination.
      a9f6091a
    • Zack Weinberg's avatar
      Make all probe() functions accept and ignore arbitrary kwargs. · c41a346d
      Zack Weinberg authored
      This is forward-compatibility for the next change, in which
      a new kwarg (that none of them need, but a new module does)
      will be added.
      c41a346d
    • Zack Weinberg's avatar
      Support nonblocking connections in torsocks. · 5f1bd178
      Zack Weinberg authored
      This was a major revision to the torsocks module, but the _effect_
      is simple to explain: a probe module can now do
      
          s = socket.socket(AF_UNIX, SOCK_STREAM)
          s.setblocking(False)
          err = s.connect_ex(addr)
          if err == errno.EINPROGRESS:
              select.select([s], [], [])
      
      and the select() will return when the connection is complete.  (In a real
      module that needs this, one would have _several_ pending connections and
      process them as they become available.)  Note that there is a visible
      difference from how a normal socket behaves, here: you select for the
      socket to become _readable_ before continuing.  A normal socket becomes
      _writable_ when the TCP handshake completes.
      
      There's a bunch of secondary work in here in aid of making the emulation
      of non-blocking half-open socket behavior as accurate as possible, and
      an ancillary change (too difficult to disentangle into its own commit)
      in which we make the monkey-patching of socket.socket more robust.  It
      is no longer necessary to put back the original socket.socket around
      event queue operations, and the monkey-patching will be 100% cleaned
      up if a module throws an uncaught exception.
      5f1bd178
    • Zack Weinberg's avatar
      Serialize calls to check_finished(). · c9cd2aa5
      Zack Weinberg authored
      eventhandler.EventHandler.check_finished is called by both the queue
      thread and the main thread, but the tear-down operations that it performs
      must only happen once.  The call to sys.exit() DOES NOT prevent the
      tear-down from happening twice.  (Is the "queue_thread.daemon = False"
      line in EventHandler.__init__ perhaps meant to be "= True"?  It wouldn't
      fix the race here, but it might prevent other problems, e.g. the program
      hanging forever if a module throws an uncaught exception.)  Anyway,
      add an explicit lock.
      c9cd2aa5
  7. 25 Mar, 2016 3 commits
  8. 20 Mar, 2016 2 commits
  9. 14 Mar, 2016 2 commits
    • Philipp Winter's avatar
      Make modules work stand-alone again. · afb174a1
      Philipp Winter authored
      afb174a1
    • Philipp Winter's avatar
      Use Python 2 in shebangs. · a4dccea4
      Philipp Winter authored
      "#!/usr/bin/env python" is too general and could return Python 3 on some
      systems.  Since exitmap currently does not support Python 3, this commit
      replaces the line with "#/usr/bin/env python2", thus making explicit use
      of Python 2.
      
      Thanks to Deepankar for pointing out this issue!
      a4dccea4
  10. 12 Mar, 2016 1 commit
  11. 10 Mar, 2016 2 commits
  12. 09 Mar, 2016 1 commit
  13. 06 Mar, 2016 2 commits
  14. 01 Mar, 2016 2 commits
  15. 11 Jan, 2016 2 commits
    • Philipp Winter's avatar
      Fix command module. · 26520b5f
      Philipp Winter authored
      In particular, this commit makes the following fixes:
      
      - Write TorPort and TorAddress to the temporary torsocks configuration
        file.
      
      - Make eventhandler hand Tor's SOCKS port to the command module.
      
      - Improved command line logging.
      26520b5f
    • Philipp Winter's avatar
      PEP8 fix. · f7b974e2
      Philipp Winter authored
      f7b974e2
  16. 10 Jan, 2016 2 commits
  17. 05 Jan, 2016 1 commit
  18. 03 Jan, 2016 5 commits