# Python Usage
## Usage
```py
from hazetunnel import HazeTunnel
from browserforge.headers import HeaderGenerator
...
# Initialize the proxy
proxy = HazeTunnel(port='8080', payload='alert("Hello World!");')
proxy.launch()
# Send the request
requests.get(
url='https://example.com',
headers=HeaderGenerator().generate(browser='chrome'),
proxies={'https': proxy.url},
verify=proxy.cert
).text
# Stop the proxy
proxy.stop()
```
<details>
<summary>
HazeTunnel parameters
</summary>
```
Parameters:
port (Optional[str]): Specify a port to listen on. Default is random.
payload (Optional[str]): Payload to inject into responses
user_agent (Optional[str]): Optionally override all User-Agent headers
upstream_proxy (Optional[str]): Optionally forward requests to an upstream proxy
```
</details>
### Using a context manager
A context manager will automatically close the server when not needed anymore.
```py
with HazeTunnel(port='8080', payload='alert("Hello World!");') as proxy:
# Send the request
requests.get(
url='https://example.com',
headers=HeaderGenerator().generate(browser='chrome'),
proxies={'https': proxy.url},
verify=proxy.cert
).text
```
<hr width=70>
## CLI
Download the latest version of the API:
```sh
python -m hazetunnel fetch
```
Remove all files before uninstalling
```sh
python -m hazetunnel remove
```
Run the MITM proxy:
```sh
python -m hazetunnel run -p 8080 --verbose
```
### All commands
```sh
Usage: python -m hazetunnel [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
fetch Fetch the latest version of hazetunnel-api
remove Remove all library files
run Run the MITM proxy
version Display the current version
```
### See [here](https://github.com/daijro/hazetunnel) for more information and examples.
---
Raw data
{
"_id": null,
"home_page": "https://github.com/daijro/hazetunnel",
"name": "hazetunnel",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "tls, golang, networking, proxy, mitm, injector, playwright",
"author": "daijro",
"author_email": "daijro.dev@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8e/b0/e44693d24a6975f630f95178f1defcc97a9620c747b6c167dd47037e4681/hazetunnel-2.0.1.tar.gz",
"platform": null,
"description": "# Python Usage\n\n## Usage\n\n```py\nfrom hazetunnel import HazeTunnel\nfrom browserforge.headers import HeaderGenerator\n...\n# Initialize the proxy\nproxy = HazeTunnel(port='8080', payload='alert(\"Hello World!\");')\nproxy.launch()\n# Send the request\nrequests.get(\n url='https://example.com',\n headers=HeaderGenerator().generate(browser='chrome'),\n proxies={'https': proxy.url},\n verify=proxy.cert\n).text\n# Stop the proxy\nproxy.stop()\n```\n\n<details>\n\n <summary>\n HazeTunnel parameters\n </summary>\n\n```\nParameters:\n port (Optional[str]): Specify a port to listen on. Default is random.\n payload (Optional[str]): Payload to inject into responses\n user_agent (Optional[str]): Optionally override all User-Agent headers\n upstream_proxy (Optional[str]): Optionally forward requests to an upstream proxy\n```\n\n</details>\n\n### Using a context manager\n\nA context manager will automatically close the server when not needed anymore.\n\n```py\nwith HazeTunnel(port='8080', payload='alert(\"Hello World!\");') as proxy:\n # Send the request\n requests.get(\n url='https://example.com',\n headers=HeaderGenerator().generate(browser='chrome'),\n proxies={'https': proxy.url},\n verify=proxy.cert\n ).text\n```\n\n<hr width=70>\n\n## CLI\n\nDownload the latest version of the API:\n\n```sh\npython -m hazetunnel fetch\n```\n\nRemove all files before uninstalling\n\n```sh\npython -m hazetunnel remove\n```\n\nRun the MITM proxy:\n\n```sh\npython -m hazetunnel run -p 8080 --verbose\n```\n\n### All commands\n\n```sh\nUsage: python -m hazetunnel [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n --help Show this message and exit.\n\nCommands:\n fetch Fetch the latest version of hazetunnel-api\n remove Remove all library files\n run Run the MITM proxy\n version Display the current version\n```\n\n### See [here](https://github.com/daijro/hazetunnel) for more information and examples.\n\n---\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Mitm proxy that defends against TLS and JS worker fingerprinting.",
"version": "2.0.1",
"project_urls": {
"Homepage": "https://github.com/daijro/hazetunnel",
"Repository": "https://github.com/daijro/hazetunnel"
},
"split_keywords": [
"tls",
" golang",
" networking",
" proxy",
" mitm",
" injector",
" playwright"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9413826a3f3e6ec8d5cfdc62c91af784dd7085a93d645e74a2e9b19d45ddf128",
"md5": "86712abf995a7d01ec922cc508945a7d",
"sha256": "116ac94fec014b5f63c4950e41c9f0fa1221b34d8e3ebd2bb4c856d4353991e5"
},
"downloads": -1,
"filename": "hazetunnel-2.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "86712abf995a7d01ec922cc508945a7d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 9436,
"upload_time": "2024-06-09T07:07:09",
"upload_time_iso_8601": "2024-06-09T07:07:09.790799Z",
"url": "https://files.pythonhosted.org/packages/94/13/826a3f3e6ec8d5cfdc62c91af784dd7085a93d645e74a2e9b19d45ddf128/hazetunnel-2.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8eb0e44693d24a6975f630f95178f1defcc97a9620c747b6c167dd47037e4681",
"md5": "6a4bcebc1634286f8b4da02cd4882e64",
"sha256": "4015733dd4337d0e53aa092c7935f01118de290b66f38b4d45947800a8496fae"
},
"downloads": -1,
"filename": "hazetunnel-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "6a4bcebc1634286f8b4da02cd4882e64",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 7488,
"upload_time": "2024-06-09T07:07:11",
"upload_time_iso_8601": "2024-06-09T07:07:11.332309Z",
"url": "https://files.pythonhosted.org/packages/8e/b0/e44693d24a6975f630f95178f1defcc97a9620c747b6c167dd47037e4681/hazetunnel-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-09 07:07:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "daijro",
"github_project": "hazetunnel",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "hazetunnel"
}