txtorcon


Nametxtorcon JSON
Version 23.11.0 PyPI version JSON
download
home_pagehttps://github.com/meejah/txtorcon
SummaryTwisted-based Tor controller client, with state-tracking and configuration abstractions. https://txtorcon.readthedocs.org https://github.com/meejah/txtorcon
upload_time2023-11-20 09:18:21
maintainer
docs_urlNone
authormeejah
requires_python>=3.8
licenseMIT
keywords python twisted tor tor controller
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            




.. _NOTE: see docs/index.rst for the starting-point
.. _ALSO: https://txtorcon.readthedocs.org for rendered docs






.. image:: https://github.com/meejah/txtorcon/actions/workflows/python3.yaml/badge.svg
    :target: https://github.com/meejah/txtorcon/actions
    :alt: github-actions

.. image:: https://coveralls.io/repos/meejah/txtorcon/badge.png?branch=main
    :target: https://coveralls.io/github/meejah/txtorcon?branch=main
    :alt: coveralls

.. image:: https://codecov.io/github/meejah/txtorcon/coverage.svg?branch=main
    :target: https://codecov.io/github/meejah/txtorcon?branch=main
    :alt: codecov

.. image:: https://readthedocs.org/projects/txtorcon/badge/?version=stable
    :target: https://txtorcon.readthedocs.io/en/stable
    :alt: ReadTheDocs

.. image:: https://readthedocs.org/projects/txtorcon/badge/?version=latest
    :target: https://txtorcon.readthedocs.io/en/latest
    :alt: ReadTheDocs


txtorcon
========

- **docs**: https://txtorcon.readthedocs.org or http://fjblvrw2jrxnhtg67qpbzi45r7ofojaoo3orzykesly2j3c2m3htapid.onion/
- **code**: https://github.com/meejah/txtorcon
- ``torsocks git clone git://fjblvrw2jrxnhtg67qpbzi45r7ofojaoo3orzykesly2j3c2m3htapid.onion/txtorcon.git``
- MIT-licensed;
- Python 3.8+, PyPy 7.3.7+;
- depends on
  `Twisted`_,
  `Automat <https://github.com/glyph/automat>`_


Ten Thousand Feet
-----------------

txtorcon is an implementation of the `control-spec
<https://gitweb.torproject.org/torspec.git/blob/HEAD:/control-spec.txt>`_
for `Tor <https://www.torproject.org/>`_ using the `Twisted`_
networking library for `Python <http://python.org/>`_.

This is useful for writing utilities to control or make use of Tor in
event-based Python programs. If your Twisted program supports
endpoints (like ``twistd`` does) your server or client can make use of
Tor immediately, with no code changes. Start your own Tor or connect
to one and get live stream, circuit, relay updates; read and change
config; monitor events; build circuits; create onion services;
etcetera (`ReadTheDocs <https://txtorcon.readthedocs.org>`_).


Some Possibly Motivational Example Code
---------------------------------------

`download <examples/readme.py>`_

.. code:: python

    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))



Try It Now On Debian/Ubuntu
---------------------------

For example, serve some files via an onion service (*aka* hidden
service):

.. code-block:: shell-session

    $ sudo apt-get install --install-suggests python3-txtorcon
    $ twistd -n web --port "onion:80" --path ~/public_html


Read More
---------

All the documentation starts `in docs/index.rst
<docs/index.rst>`_. Also hosted at `txtorcon.rtfd.org
<https://txtorcon.readthedocs.io/en/latest/>`_.

You'll want to start with `the introductions <docs/introduction.rst>`_ (`hosted at RTD
<https://txtorcon.readthedocs.org/en/latest/introduction.html>`_).

