toxic-proxy


Nametoxic-proxy JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/msoedov/toxic_proxy
SummaryAn asyncio tcp proxy for network resilience testing
upload_time2023-09-06 16:18:22
maintainerAlexander Miasoiedov
docs_urlNone
authorAlexander Miasoiedov
requires_python>=3.9,<4.0
licenseMIT
keywords resilience asyncio testing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Toxic Proxy

Toxic Proxy is an asyncio-based TCP proxy designed for network resilience testing. This allows you to simulate network conditions like latency, bandwidth limitations, and other issues to test how your application behaves under different scenarios. Whether you're working with microservices or just need to test your network reliability, Toxic Proxy provides a flexible way to introduce network anomalies for better resilience testing.

## Features

- Simulate network latency
- Limit bandwidth
- Easy to integrate with Python applications
- Uses asyncio for high performance

## Installation

Install Toxic Proxy using pip.

```shell
pip install --upgrade toxic_proxy
```

## Quick Start

### Using with Cassandra

Here's an example that shows how to use Toxic Proxy with a Cassandra cluster.

```python
import asyncio
from aiocassandra import aiosession
from cassandra.cluster import Cluster
from toxic_proxy import toxic_proxy

# Create a proxy with latency
proxy = toxic_proxy(
    destination=('<cassandra-ip>', 9042),
    latency=5,
    port=9043
)

# Connect to Cassandra through the proxy
cluster = Cluster(['0.0.0.0:9043'])
session = cluster.connect()
# ... your code here ...


```

### Simplified Example

This example demonstrates a simple use case to limit bandwidth when connecting to google.com.

```python
import asyncio
from toxic_proxy import toxic_proxy

# Create a proxy with bandwidth limit
proxy = toxic_proxy(
    destination=('google.com', 80),
    bandwidth_rate_kb=0.5,
    port=8888
)

loop = asyncio.get_event_loop()
server = loop.run_until_complete(proxy)
print(f'Serving on {server.sockets[0].getsockname()}')

try:
    loop.run_forever()
except KeyboardInterrupt:
    pass

# Close the server
server.close()
loop.run_until_complete(server.wait_closed())
loop.close()

```

### Testing

To test, you can use curl to make a request through the proxy.

```shell
curl -v 0.0.0.0:8888

```

## Contributing

We welcome contributions! If you find a bug or have a feature request, please open an issue. If you want to contribute code, feel free to open a pull request.

## License

This project is licensed under the MIT License. See the LICENSE file for details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/msoedov/toxic_proxy",
    "name": "toxic-proxy",
    "maintainer": "Alexander Miasoiedov",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "msoedov@gmail.com",
    "keywords": "resilience,asyncio,testing",
    "author": "Alexander Miasoiedov",
    "author_email": "msoedov@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6f/f0/4c69fd0122871ca946550bfa50b6e49af010d93ee46c39247fe2540c8747/toxic_proxy-0.1.0.tar.gz",
    "platform": null,
    "description": "# Toxic Proxy\n\nToxic Proxy is an asyncio-based TCP proxy designed for network resilience testing. This allows you to simulate network conditions like latency, bandwidth limitations, and other issues to test how your application behaves under different scenarios. Whether you're working with microservices or just need to test your network reliability, Toxic Proxy provides a flexible way to introduce network anomalies for better resilience testing.\n\n## Features\n\n- Simulate network latency\n- Limit bandwidth\n- Easy to integrate with Python applications\n- Uses asyncio for high performance\n\n## Installation\n\nInstall Toxic Proxy using pip.\n\n```shell\npip install --upgrade toxic_proxy\n```\n\n## Quick Start\n\n### Using with Cassandra\n\nHere's an example that shows how to use Toxic Proxy with a Cassandra cluster.\n\n```python\nimport asyncio\nfrom aiocassandra import aiosession\nfrom cassandra.cluster import Cluster\nfrom toxic_proxy import toxic_proxy\n\n# Create a proxy with latency\nproxy = toxic_proxy(\n    destination=('<cassandra-ip>', 9042),\n    latency=5,\n    port=9043\n)\n\n# Connect to Cassandra through the proxy\ncluster = Cluster(['0.0.0.0:9043'])\nsession = cluster.connect()\n# ... your code here ...\n\n\n```\n\n### Simplified Example\n\nThis example demonstrates a simple use case to limit bandwidth when connecting to google.com.\n\n```python\nimport asyncio\nfrom toxic_proxy import toxic_proxy\n\n# Create a proxy with bandwidth limit\nproxy = toxic_proxy(\n    destination=('google.com', 80),\n    bandwidth_rate_kb=0.5,\n    port=8888\n)\n\nloop = asyncio.get_event_loop()\nserver = loop.run_until_complete(proxy)\nprint(f'Serving on {server.sockets[0].getsockname()}')\n\ntry:\n    loop.run_forever()\nexcept KeyboardInterrupt:\n    pass\n\n# Close the server\nserver.close()\nloop.run_until_complete(server.wait_closed())\nloop.close()\n\n```\n\n### Testing\n\nTo test, you can use curl to make a request through the proxy.\n\n```shell\ncurl -v 0.0.0.0:8888\n\n```\n\n## Contributing\n\nWe welcome contributions! If you find a bug or have a feature request, please open an issue. If you want to contribute code, feel free to open a pull request.\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An asyncio tcp proxy for network resilience testing",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/msoedov/toxic_proxy",
        "Repository": "https://github.com/msoedov/toxic_proxy"
    },
    "split_keywords": [
        "resilience",
        "asyncio",
        "testing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6ff04c69fd0122871ca946550bfa50b6e49af010d93ee46c39247fe2540c8747",
                "md5": "e12a1c48683ce37cd5ca2205f60b670c",
                "sha256": "2fb07bc3fa734c87441f0c4883462129395a08a576ec75cfc08d8bb0a8287e31"
            },
            "downloads": -1,
            "filename": "toxic_proxy-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e12a1c48683ce37cd5ca2205f60b670c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 2859,
            "upload_time": "2023-09-06T16:18:22",
            "upload_time_iso_8601": "2023-09-06T16:18:22.177838Z",
            "url": "https://files.pythonhosted.org/packages/6f/f0/4c69fd0122871ca946550bfa50b6e49af010d93ee46c39247fe2540c8747/toxic_proxy-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-06 16:18:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "msoedov",
    "github_project": "toxic_proxy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "toxic-proxy"
}
        
Elapsed time: 0.11570s