Hello community, here is the log from the commit of package python-txtorcon for openSUSE:Factory checked in at 2020-04-07 10:29:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-txtorcon (Old) and /work/SRC/openSUSE:Factory/.python-txtorcon.new.3248 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-txtorcon" Tue Apr 7 10:29:57 2020 rev:7 rq:791685 version:20.0.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-txtorcon/python-txtorcon.changes 2020-01-02 14:43:22.376959965 +0100 +++ /work/SRC/openSUSE:Factory/.python-txtorcon.new.3248/python-txtorcon.changes 2020-04-07 10:31:36.674521238 +0200 @@ -1,0 +2,10 @@ +Mon Apr 6 08:18:04 UTC 2020 - Marketa Calabkova <mcalabk...@suse.com> + +- Update to 20.0.0 + * Use real GeoIP database or nothing (https://github.com/meejah/txtorcon/issues/250) + * Change abstract base classes import in preperation for Python 3.8 (thanks @glowatsk) + * Python 3.4 is no longer supported + * Python 2 is deprecated; all new code should be Python 3. Support + for Python 2 will be removed in a future release. + +------------------------------------------------------------------- Old: ---- txtorcon-19.1.0.tar.gz New: ---- txtorcon-20.0.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-txtorcon.spec ++++++ --- /var/tmp/diff_new_pack.oQdU5g/_old 2020-04-07 10:31:40.046525631 +0200 +++ /var/tmp/diff_new_pack.oQdU5g/_new 2020-04-07 10:31:40.046525631 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-txtorcon # -# Copyright (c) 2019 SUSE LLC +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} %{!?skip_python3:python3-%{**}}} Name: python-txtorcon -Version: 19.1.0 +Version: 20.0.0 Release: 0 Summary: Twisted-based asynchronous Tor control protocol implementation License: MIT @@ -66,7 +66,7 @@ %check # looks more like integration tests -%pytest -k 'not (test_real_addr or test_return_geoip_object)' +%pytest -k 'not test_real_addr' %files %{python_files} %license LICENSE docs/*.rst ++++++ txtorcon-19.1.0.tar.gz -> txtorcon-20.0.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/Makefile new/txtorcon-20.0.0/Makefile --- old/txtorcon-19.1.0/Makefile 2019-09-10 08:50:29.000000000 +0200 +++ new/txtorcon-20.0.0/Makefile 2020-03-31 04:43:49.000000000 +0200 @@ -1,6 +1,6 @@ -.PHONY: test html counts coverage sdist clean install doc integration diagrams dist-hs +.PHONY: test html counts coverage sdist clean install doc integration diagrams default: test -VERSION = 19.1.0 +VERSION = 20.0.0 test: PYTHONPATH=. trial --reporter=text test @@ -103,20 +103,6 @@ dist-sigs: dist/txtorcon-${VERSION}-py2.py3-none-any.whl.asc dist/txtorcon-${VERSION}.tar.gz.asc -dist-hs: - cp dist/txtorcon-${VERSION}-py2.py3-none-any.whl ~/tools/dist/txtorcon3/git/docs/_build/html/ - cp dist/txtorcon-${VERSION}-py2.py3-none-any.whl.asc ~/tools/dist/txtorcon3/git/docs/_build/html/ - cp dist/txtorcon-${VERSION}-py2.py3-none-any.whl ~/tools/dist/txtorcon/git/docs/_build/html/ - cp dist/txtorcon-${VERSION}-py2.py3-none-any.whl.asc ~/tools/dist/txtorcon/git/docs/_build/html/ - cp dist/txtorcon-${VERSION}.tar.gz ~/tools/dist/txtorcon3/git/docs/_build/html/ - cp dist/txtorcon-${VERSION}.tar.gz.asc ~/tools/dist/txtorcon3/git/docs/_build/html/ - cp dist/txtorcon-${VERSION}.tar.gz ~/tools/dist/txtorcon/git/docs/_build/html/ - cp dist/txtorcon-${VERSION}.tar.gz.asc ~/tools/dist/txtorcon/git/docs/_build/html/ - -check-sigs: - gpg --verify dist/txtorcon-${VERSION}-py2.py3-none-any.whl.asc - gpg --verify dist/txtorcon-${VERSION}.tar.gz.asc - sdist: setup.py python setup.py check python setup.py sdist diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/PKG-INFO new/txtorcon-20.0.0/PKG-INFO --- old/txtorcon-19.1.0/PKG-INFO 2019-09-10 08:50:32.000000000 +0200 +++ new/txtorcon-20.0.0/PKG-INFO 2020-04-01 04:56:34.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: txtorcon -Version: 19.1.0 +Version: 20.0.0 Summary: Twisted-based Tor controller client, with state-tracking and configuration abstractions. https://txtorcon.readthedocs.org https://github.com/meejah/txtorcon Home-page: https://github.com/meejah/txtorcon Author: meejah @@ -51,7 +51,7 @@ - **code**: https://github.com/meejah/txtorcon - ``torsocks git clone git://timaq4ygg2iegci7.onion/txtorcon.git`` - MIT-licensed; - - Python 2.7, PyPy 5.0.0+, Python 3.4+; + - Python 2.7, PyPy 5.0.0+, Python 3.5+; - depends on `Twisted`_, `Automat <https://github.com/glyph/automat>`_, @@ -79,53 +79,59 @@ --------------------------------------- `download <examples/readme.py>`_ - (also `python3 style <examples/readme3.py>`_) + (also `python2 style <examples/readme2.py>`_) .. code:: python from twisted.internet.task import react - from twisted.internet.defer import inlineCallbacks + from twisted.internet.defer import inlineCallbacks, ensureDeferred from twisted.internet.endpoints import UNIXClientEndpoint + import treq import txtorcon - @react - @inlineCallbacks - def main(reactor): - tor = yield txtorcon.connect( + + async def main(reactor): + tor = await txtorcon.connect( reactor, UNIXClientEndpoint(reactor, "/var/run/tor/control") ) print("Connected to Tor version {}".format(tor.version)) - url = 'https://www.torproject.org:443' - print("Downloading {}".format(url)) - resp = yield treq.get(url, agent=tor.web_agent()) - - print(" {} bytes".format(resp.length)) - data = yield resp.text() - print("Got {} bytes:\n{}\n[...]{}".format( + url = u'https://www.torproject.org:443' + print(u"Downloading {}".format(repr(url))) + resp = await treq.get(url, agent=tor.web_agent()) + + print(u" {} bytes".format(resp.length)) + data = await resp.text() + print(u"Got {} bytes:\n{}\n[...]{}".format( len(data), data[:120], data[-120:], )) - print("Creating a circuit") - state = yield tor.create_state() - circ = yield state.build_circuit() - yield circ.when_built() - print(" path: {}".format(" -> ".join([r.ip for r in circ.path]))) - - print("Downloading meejah's public key via above circuit...") - resp = yield treq.get( - 'https://meejah.ca/meejah.asc', - agent=circ.web_agent(reactor, tor.config.socks_endpoint(reactor)), + print(u"Creating a circuit") + state = await tor.create_state() + circ = await state.build_circuit() + await circ.when_built() + print(u" path: {}".format(" -> ".join([r.ip for r in circ.path]))) + + print(u"Downloading meejah's public key via above circuit...") + config = await tor.get_config() + resp = await treq.get( + u'https://meejah.ca/meejah.asc', + agent=circ.web_agent(reactor, config.socks_endpoint(reactor)), ) - data = yield resp.text() + data = await resp.text() print(data) + @react + def _main(reactor): + return ensureDeferred(main(reactor)) + + Try It Now On Debian/Ubuntu --------------------------- @@ -135,7 +141,7 @@ .. code-block:: shell-session - $ sudo apt-get install --install-suggests python-txtorcon + $ sudo apt-get install --install-suggests python3-txtorcon $ twistd -n web --port "onion:80" --path ~/public_html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/README.rst new/txtorcon-20.0.0/README.rst --- old/txtorcon-19.1.0/README.rst 2019-09-10 08:49:17.000000000 +0200 +++ new/txtorcon-20.0.0/README.rst 2020-03-31 04:32:26.000000000 +0200 @@ -43,7 +43,7 @@ - **code**: https://github.com/meejah/txtorcon - ``torsocks git clone git://timaq4ygg2iegci7.onion/txtorcon.git`` - MIT-licensed; -- Python 2.7, PyPy 5.0.0+, Python 3.4+; +- Python 2.7, PyPy 5.0.0+, Python 3.5+; - depends on `Twisted`_, `Automat <https://github.com/glyph/automat>`_, @@ -71,53 +71,59 @@ --------------------------------------- `download <examples/readme.py>`_ -(also `python3 style <examples/readme3.py>`_) +(also `python2 style <examples/readme2.py>`_) .. code:: python from twisted.internet.task import react - from twisted.internet.defer import inlineCallbacks + from twisted.internet.defer import inlineCallbacks, ensureDeferred from twisted.internet.endpoints import UNIXClientEndpoint + import treq import txtorcon - @react - @inlineCallbacks - def main(reactor): - tor = yield txtorcon.connect( + + async def main(reactor): + tor = await txtorcon.connect( reactor, UNIXClientEndpoint(reactor, "/var/run/tor/control") ) print("Connected to Tor version {}".format(tor.version)) - url = 'https://www.torproject.org:443' - print("Downloading {}".format(url)) - resp = yield treq.get(url, agent=tor.web_agent()) - - print(" {} bytes".format(resp.length)) - data = yield resp.text() - print("Got {} bytes:\n{}\n[...]{}".format( + url = u'https://www.torproject.org:443' + print(u"Downloading {}".format(repr(url))) + resp = await treq.get(url, agent=tor.web_agent()) + + print(u" {} bytes".format(resp.length)) + data = await resp.text() + print(u"Got {} bytes:\n{}\n[...]{}".format( len(data), data[:120], data[-120:], )) - print("Creating a circuit") - state = yield tor.create_state() - circ = yield state.build_circuit() - yield circ.when_built() - print(" path: {}".format(" -> ".join([r.ip for r in circ.path]))) - - print("Downloading meejah's public key via above circuit...") - resp = yield treq.get( - 'https://meejah.ca/meejah.asc', - agent=circ.web_agent(reactor, tor.config.socks_endpoint(reactor)), + print(u"Creating a circuit") + state = await tor.create_state() + circ = await state.build_circuit() + await circ.when_built() + print(u" path: {}".format(" -> ".join([r.ip for r in circ.path]))) + + print(u"Downloading meejah's public key via above circuit...") + config = await tor.get_config() + resp = await treq.get( + u'https://meejah.ca/meejah.asc', + agent=circ.web_agent(reactor, config.socks_endpoint(reactor)), ) - data = yield resp.text() + data = await resp.text() print(data) + @react + def _main(reactor): + return ensureDeferred(main(reactor)) + + Try It Now On Debian/Ubuntu --------------------------- @@ -127,7 +133,7 @@ .. code-block:: shell-session - $ sudo apt-get install --install-suggests python-txtorcon + $ sudo apt-get install --install-suggests python3-txtorcon $ twistd -n web --port "onion:80" --path ~/public_html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/dev-requirements.txt new/txtorcon-20.0.0/dev-requirements.txt --- old/txtorcon-19.1.0/dev-requirements.txt 2019-03-27 05:29:35.000000000 +0100 +++ new/txtorcon-20.0.0/dev-requirements.txt 2020-03-31 04:52:10.000000000 +0200 @@ -1,5 +1,5 @@ tox -coverage +coverage<5.0 cuvner setuptools>=0.8.0 Sphinx diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/docs/index.rst new/txtorcon-20.0.0/docs/index.rst --- old/txtorcon-19.1.0/docs/index.rst 2018-12-11 17:15:06.000000000 +0100 +++ new/txtorcon-20.0.0/docs/index.rst 2020-03-31 04:10:02.000000000 +0200 @@ -48,7 +48,7 @@ | PyPy 5.0.0+ | ✓ | ✓ | +---------------+---------+---------+ -Supported and tested platforms: Python 2.7+, Python 3.5+, PyPy 5.0.0+ +Supported and tested platforms: Python 3.5+, PyPy 5.0.0+, Python 2.7+ (deprecated) using Twisted 15.5.0+, 16.3.0+, or 17.1.0+ (see `travis <https://travis-ci.org/meejah/txtorcon>`_). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/docs/release-checklist.rst new/txtorcon-20.0.0/docs/release-checklist.rst --- old/txtorcon-19.1.0/docs/release-checklist.rst 2019-09-10 08:50:29.000000000 +0200 +++ new/txtorcon-20.0.0/docs/release-checklist.rst 2020-04-01 04:55:53.000000000 +0200 @@ -23,7 +23,7 @@ * update heading, date * on both signing-machine and build-machine shells: - * export VERSION=19.1.0 + * export VERSION=20.0.0 * (if on signing machine) "make dist" and "make dist-sigs" * creates: @@ -103,9 +103,6 @@ * copy dist/* files + signatures to hidden-service machine * copy them to the HTML build directory! (docs/_build/html/) - * make dist-hs - * make check-sigs - * git pull and build docs there * FIXME: why aren't all the dist files copied as part of doc build (only .tar.gz) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/docs/releases.rst new/txtorcon-20.0.0/docs/releases.rst --- old/txtorcon-19.1.0/docs/releases.rst 2019-09-10 08:50:22.000000000 +0200 +++ new/txtorcon-20.0.0/docs/releases.rst 2020-04-01 04:53:52.000000000 +0200 @@ -15,10 +15,19 @@ See also :ref:`api_stability`. -unreleased ----------- +`git master <https://github.com/meejah/txtorcon>`_ *will likely become v20.1.0* -`git master <https://github.com/meejah/txtorcon>`_ *will likely become v19.2.0* + +v20.0.0 +------- + +April 1, 2020 + + * Use real GeoIP database or nothing (`#250 <https://github.com/meejah/txtorcon/issues/250>`_) + * Change abstract base classes import in preperation for Python 3.8 (thanks `@glowatsk <https://github.com/glowatsk>`_ + * Python 3.4 is no longer supported + * Python 2 is deprecated; all new code should be Python 3. Support + for Python 2 will be removed in a future release. v19.1.0 @@ -634,4 +643,3 @@ march, 2012 * `txtorcon-0.1.tar.gz <txtorcon-0.1.tar.gz>`_ (`txtorcon-0.1.tar.gz.sig <txtorcon-0.1.tar.gz.sig>`_) - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/config.py new/txtorcon-20.0.0/examples/config.py --- old/txtorcon-19.1.0/examples/config.py 2017-10-03 07:45:45.000000000 +0200 +++ new/txtorcon-20.0.0/examples/config.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,38 +0,0 @@ -from __future__ import print_function - -import sys -import txtorcon -from twisted.web.client import readBody -from twisted.internet.task import react -from twisted.internet.defer import inlineCallbacks -from twisted.internet.endpoints import clientFromString - - -@react -@inlineCallbacks -def main(reactor): - control_ep = clientFromString(reactor, "tcp:localhost:9251") - tor = yield txtorcon.connect(reactor, control_ep) - print("Connected to Tor version '{}'".format(tor.protocol.version)) - - config = yield tor.get_config() - - print("SocksPort={}".format(config.SocksPort[0])) - - print("Directory authorities:") - for a in config.DirAuthority: - print(" {}".format(a[1:-1].split()[0])) - return - - stuff = yield tor.protocol.get_info('config/defaults') - stuff = stuff['config/defaults'] - for line in stuff.strip().split('\n'): - k, v = line.split(' ', 1) - if k not in ['FallbackDir']: - v = yield tor.protocol.get_conf(k) - print('{} = {}'.format(k, v)) - continue - try: - print('{} = {}'.format(k, getattr(config, k))) - except KeyError: - print('error on {}'.format(k)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/monitor_compose.py new/txtorcon-20.0.0/examples/monitor_compose.py --- old/txtorcon-19.1.0/examples/monitor_compose.py 2019-04-23 06:53:35.000000000 +0200 +++ new/txtorcon-20.0.0/examples/monitor_compose.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,30 +0,0 @@ -#!/usr/bin/env python - -# Just listens for a few EVENTs from Tor (INFO NOTICE WARN ERR) and -# prints out the contents, so functions like a log monitor. - -from __future__ import print_function - -from twisted.internet import task, defer -from twisted.internet.endpoints import UNIXClientEndpoint -import txtorcon - - -@task.react -@defer.inlineCallbacks -def main(reactor): - ep = UNIXClientEndpoint(reactor, '/var/run/tor/control') - tor = yield txtorcon.connect(reactor, ep) - - def log(msg): - print(msg) - print("Connected to a Tor version", tor.protocol.version) - - state = yield tor.create_state() - - print(dir(state)) - @state.on_stream_new - def _(circ): - print("new stream: {}".format(circ)) - - yield defer.Deferred() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/readme.py new/txtorcon-20.0.0/examples/readme.py --- old/txtorcon-19.1.0/examples/readme.py 2017-05-16 20:55:59.000000000 +0200 +++ new/txtorcon-20.0.0/examples/readme.py 2020-03-31 04:35:21.000000000 +0200 @@ -1,45 +1,47 @@ -from __future__ import print_function - from twisted.internet.task import react -from twisted.internet.defer import inlineCallbacks +from twisted.internet.defer import inlineCallbacks, ensureDeferred from twisted.internet.endpoints import UNIXClientEndpoint + import treq import txtorcon -@react -@inlineCallbacks -def main(reactor): - tor = yield txtorcon.connect( +async def main(reactor): + tor = await txtorcon.connect( reactor, UNIXClientEndpoint(reactor, "/var/run/tor/control") ) print("Connected to Tor version {}".format(tor.version)) - url = 'https://www.torproject.org:443' - print("Downloading {}".format(url)) - resp = yield treq.get(url, agent=tor.web_agent()) - - print(" {} bytes".format(resp.length)) - data = yield resp.text() - print("Got {} bytes:\n{}\n[...]{}".format( + url = u'https://www.torproject.org:443' + print(u"Downloading {}".format(repr(url))) + resp = await treq.get(url, agent=tor.web_agent()) + + print(u" {} bytes".format(resp.length)) + data = await resp.text() + print(u"Got {} bytes:\n{}\n[...]{}".format( len(data), data[:120], data[-120:], )) - print("Creating a circuit") - state = yield tor.create_state() - circ = yield state.build_circuit() - yield circ.when_built() - print(" path: {}".format(" -> ".join([r.ip for r in circ.path]))) - - print("Downloading meejah's public key via above circuit...") - config = yield tor.get_config() - resp = yield treq.get( - 'https://meejah.ca/meejah.asc', + print(u"Creating a circuit") + state = await tor.create_state() + circ = await state.build_circuit() + await circ.when_built() + print(u" path: {}".format(" -> ".join([r.ip for r in circ.path]))) + + print(u"Downloading meejah's public key via above circuit...") + config = await tor.get_config() + resp = await treq.get( + u'https://meejah.ca/meejah.asc', agent=circ.web_agent(reactor, config.socks_endpoint(reactor)), ) - data = yield resp.text() + data = await resp.text() print(data) + + +@react +def _main(reactor): + return ensureDeferred(main(reactor)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/readme2.py new/txtorcon-20.0.0/examples/readme2.py --- old/txtorcon-19.1.0/examples/readme2.py 1970-01-01 01:00:00.000000000 +0100 +++ new/txtorcon-20.0.0/examples/readme2.py 2020-03-31 04:30:54.000000000 +0200 @@ -0,0 +1,42 @@ +# this is a Python2 version of the code in readme.py +from twisted.internet.task import react +from twisted.internet.defer import inlineCallbacks +from twisted.internet.endpoints import UNIXClientEndpoint +import treq +import txtorcon + +@react +@inlineCallbacks +def main(reactor): + tor = yield txtorcon.connect( + reactor, + UNIXClientEndpoint(reactor, "/var/run/tor/control") + ) + + print("Connected to Tor version {}".format(tor.version)) + + url = 'https://www.torproject.org:443' + print("Downloading {}".format(url)) + resp = yield treq.get(url, agent=tor.web_agent()) + + print(" {} bytes".format(resp.length)) + data = yield resp.text() + print("Got {} bytes:\n{}\n[...]{}".format( + len(data), + data[:120], + data[-120:], + )) + + print("Creating a circuit") + state = yield tor.create_state() + circ = yield state.build_circuit() + yield circ.when_built() + print(" path: {}".format(" -> ".join([r.ip for r in circ.path]))) + + print("Downloading meejah's public key via above circuit...") + resp = yield treq.get( + 'https://meejah.ca/meejah.asc', + agent=circ.web_agent(reactor, tor.config.socks_endpoint(reactor)), + ) + data = yield resp.text() + print(data) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/readme3.py new/txtorcon-20.0.0/examples/readme3.py --- old/txtorcon-19.1.0/examples/readme3.py 2017-05-16 20:55:59.000000000 +0200 +++ new/txtorcon-20.0.0/examples/readme3.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,49 +0,0 @@ -# this is a Python3 version of the code in readme.py - -from twisted.internet.task import react -from twisted.internet.defer import inlineCallbacks, ensureDeferred -from twisted.internet.endpoints import UNIXClientEndpoint - -import treq -import txtorcon - - -async def main(reactor): - tor = await txtorcon.connect( - reactor, - UNIXClientEndpoint(reactor, "/var/run/tor/control") - ) - - print("Connected to Tor version {}".format(tor.version)) - - url = u'https://www.torproject.org:443' - print(u"Downloading {}".format(repr(url))) - resp = await treq.get(url, agent=tor.web_agent()) - - print(u" {} bytes".format(resp.length)) - data = await resp.text() - print(u"Got {} bytes:\n{}\n[...]{}".format( - len(data), - data[:120], - data[-120:], - )) - - print(u"Creating a circuit") - state = await tor.create_state() - circ = await state.build_circuit() - await circ.when_built() - print(u" path: {}".format(" -> ".join([r.ip for r in circ.path]))) - - print(u"Downloading meejah's public key via above circuit...") - config = await tor.get_config() - resp = await treq.get( - u'https://meejah.ca/meejah.asc', - agent=circ.web_agent(reactor, config.socks_endpoint(reactor)), - ) - data = await resp.text() - print(data) - - -@react -def _main(reactor): - return ensureDeferred(main(reactor)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/wait_newconsensus.py new/txtorcon-20.0.0/examples/wait_newconsensus.py --- old/txtorcon-19.1.0/examples/wait_newconsensus.py 2018-01-24 23:30:15.000000000 +0100 +++ new/txtorcon-20.0.0/examples/wait_newconsensus.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,29 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function - -from twisted.internet import task, defer -from twisted.internet.endpoints import UNIXClientEndpoint -import txtorcon - - -def await_single_event(tor_protocol, event_name): - d0 = defer.Deferred() - - def _got(consensus): - d1 = tor_protocol.remove_event_listener('NEWCONSENSUS', _got) - d1.addCallback(lambda _: d0.callback(consensus)) - return d1 - tor_protocol.add_event_listener('NEWCONSENSUS', _got) - return d0 - - -@task.react -@defer.inlineCallbacks -def main(reactor): - ep = UNIXClientEndpoint(reactor, '/var/run/tor/control') - tor = yield txtorcon.connect(reactor, ep) - - print("waiting for next NEWCONSENSUS") - consensus = yield await_single_event(tor.protocol, 'NEWCONSENSUS') - print("Got NEWCONSENSUS; {} bytes".format(len(consensus))) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/web_client_authenticated_py3.py new/txtorcon-20.0.0/examples/web_client_authenticated_py3.py --- old/txtorcon-19.1.0/examples/web_client_authenticated_py3.py 2017-12-11 07:20:13.000000000 +0100 +++ new/txtorcon-20.0.0/examples/web_client_authenticated_py3.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,51 +0,0 @@ -# this example shows how to use Twisted's web client with Tor via -# txtorcon - -from __future__ import print_function - -from twisted.internet.defer import inlineCallbacks, ensureDeferred -from twisted.internet.task import react -from twisted.internet.endpoints import TCP4ClientEndpoint -from twisted.web.client import readBody - -import txtorcon -from txtorcon.util import default_control_port - - -async def main(reactor): - # use port 9051 for system tor instances, or: - # ep = UNIXClientEndpoint(reactor, '/var/run/tor/control') - # ep = UNIXClientEndpoint(reactor, '/var/run/tor/control') - ep = TCP4ClientEndpoint(reactor, '127.0.0.1', default_control_port()) - tor = await txtorcon.connect(reactor, ep) - print("Connected to {tor} via localhost:{port}".format( - tor=tor, - port=default_control_port(), - )) - - # add our client-side authentication tokens for the service. - # You can create these by running the - # web_onion_service_ephemeral_auth.py in a separate shell and - # using either the "alice" or "bob" token in this client. - token = u"0GaFhnbunp0TxZuBhejhxg" # alice's token - onion_uri = u"FIXME.onion" - - if u"FIXME" in onion_uri: - print("Please edit to the correct .onion URI") - return - - async with tor.onion_authentication(onion_uri, token): - # do the Web request as with any other - agent = tor.web_agent() - uri = u'http://{}/'.format(onion_uri) - print("Downloading {}".format(uri)) - resp = await agent.request(b'GET', uri.encode('ascii')) - - print("Response has {} bytes".format(resp.length)) - body = await readBody(resp) - print(body) - -if __name__ == '__main__': - def _main(reactor): - return ensureDeferred(main(reactor)) - react(_main) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/web_onion_service_ephemeral.py new/txtorcon-20.0.0/examples/web_onion_service_ephemeral.py --- old/txtorcon-19.1.0/examples/web_onion_service_ephemeral.py 2018-02-15 07:58:40.000000000 +0100 +++ new/txtorcon-20.0.0/examples/web_onion_service_ephemeral.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,57 +0,0 @@ -#!/usr/bin/env python - -# This shows how to leverage the endpoints API to get a new hidden -# service up and running quickly. You can pass along this API to your -# users by accepting endpoint strings as per Twisted recommendations. -# -# http://twistedmatrix.com/documents/current/core/howto/endpoints.html#maximizing-the-return-on-your-endpoint-investment -# -# note that only the progress-updates needs the "import txtorcon" -- -# you do still need it installed so that Twisted finds the endpoint -# parser plugin but code without knowledge of txtorcon can still -# launch a Tor instance using it. cool! - -from __future__ import print_function -from twisted.internet import defer, task, endpoints -from twisted.web import server, resource - -import txtorcon -from txtorcon.util import default_control_port -from txtorcon.onion import AuthBasic - - -class Simple(resource.Resource): - """ - A really simple Web site. - """ - isLeaf = True - - def render_GET(self, request): - return b"<html>Hello, world! I'm an authenticated hidden service!</html>" - - -@defer.inlineCallbacks -def main(reactor): - tor = yield txtorcon.connect( - reactor, - endpoints.TCP4ClientEndpoint(reactor, "localhost", 9251), - ) - ep = tor.create_onion_endpoint( - 80, - version=3, - ) - - def on_progress(percent, tag, msg): - print('%03d: %s' % (percent, msg)) - txtorcon.IProgressProvider(ep).add_progress_listener(on_progress) - print("Note: descriptor upload can take several minutes") - - port = yield ep.listen(server.Site(Simple())) - print("Private key:\n{}".format(port.getHost().onion_key)) - hs = port.onion_service - print("hs {}".format(hs)) - print("{}".format(hs.hostname)) - yield defer.Deferred() # wait forever - - -task.react(main) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/web_onion_service_ephemeral_keyfile.py new/txtorcon-20.0.0/examples/web_onion_service_ephemeral_keyfile.py --- old/txtorcon-19.1.0/examples/web_onion_service_ephemeral_keyfile.py 2018-10-02 23:19:23.000000000 +0200 +++ new/txtorcon-20.0.0/examples/web_onion_service_ephemeral_keyfile.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,57 +0,0 @@ -#!/usr/bin/env python - -# This shows how to leverage the endpoints API to get a new hidden -# service up and running quickly. You can pass along this API to your -# users by accepting endpoint strings as per Twisted recommendations. -# -# http://twistedmatrix.com/documents/current/core/howto/endpoints.html#maximizing-the-return-on-your-endpoint-investment -# -# note that only the progress-updates needs the "import txtorcon" -- -# you do still need it installed so that Twisted finds the endpoint -# parser plugin but code without knowledge of txtorcon can still -# launch a Tor instance using it. cool! - -from __future__ import print_function -from twisted.internet import defer, task, endpoints -from twisted.web import server, resource - -import txtorcon -from txtorcon.util import default_control_port -from txtorcon.onion import AuthBasic - - -class Simple(resource.Resource): - """ - A really simple Web site. - """ - isLeaf = True - - def render_GET(self, request): - return b"<html>Hello, world! I'm a single-hop hidden service!</html>" - - -@defer.inlineCallbacks -def main(reactor): - tor = yield txtorcon.connect( - reactor, - endpoints.TCP4ClientEndpoint(reactor, "localhost", 9251), - ) - ep = endpoints.serverFromString( - reactor, - "onion:80:version=3:privateKeyFile=/home/mike/src/txtorcon/foodir/hs_ed25519_secret_key" - ) - - def on_progress(percent, tag, msg): - print('%03d: %s' % (percent, msg)) - txtorcon.IProgressProvider(ep).add_progress_listener(on_progress) - print("Note: descriptor upload can take several minutes") - - port = yield ep.listen(server.Site(Simple())) - print("Private key:\n{}".format(port.getHost().onion_key)) - hs = port.onion_service - print("hs {}".format(hs)) - print("{}".format(hs.hostname)) - yield defer.Deferred() # wait forever - - -task.react(main) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/web_onion_service_nonanonymous.py new/txtorcon-20.0.0/examples/web_onion_service_nonanonymous.py --- old/txtorcon-19.1.0/examples/web_onion_service_nonanonymous.py 2019-03-04 03:57:43.000000000 +0100 +++ new/txtorcon-20.0.0/examples/web_onion_service_nonanonymous.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,56 +0,0 @@ -#!/usr/bin/env python - -# This shows how to leverage the endpoints API to get a new hidden -# service up and running quickly. You can pass along this API to your -# users by accepting endpoint strings as per Twisted recommendations. -# -# http://twistedmatrix.com/documents/current/core/howto/endpoints.html#maximizing-the-return-on-your-endpoint-investment -# -# note that only the progress-updates needs the "import txtorcon" -- -# you do still need it installed so that Twisted finds the endpoint -# parser plugin but code without knowledge of txtorcon can still -# launch a Tor instance using it. cool! - -from __future__ import print_function -from twisted.internet import defer, task, endpoints -from twisted.web import server, resource - -import txtorcon -from txtorcon.util import default_control_port - - -class Simple(resource.Resource): - """ - A really simple Web site. - """ - isLeaf = True - - def render_GET(self, request): - print("serving request") - return b"<html>Hello, world! I'm a single-hop Onion Service!</html>" - - -@defer.inlineCallbacks -def main(reactor): - tor = yield txtorcon.launch( - reactor, - progress_updates=print, - non_anonymous_mode=True, - data_directory="./tor_data", - ) - print("{}".format(tor)) - hs = yield tor.create_filesystem_onion_service( - [(80, 8787)], - "./prop224_hs", - version=3, - ) - print("{}".format(hs)) - - ep = endpoints.TCP4ServerEndpoint(reactor, 8787, interface="localhost") - port = yield ep.listen(server.Site(Simple())) - print("Site listening: {}".format(hs.hostname)) - print("Private key:\n{}".format(hs.private_key)) - yield defer.Deferred() # wait forever - - -task.react(main) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/web_onion_service_prop224_endpoints.py new/txtorcon-20.0.0/examples/web_onion_service_prop224_endpoints.py --- old/txtorcon-19.1.0/examples/web_onion_service_prop224_endpoints.py 2017-12-13 06:51:57.000000000 +0100 +++ new/txtorcon-20.0.0/examples/web_onion_service_prop224_endpoints.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,52 +0,0 @@ -#!/usr/bin/env python - -# This shows how to leverage the endpoints API to get a new hidden -# service up and running quickly. You can pass along this API to your -# users by accepting endpoint strings as per Twisted recommendations. -# -# http://twistedmatrix.com/documents/current/core/howto/endpoints.html#maximizing-the-return-on-your-endpoint-investment -# -# note that only the progress-updates needs the "import txtorcon" -- -# you do still need it installed so that Twisted finds the endpoint -# parser plugin but code without knowledge of txtorcon can still -# launch a Tor instance using it. cool! - -from __future__ import print_function -from twisted.internet import defer, task, endpoints -from twisted.web import server, resource - -import txtorcon -from txtorcon.util import default_control_port - - -class Simple(resource.Resource): - """ - A really simple Web site. - """ - isLeaf = True - - def render_GET(self, request): - return b"<html>Hello, world! I'm a prop224 Onion Service!</html>" - - -@defer.inlineCallbacks -def main(reactor): - tor = yield txtorcon.connect( - reactor, - endpoints.TCP4ClientEndpoint(reactor, "localhost", 9251), - ) - print(default_control_port()) - ep = endpoints.serverFromString(reactor, "onion:80:controlPort={port}:version=3".format(port=default_control_port())) - - def on_progress(percent, tag, msg): - print('%03d: %s' % (percent, msg)) - txtorcon.IProgressProvider(ep).add_progress_listener(on_progress) - print("Note: descriptor upload can take several minutes") - - port = yield ep.listen(server.Site(Simple())) - print("Site listening: {}".format(port.getHost())) - print("Private key:\n{}".format(port.getHost().onion_key)) - yield defer.Deferred() # wait forever - - -task.react(main) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/examples/web_onion_service_prop224_endpoints_ephemeral.py new/txtorcon-20.0.0/examples/web_onion_service_prop224_endpoints_ephemeral.py --- old/txtorcon-19.1.0/examples/web_onion_service_prop224_endpoints_ephemeral.py 2018-06-19 04:34:31.000000000 +0200 +++ new/txtorcon-20.0.0/examples/web_onion_service_prop224_endpoints_ephemeral.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,52 +0,0 @@ -#!/usr/bin/env python - -# This shows how to leverage the endpoints API to get a new hidden -# service up and running quickly. You can pass along this API to your -# users by accepting endpoint strings as per Twisted recommendations. -# -# http://twistedmatrix.com/documents/current/core/howto/endpoints.html#maximizing-the-return-on-your-endpoint-investment -# -# note that only the progress-updates needs the "import txtorcon" -- -# you do still need it installed so that Twisted finds the endpoint -# parser plugin but code without knowledge of txtorcon can still -# launch a Tor instance using it. cool! - -from __future__ import print_function -from twisted.internet import defer, task, endpoints -from twisted.web import server, resource - -import txtorcon -from txtorcon.util import default_control_port - - -class Simple(resource.Resource): - """ - A really simple Web site. - """ - isLeaf = True - - def render_GET(self, request): - return b"<html>Hello, world! I'm an ephemeral prop224 Onion Service!</html>" - - -@defer.inlineCallbacks -def main(reactor): - tor = yield txtorcon.connect( - reactor, - endpoints.TCP4ClientEndpoint(reactor, "localhost", 9251), - ) - - ep = tor.create_onion_endpoint(80, version=3) - - def on_progress(percent, tag, msg): - print('%03d: %s' % (percent, msg)) - txtorcon.IProgressProvider(ep).add_progress_listener(on_progress) - print("Note: descriptor upload can take several minutes") - - port = yield ep.listen(server.Site(Simple())) - print("Site listening: {}".format(port.getHost())) - print("Private key:\n{}".format(port.getHost().onion_key)) - yield defer.Deferred() # wait forever - - -task.react(main) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/scripts/asciinema-demo0.py new/txtorcon-20.0.0/scripts/asciinema-demo0.py --- old/txtorcon-19.1.0/scripts/asciinema-demo0.py 2014-12-19 04:32:59.000000000 +0100 +++ new/txtorcon-20.0.0/scripts/asciinema-demo0.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,84 +0,0 @@ -#!/usr/bin/env python - -# this is a hack-tacular script to pass to asciinema like: -# asciinema -c ./asciinema-demo0.py rec -# to script the show. as it were. - -import os -import sys -import time -import random -import colors -import subprocess - -prompt = 'user@machine:~/src/txtorcon$ ' - -def interkey_interval(): - "in milliseconds" -# return 0 - return (random.lognormvariate(0.0, 0.5) * 30.0) / 1000.0 - return (float(random.randrange(10,50)) / 1000.0) - -def type_it_out(line): - for c in line: - sys.stdout.write(c) - sys.stdout.flush() - time.sleep(interkey_interval()) - -def do_commands(lines): - for line in lines: - sys.stdout.write(colors.blue(prompt)) - type_it_out(line) - time.sleep(0.5) - print - os.system(colors.strip_color(line)) - -commands = [] -commands.append(colors.bold('export TMPDIR=/dev/shm')) -commands.append(colors.red('# txtorcon + endpoints demo')) -commands.append(colors.red('# we already checked out the code here')) -commands.append(colors.red('# first, prepare a virtualenv')) -commands.append(colors.bold('virtualenv txtorcon_demo')) -commands.append('txtorcon_demo/bin/' + colors.bold(colors.white('pip install -r requirements.txt'))) - -commands.append(colors.red('# pick up txtorcon from our local Git checkout')) -commands.append('export PYTHONPATH=`pwd`') - -commands.append(colors.red('# prepare example web content')) -commands.append('mkdir -p example_website') -commands.append('echo "hello, hidden-service world" > example_website/index.html') -commands.append('rm -f twistd.log') -commands.append('txtorcon_demo/bin/' + colors.bold('twistd web ') + colors.white('--port onion:80') + colors.bold(' --path example_website/')) - -commands.append(colors.red('# wait until Tor launches etc')) -commands.append('tail twistd.log') -commands.append(colors.red('# wait for a particular log message to appear')) -commands.append('while ! grep "Started hidden service" twistd.log ; do sleep 1; done;') - -commands.append(colors.red('# save our new hidden service\'s keys')) -commands.append('tail twistd.log') -commands.append('mkdir hidserv_keys') -commands.append(r'cp `grep "Keys are in " twistd.log | cut -d \" -f 2`/* hidserv_keys') -commands.append('ls hidserv_keys') -commands.append('cat hidserv_keys/hostname') -commands.append(colors.red("# now we've got a copy of the private key")) -commands.append('tail twistd.log') - -commands.append(colors.red('# there we go, a new hidden-serivce.')) -commands.append(colors.red('# now, what if we kill it and want to re-launch with the same key/hostname?')) -commands.append('kill `cat twistd.pid`') -commands.append('rm twistd.log') -commands.append('txtorcon_demo/bin/' + colors.bold('twistd web ') + colors.white('--port onion:80' + colors.bold(':hiddenServiceDir=hidserv_keys')) + colors.bold(' --path example_website/')) -commands.append('# ^^^^^^^^^^^^^^^^') -commands.append('sleep 5') - -commands.append(colors.red('# remember, if anyone gets hold of private_key ' + colors.bold(colors.green(colors.underline('they can BECOME your hidden-service'))))) -commands.append(colors.red('# just as if you\'d completely lost control of your DNS entries on "normal" internet')) -commands.append('while ! grep "Started hidden service" twistd.log ; do sleep 1; done;') -commands.append('tail twistd.log') -commands.append(colors.bold('cat hidserv_keys/hostname')) -commands.append(colors.green('# thanks for watching!')) -commands.append(colors.bold(colors.white('# https://github.com/meejah/txtorcon'))) - -if __name__ == '__main__': - do_commands(commands) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/scripts/asciinema-demo1.py new/txtorcon-20.0.0/scripts/asciinema-demo1.py --- old/txtorcon-19.1.0/scripts/asciinema-demo1.py 2016-04-06 06:25:47.000000000 +0200 +++ new/txtorcon-20.0.0/scripts/asciinema-demo1.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,72 +0,0 @@ -#!/usr/bin/env python - -# this is a hack-tacular script to pass to asciinema like: -# asciinema -c ./asciinema-demo1.py rec -# to script the show. as it were. - -import os -import sys -import time -import random -import colors -import subprocess - -prompt = 'user@machine:~/src$ ' - -def interkey_interval(): - "in milliseconds" -# return 0 # faster debugging - return (random.lognormvariate(0.0, 0.5) * 30.0) / 1000.0 - return (float(random.randrange(10,50)) / 1000.0) - -def type_it_out(line): - for c in line: - sys.stdout.write(c) - sys.stdout.flush() - time.sleep(interkey_interval()) - -def do_commands(lines): - for line in lines: - if callable(line): - line() - continue - really_run = True - if line.startswith('!'): - really_run = False - line = line[1:] - sys.stdout.write(colors.blue(prompt)) - type_it_out(line) - time.sleep(0.5) - print - if really_run: - # XXX nice to have time-limit? - os.system(colors.strip_color(line)) - -def change_prompt(p): - global prompt - prompt = p - -commands = [] -commands.append(colors.bold('export TMPDIR=/dev/shm')) -commands.append(colors.red('# see http://txtorcon.readthedocs.org')) -commands.append('git clone https://github.com/meejah/txtorcon') -commands.append(colors.bold('virtualenv venv')) -commands.append('!' + colors.bold('source ./venv/bin/activate')) -commands.append(lambda: change_prompt('(venv)user@machine:~/src/txtorcon$ ')) -commands.append(lambda: sys.path.insert(0, './venv/bin')) -commands.append(colors.bold(colors.white('pip install --editable ./txtorcon'))) -commands.append('!' + colors.white('cd txtorcon')) -commands.append(lambda: os.chdir('./txtorcon')) -commands.append(lambda: change_prompt('user@machine:~/src/txtorcon$ ')) -commands.append('make coverage') -#commands.append('python examples/add_hiddenservice_to_system_tor.py') -commands.append(colors.red('# okay, lets try one of the examles')) -commands.append('ls examples/') -commands.append('python examples/dump_config.py | head') -commands.append('python examples/hello_darkweb.py') -commands.append(colors.red('# thanks for watching')) -commands.append(colors.red('# https://github.com/meejah/txtorcon')) -commands.append(colors.red('# https://txtorcon.readthedocs.org')) - -if __name__ == '__main__': - do_commands(commands) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/test/profile_startup.py new/txtorcon-20.0.0/test/profile_startup.py --- old/txtorcon-19.1.0/test/profile_startup.py 2017-04-11 07:53:18.000000000 +0200 +++ new/txtorcon-20.0.0/test/profile_startup.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,21 +0,0 @@ -#!/usr/bin/env python - -from time import time -import cProfile -import txtorcon - -proto = txtorcon.TorControlProtocol() -state = txtorcon.TorState(proto) - -data = open('consensus', 'r').read() -routers = 5494 # number of routers in above file -iters = 5 - -start = time() -if False: - cProfile.run('state._update_network_status(data)') -else: - for x in range(iters): - state._update_network_status(data) -diff = time() - start -print("%fs: %f microdescriptors/second" % (diff, (routers * iters) / diff)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/test/test_util.py new/txtorcon-20.0.0/test/test_util.py --- old/txtorcon-19.1.0/test/test_util.py 2019-03-04 03:38:01.000000000 +0100 +++ new/txtorcon-20.0.0/test/test_util.py 2020-01-04 09:10:36.000000000 +0100 @@ -1,9 +1,10 @@ import os import sys import tempfile +import ipaddress from mock import patch from unittest import skipIf -import ipaddress +from os.path import exists from twisted.trial import unittest from twisted.internet import defer @@ -63,10 +64,14 @@ @skipIf('pypy' in sys.version.lower(), "No GeoIP in PyPy") def test_return_geoip_object(self): + # requires a valid GeoIP database to work, so hopefully we're + # on Debian or similar... + fname = "/usr/share/GeoIP/GeoIP.dat" + if not exists(fname): + return + from txtorcon import util - (fd, f) = tempfile.mkstemp() - ret_val = util.create_geoip(f) - delete_file_or_tree(f) + ret_val = util.create_geoip(fname) self.assertEqual(type(ret_val).__name__, 'GeoIP') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/test/verify-release.py new/txtorcon-20.0.0/test/verify-release.py --- old/txtorcon-19.1.0/test/verify-release.py 2017-04-22 06:29:06.000000000 +0200 +++ new/txtorcon-20.0.0/test/verify-release.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,58 +0,0 @@ -# this does the "download and verify release from web + hidden-service -# machine" for txtorcon release-checklist. - -import sys -import hashlib -from os.path import join, split, exists - -import txtorcon - -from twisted.internet import defer, task -from twisted.web.client import readBody -from twisted.python.failure import Failure - - -@task.react -@defer.inlineCallbacks -def main(reactor): - if len(sys.argv) != 2: - print('usage: {} <version>'.format(__file__)) - raise SystemExit(1) - version = sys.argv[1] - announce = join(split(__file__)[0], '..', 'release-announce-{}'.format(version)) - if not exists(announce): - print('no announcement file: {}'.format(announce)) - raise SystemExit(2) - - sums = None - with open(announce, 'r') as f: - for line in f.readlines(): - if line.strip() == 'cat <<EOF | sha256sum --check': - sums = [] - elif line.strip() == 'EOF': - break - elif sums is not None: - checksum, fname = line.split() - sums.append((checksum, split(fname)[1])) - - tor = yield txtorcon.connect(reactor) - agent = tor.web_agent() - - for sha256, fname in sums: - print("Verifying '{}'".format(fname)) - uri = b'http://timaq4ygg2iegci7.onion/' + fname.encode('ascii') - try: - resp = yield agent.request(b'GET', uri) - except Exception: - print(Failure()) - raise - data = yield readBody(resp) - print('data: {} {}'.format(type(data), len(data))) - hasher = hashlib.new('sha256') - hasher.update(data) - alleged_sum = hasher.hexdigest() - if alleged_sum != sha256: - print("Checksum mismatch:") - print("wanted: {}".format(sha256)) - print(" got: {}".format(alleged_sum)) - raise SystemExit(45) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/txtorcon/_metadata.py new/txtorcon-20.0.0/txtorcon/_metadata.py --- old/txtorcon-19.1.0/txtorcon/_metadata.py 2019-09-10 08:50:22.000000000 +0200 +++ new/txtorcon-20.0.0/txtorcon/_metadata.py 2020-03-31 04:43:59.000000000 +0200 @@ -1,4 +1,4 @@ -__version__ = '19.1.0' +__version__ = '20.0.0' __author__ = 'meejah' __contact__ = 'mee...@meejah.ca' __url__ = 'https://github.com/meejah/txtorcon' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/txtorcon/controller.py new/txtorcon-20.0.0/txtorcon/controller.py --- old/txtorcon-19.1.0/txtorcon/controller.py 2019-03-11 01:37:39.000000000 +0100 +++ new/txtorcon-20.0.0/txtorcon/controller.py 2020-01-04 08:13:25.000000000 +0100 @@ -11,8 +11,11 @@ import tempfile import functools from io import StringIO -from collections import Sequence from os.path import dirname, exists +try: + from collections.abc import Sequence +except ImportError: + from collections import Sequence from twisted.python import log from twisted.python.failure import Failure diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/txtorcon/torconfig.py new/txtorcon-20.0.0/txtorcon/torconfig.py --- old/txtorcon-19.1.0/txtorcon/torconfig.py 2019-03-04 03:38:01.000000000 +0100 +++ new/txtorcon-20.0.0/txtorcon/torconfig.py 2020-01-04 08:13:25.000000000 +0100 @@ -10,8 +10,11 @@ import functools import warnings from io import StringIO -from collections import OrderedDict from warnings import warn +try: + from collections.abc import OrderedDict +except ImportError: + from collections import OrderedDict from twisted.python import log from twisted.python.compat import nativeString diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/txtorcon/torstate.py new/txtorcon-20.0.0/txtorcon/torstate.py --- old/txtorcon-19.1.0/txtorcon/torstate.py 2019-06-15 08:32:36.000000000 +0200 +++ new/txtorcon-20.0.0/txtorcon/torstate.py 2020-02-06 22:56:18.000000000 +0100 @@ -4,10 +4,13 @@ from __future__ import print_function from __future__ import with_statement -import collections import os import stat import warnings +try: + from collections.abc import Callable +except ImportError: + from collections import Callable from twisted.internet import defer from twisted.python.failure import Failure @@ -115,11 +118,11 @@ ) if build_state: d.addCallback(build_state - if isinstance(build_state, collections.Callable) + if isinstance(build_state, Callable) else _build_state) elif wait_for_proto: d.addCallback(wait_for_proto - if isinstance(wait_for_proto, collections.Callable) + if isinstance(wait_for_proto, Callable) else _wait_for_proto) return d diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/txtorcon.egg-info/PKG-INFO new/txtorcon-20.0.0/txtorcon.egg-info/PKG-INFO --- old/txtorcon-19.1.0/txtorcon.egg-info/PKG-INFO 2019-09-10 08:50:32.000000000 +0200 +++ new/txtorcon-20.0.0/txtorcon.egg-info/PKG-INFO 2020-04-01 04:56:34.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: txtorcon -Version: 19.1.0 +Version: 20.0.0 Summary: Twisted-based Tor controller client, with state-tracking and configuration abstractions. https://txtorcon.readthedocs.org https://github.com/meejah/txtorcon Home-page: https://github.com/meejah/txtorcon Author: meejah @@ -51,7 +51,7 @@ - **code**: https://github.com/meejah/txtorcon - ``torsocks git clone git://timaq4ygg2iegci7.onion/txtorcon.git`` - MIT-licensed; - - Python 2.7, PyPy 5.0.0+, Python 3.4+; + - Python 2.7, PyPy 5.0.0+, Python 3.5+; - depends on `Twisted`_, `Automat <https://github.com/glyph/automat>`_, @@ -79,53 +79,59 @@ --------------------------------------- `download <examples/readme.py>`_ - (also `python3 style <examples/readme3.py>`_) + (also `python2 style <examples/readme2.py>`_) .. code:: python from twisted.internet.task import react - from twisted.internet.defer import inlineCallbacks + from twisted.internet.defer import inlineCallbacks, ensureDeferred from twisted.internet.endpoints import UNIXClientEndpoint + import treq import txtorcon - @react - @inlineCallbacks - def main(reactor): - tor = yield txtorcon.connect( + + async def main(reactor): + tor = await txtorcon.connect( reactor, UNIXClientEndpoint(reactor, "/var/run/tor/control") ) print("Connected to Tor version {}".format(tor.version)) - url = 'https://www.torproject.org:443' - print("Downloading {}".format(url)) - resp = yield treq.get(url, agent=tor.web_agent()) - - print(" {} bytes".format(resp.length)) - data = yield resp.text() - print("Got {} bytes:\n{}\n[...]{}".format( + url = u'https://www.torproject.org:443' + print(u"Downloading {}".format(repr(url))) + resp = await treq.get(url, agent=tor.web_agent()) + + print(u" {} bytes".format(resp.length)) + data = await resp.text() + print(u"Got {} bytes:\n{}\n[...]{}".format( len(data), data[:120], data[-120:], )) - print("Creating a circuit") - state = yield tor.create_state() - circ = yield state.build_circuit() - yield circ.when_built() - print(" path: {}".format(" -> ".join([r.ip for r in circ.path]))) - - print("Downloading meejah's public key via above circuit...") - resp = yield treq.get( - 'https://meejah.ca/meejah.asc', - agent=circ.web_agent(reactor, tor.config.socks_endpoint(reactor)), + print(u"Creating a circuit") + state = await tor.create_state() + circ = await state.build_circuit() + await circ.when_built() + print(u" path: {}".format(" -> ".join([r.ip for r in circ.path]))) + + print(u"Downloading meejah's public key via above circuit...") + config = await tor.get_config() + resp = await treq.get( + u'https://meejah.ca/meejah.asc', + agent=circ.web_agent(reactor, config.socks_endpoint(reactor)), ) - data = yield resp.text() + data = await resp.text() print(data) + @react + def _main(reactor): + return ensureDeferred(main(reactor)) + + Try It Now On Debian/Ubuntu --------------------------- @@ -135,7 +141,7 @@ .. code-block:: shell-session - $ sudo apt-get install --install-suggests python-txtorcon + $ sudo apt-get install --install-suggests python3-txtorcon $ twistd -n web --port "onion:80" --path ~/public_html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/txtorcon.egg-info/SOURCES.txt new/txtorcon-20.0.0/txtorcon.egg-info/SOURCES.txt --- old/txtorcon-19.1.0/txtorcon.egg-info/SOURCES.txt 2019-09-10 08:50:32.000000000 +0200 +++ new/txtorcon-20.0.0/txtorcon.egg-info/SOURCES.txt 2020-04-01 04:56:34.000000000 +0200 @@ -46,7 +46,6 @@ docs/_themes/alabaster/static/alabaster.css_t docs/_themes/alabaster/static/pygments.css examples/close_all_circuits.py -examples/config.py examples/connect.py examples/disallow_streams_by_port.py examples/dns_lookups.py @@ -59,37 +58,26 @@ examples/launch_tor_with_simplehttpd.py examples/minimal_endpoint.py examples/monitor.py -examples/monitor_compose.py examples/readme.py -examples/readme3.py +examples/readme2.py examples/stem_relay_descriptor.py examples/stream_circuit_logger.py examples/tor_info.py examples/txtorcon.tac -examples/wait_newconsensus.py examples/web_client.py examples/web_client_authenticated.py -examples/web_client_authenticated_py3.py examples/web_client_custom_circuit.py examples/web_client_treq.py examples/web_onion_service_aiohttp.py examples/web_onion_service_endpoints.py -examples/web_onion_service_ephemeral.py examples/web_onion_service_ephemeral_auth.py -examples/web_onion_service_ephemeral_keyfile.py examples/web_onion_service_ephemeral_nonanon.py examples/web_onion_service_ephemeral_unix.py examples/web_onion_service_filesystem.py -examples/web_onion_service_nonanonymous.py examples/web_onion_service_prop224.py -examples/web_onion_service_prop224_endpoints.py -examples/web_onion_service_prop224_endpoints_ephemeral.py examples/web_onion_service_prop224_endpoints_file.py examples/webui_server.py -scripts/asciinema-demo0.py -scripts/asciinema-demo1.py test/__init__.py -test/profile_startup.py test/py3_test_controller.py test/py3_torstate.py test/test_addrmap.py @@ -112,7 +100,6 @@ test/test_util_imports.py test/test_web.py test/util.py -test/verify-release.py twisted/plugins/txtorcon_endpoint_parser.py txtorcon/__init__.py txtorcon/_metadata.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/txtorcon-19.1.0/txtorcon.egg-info/requires.txt new/txtorcon-20.0.0/txtorcon.egg-info/requires.txt --- old/txtorcon-19.1.0/txtorcon.egg-info/requires.txt 2019-09-10 08:50:32.000000000 +0200 +++ new/txtorcon-20.0.0/txtorcon.egg-info/requires.txt 2020-04-01 04:56:34.000000000 +0200 @@ -9,7 +9,7 @@ [dev] tox -coverage +coverage<5.0 cuvner setuptools>=0.8.0 Sphinx