.. _Twisted: https://twistedmatrix.com/trac

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/meejah/txtorcon",
    "name": "txtorcon",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "python,twisted,tor,tor controller",
    "author": "meejah",
    "author_email": "meejah@meejah.ca",
    "download_url": "https://files.pythonhosted.org/packages/39/eb/dd87610a296ac02aba6a67668e5811e43078ea32d261e0c8eb2d43d6e67c/txtorcon-23.11.0.tar.gz",
    "platform": null,
    "description": "\n\n\n\n\n.. _NOTE: see docs/index.rst for the starting-point\n.. _ALSO: https://txtorcon.readthedocs.org for rendered docs\n\n\n\n\n\n\n.. image:: https://github.com/meejah/txtorcon/actions/workflows/python3.yaml/badge.svg\n    :target: https://github.com/meejah/txtorcon/actions\n    :alt: github-actions\n\n.. image:: https://coveralls.io/repos/meejah/txtorcon/badge.png?branch=main\n    :target: https://coveralls.io/github/meejah/txtorcon?branch=main\n    :alt: coveralls\n\n.. image:: https://codecov.io/github/meejah/txtorcon/coverage.svg?branch=main\n    :target: https://codecov.io/github/meejah/txtorcon?branch=main\n    :alt: codecov\n\n.. image:: https://readthedocs.org/projects/txtorcon/badge/?version=stable\n    :target: https://txtorcon.readthedocs.io/en/stable\n    :alt: ReadTheDocs\n\n.. image:: https://readthedocs.org/projects/txtorcon/badge/?version=latest\n    :target: https://txtorcon.readthedocs.io/en/latest\n    :alt: ReadTheDocs\n\n\ntxtorcon\n========\n\n- **docs**: https://txtorcon.readthedocs.org or http://fjblvrw2jrxnhtg67qpbzi45r7ofojaoo3orzykesly2j3c2m3htapid.onion/\n- **code**: https://github.com/meejah/txtorcon\n- ``torsocks git clone git://fjblvrw2jrxnhtg67qpbzi45r7ofojaoo3orzykesly2j3c2m3htapid.onion/txtorcon.git``\n- MIT-licensed;\n- Python 3.8+, PyPy 7.3.7+;\n- depends on\n  `Twisted`_,\n  `Automat <https://github.com/glyph/automat>`_\n\n\nTen Thousand Feet\n-----------------\n\ntxtorcon is an implementation of the `control-spec\n<https://gitweb.torproject.org/torspec.git/blob/HEAD:/control-spec.txt>`_\nfor `Tor <https://www.torproject.org/>`_ using the `Twisted`_\nnetworking library for `Python <http://python.org/>`_.\n\nThis is useful for writing utilities to control or make use of Tor in\nevent-based Python programs. If your Twisted program supports\nendpoints (like ``twistd`` does) your server or client can make use of\nTor immediately, with no code changes. Start your own Tor or connect\nto one and get live stream, circuit, relay updates; read and change\nconfig; monitor events; build circuits; create onion services;\netcetera (`ReadTheDocs <https://txtorcon.readthedocs.org>`_).\n\n\nSome Possibly Motivational Example Code\n---------------------------------------\n\n`download <examples/readme.py>`_\n\n.. code:: python\n\n    from twisted.internet.task import react\n    from twisted.internet.defer import inlineCallbacks, ensureDeferred\n    from twisted.internet.endpoints import UNIXClientEndpoint\n\n    import treq\n    import txtorcon\n\n\n    async def main(reactor):\n        tor = await txtorcon.connect(\n            reactor,\n            UNIXClientEndpoint(reactor, \"/var/run/tor/control\")\n        )\n\n        print(\"Connected to Tor version {}\".format(tor.version))\n\n        url = u'https://www.torproject.org:443'\n        print(u\"Downloading {}\".format(repr(url)))\n        resp = await treq.get(url, agent=tor.web_agent())\n\n        print(u\"   {} bytes\".format(resp.length))\n        data = await resp.text()\n        print(u\"Got {} bytes:\\n{}\\n[...]{}\".format(\n            len(data),\n            data[:120],\n            data[-120:],\n        ))\n\n        print(u\"Creating a circuit\")\n        state = await tor.create_state()\n        circ = await state.build_circuit()\n        await circ.when_built()\n        print(u\"  path: {}\".format(\" -> \".join([r.ip for r in circ.path])))\n\n        print(u\"Downloading meejah's public key via above circuit...\")\n        config = await tor.get_config()\n        resp = await treq.get(\n            u'https://meejah.ca/meejah.asc',\n            agent=circ.web_agent(reactor, config.socks_endpoint(reactor)),\n        )\n        data = await resp.text()\n        print(data)\n\n\n    @react\n    def _main(reactor):\n        return ensureDeferred(main(reactor))\n\n\n\nTry It Now On Debian/Ubuntu\n---------------------------\n\nFor example, serve some files via an onion service (*aka* hidden\nservice):\n\n.. code-block:: shell-session\n\n    $ sudo apt-get install --install-suggests python3-txtorcon\n    $ twistd -n web --port \"onion:80\" --path ~/public_html\n\n\nRead More\n---------\n\nAll the documentation starts `in docs/index.rst\n<docs/index.rst>`_. Also hosted at `txtorcon.rtfd.org\n<https://txtorcon.readthedocs.io/en/latest/>`_.\n\nYou'll want to start with `the introductions <docs/introduction.rst>`_ (`hosted at RTD\n<https://txtorcon.readthedocs.org/en/latest/introduction.html>`_).\n\n.. _Twisted: https://twistedmatrix.com/trac\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Twisted-based Tor controller client, with state-tracking and     configuration abstractions.     https://txtorcon.readthedocs.org     https://github.com/meejah/txtorcon",
    "version": "23.11.0",
    "project_urls": {
        "Homepage": "https://github.com/meejah/txtorcon"
    },
    "split_keywords": [
        "python",
        "twisted",
        "tor",
        "tor controller"
    ],
    "urls": [
        {
            "comment_text": "txtorcon v23.11.0 wheel",
            "digests": {
                "blake2b_256": "bcef812bfd4172b7a50d920f11c592185fe85b35a0b41f462f008db525bb87db",
                "md5": "b15be86a3790fda757cea3202fda4b72",
                "sha256": "59ec801a38d6ea3cedc544cfcdb8e6f180b55d51bf9a01224b09f4bf48262f6b"
            },
            "downloads": -1,
            "filename": "txtorcon-23.11.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b15be86a3790fda757cea3202fda4b72",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 262789,
            "upload_time": "2023-11-20T09:18:24",
            "upload_time_iso_8601": "2023-11-20T09:18:24.665449Z",
            "url": "https://files.pythonhosted.org/packages/bc/ef/812bfd4172b7a50d920f11c592185fe85b35a0b41f462f008db525bb87db/txtorcon-23.11.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "txtorcon v23.11.0 tarball",
            "digests": {
                "blake2b_256": "39ebdd87610a296ac02aba6a67668e5811e43078ea32d261e0c8eb2d43d6e67c",
                "md5": "59c8bff94b195147ae6adbfd313f8dd4",
                "sha256": "71f85ae93d76d726510059c9ed74e608bc5a5c9f7d103853b49e414280406a2f"
            },
            "downloads": -1,
            "filename": "txtorcon-23.11.0.tar.gz",
            "has_sig": false,
            "md5_digest": "59c8bff94b195147ae6adbfd313f8dd4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 313549,
            "upload_time": "2023-11-20T09:18:21",
            "upload_time_iso_8601": "2023-11-20T09:18:21.507262Z",
            "url": "https://files.pythonhosted.org/packages/39/eb/dd87610a296ac02aba6a67668e5811e43078ea32d261e0c8eb2d43d6e67c/txtorcon-23.11.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-20 09:18:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "meejah",
    "github_project": "txtorcon",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "txtorcon"
}
        
Elapsed time: 0.19596s