Name | paccreator JSON |
Version |
0.2.2
JSON |
| download |
home_page | None |
Summary | This package makes it possible to create simple proxy auto-config (PAC) files declaratively. |
upload_time | 2024-09-17 09:12:01 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT License Copyright (c) 2023 Heiko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
proxy auto-config
auto-config
pac
wpad
proxy
findproxyforurl
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Generate auto proxy config files (PAC) from a declaration
[![Tests](https://github.com/73h/paccreator/actions/workflows/tests.yml/badge.svg)](https://github.com/73h/paccreator/actions/workflows/tests.yml)
---
This package aims to make it possible to create simple proxy scripts declaratively. It will never cover all the
subtleties. If you have unusual requirements, it is better to write the proxy script directly in JavaScript
## Usage
You can install the package with pip.
```
pip install paccreator
```
You can also load the script directly from github with pip.
```
pip install git+https://github.com/73h/paccreator.git@main#egg=paccreator
```
Create a file called myproxy.yaml and define your proxy rules in it like this.
```yaml
description: A description of proxy script # (optional, default=pac file for my company)
version: The version of proxy script # (optional, default=0.1)
proxies:
- route: DIRECT
description: A description of proxy # (optional, default=use this proxy)
tags: # (optional) Here you can add any comments you like, which you can use to filter later. However, there are also standard annotations.
- default # (optional) This marks the proxy as default if no other condition applies. if no default proxy is available, the first one is used.
- catch-plain-hostnames # (optional) This proxy applies if there is no domain name in the hostname (no dots). You should not annotate this on several proxies.
targets:
- example.com
- foo.example.com
- .example.net
# You can also use a network mask, ip-addresses, hosts or strings
- route: PROXY proxy1.example.com:80; DIRECT
targets:
- 10.0.0.0/8
```
Run this in python.
```python
import os
from paccreator import PacCreator
p = PacCreator()
with open(os.path.join("myproxy.yaml"), "r") as f:
p.load_from_yaml(f.read())
print(p.output())
```
You can also use with contextmanager.
```python
import os
from paccreator import load_from_yaml
with open(os.path.join("myproxy.yaml"), "r") as f:
with load_from_yaml(f.read()) as p:
print(p.output())
```
## Examples
### A simple Example for a random company
yaml file
```yaml
description: Simple proxy
proxies:
- description: use direct connection
route: DIRECT
targets:
- 10.0.0.0/8
- .my-company.com
- description: use my proxy
route: PROXY proxy.my-company.com:80
tags:
- default
targets:
- www.my-company.com
- contact.my-company.com
- description: use the special proxy
route: PROXY proxy.my-company.com:8080
targets:
- datacenter.my-company.com
```
As a result, you can see that it has resolved the overlap between ``.my-company.com`` and,
for example, ``contact.my-company.com`` by first evaluating the exact subdomains.
The network mask ``10.0.0.0/8`` was placed at the end to avoid DNS queries when they are not necessary.
```javascript
function FindProxyForURL(url, host) {
/*
Description: Simple proxy
Version: 0.1
*/
host = host.toLowerCase();
if (
localHostOrDomainIs(host, "www.my-company.com")
|| localHostOrDomainIs(host, "contact.my-company.com")
) {
/* use my proxy */
return "PROXY proxy.my-company.com:80";
}
if (
localHostOrDomainIs(host, "datacenter.my-company.com")
) {
/* use the special proxy */
return "PROXY proxy.my-company.com:8080";
}
if (
dnsDomainIs(host, ".my-company.com")
) {
/* use direct connection */
return "DIRECT";
}
if (
isInNet(host, "10.0.0.0", "255.0.0.0")
) {
/* use direct connection */
return "DIRECT";
}
/* Default: use my proxy */
return "PROXY proxy.my-company.com:80";
}
```
### Unit Tests Example
You can see all the options supported so far in the test examples.
- [unittests.yaml](src/examples/unittests.yaml)
- [unittests.pac](src/examples/unittests.pac)
Raw data
{
"_id": null,
"home_page": null,
"name": "paccreator",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Heiko Schmidt <73h@gmx.net>",
"keywords": "proxy auto-config, auto-config, pac, wpad, proxy, findproxyforurl",
"author": null,
"author_email": "Heiko Schmidt <73h@gmx.net>",
"download_url": "https://files.pythonhosted.org/packages/bc/52/cb2223eff562c31da361a4a7ce7072dba32cd6133f61fd0e0b1f0cc51f10/paccreator-0.2.2.tar.gz",
"platform": null,
"description": "# Generate auto proxy config files (PAC) from a declaration\n\n[![Tests](https://github.com/73h/paccreator/actions/workflows/tests.yml/badge.svg)](https://github.com/73h/paccreator/actions/workflows/tests.yml)\n\n---\n\nThis package aims to make it possible to create simple proxy scripts declaratively. It will never cover all the\nsubtleties. If you have unusual requirements, it is better to write the proxy script directly in JavaScript\n\n\n## Usage\n\nYou can install the package with pip.\n```\npip install paccreator\n```\n\nYou can also load the script directly from github with pip.\n```\npip install git+https://github.com/73h/paccreator.git@main#egg=paccreator\n```\n\nCreate a file called myproxy.yaml and define your proxy rules in it like this.\n```yaml\ndescription: A description of proxy script # (optional, default=pac file for my company)\nversion: The version of proxy script # (optional, default=0.1)\nproxies:\n - route: DIRECT\n description: A description of proxy # (optional, default=use this proxy)\n tags: # (optional) Here you can add any comments you like, which you can use to filter later. However, there are also standard annotations.\n - default # (optional) This marks the proxy as default if no other condition applies. if no default proxy is available, the first one is used.\n - catch-plain-hostnames # (optional) This proxy applies if there is no domain name in the hostname (no dots). You should not annotate this on several proxies.\n targets:\n - example.com\n - foo.example.com\n - .example.net\n # You can also use a network mask, ip-addresses, hosts or strings\n - route: PROXY proxy1.example.com:80; DIRECT\n targets:\n - 10.0.0.0/8\n```\n\nRun this in python. \n```python\nimport os\nfrom paccreator import PacCreator\n\np = PacCreator()\nwith open(os.path.join(\"myproxy.yaml\"), \"r\") as f:\n p.load_from_yaml(f.read())\n print(p.output())\n```\n\nYou can also use with contextmanager.\n```python\nimport os\nfrom paccreator import load_from_yaml\n\nwith open(os.path.join(\"myproxy.yaml\"), \"r\") as f:\n with load_from_yaml(f.read()) as p:\n print(p.output())\n```\n\n## Examples\n\n### A simple Example for a random company\n\nyaml file \n```yaml\ndescription: Simple proxy\nproxies:\n - description: use direct connection\n route: DIRECT\n targets:\n - 10.0.0.0/8\n - .my-company.com\n - description: use my proxy\n route: PROXY proxy.my-company.com:80\n tags:\n - default\n targets:\n - www.my-company.com\n - contact.my-company.com\n - description: use the special proxy\n route: PROXY proxy.my-company.com:8080\n targets:\n - datacenter.my-company.com\n```\n\nAs a result, you can see that it has resolved the overlap between ``.my-company.com`` and,\nfor example, ``contact.my-company.com`` by first evaluating the exact subdomains.\nThe network mask ``10.0.0.0/8`` was placed at the end to avoid DNS queries when they are not necessary. \n```javascript\nfunction FindProxyForURL(url, host) {\n /*\n Description: Simple proxy\n Version: 0.1\n */\n host = host.toLowerCase();\n if (\n localHostOrDomainIs(host, \"www.my-company.com\")\n || localHostOrDomainIs(host, \"contact.my-company.com\")\n ) {\n /* use my proxy */\n return \"PROXY proxy.my-company.com:80\";\n }\n if (\n localHostOrDomainIs(host, \"datacenter.my-company.com\")\n ) {\n /* use the special proxy */\n return \"PROXY proxy.my-company.com:8080\";\n }\n if (\n dnsDomainIs(host, \".my-company.com\")\n ) {\n /* use direct connection */\n return \"DIRECT\";\n }\n if (\n isInNet(host, \"10.0.0.0\", \"255.0.0.0\")\n ) {\n /* use direct connection */\n return \"DIRECT\";\n }\n /* Default: use my proxy */\n return \"PROXY proxy.my-company.com:80\";\n}\n```\n\n### Unit Tests Example\n\nYou can see all the options supported so far in the test examples.\n\n- [unittests.yaml](src/examples/unittests.yaml)\n- [unittests.pac](src/examples/unittests.pac)\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023 Heiko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "This package makes it possible to create simple proxy auto-config (PAC) files declaratively.",
"version": "0.2.2",
"project_urls": {
"Homepage": "https://github.com/73h/paccreator"
},
"split_keywords": [
"proxy auto-config",
" auto-config",
" pac",
" wpad",
" proxy",
" findproxyforurl"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d3eebca1561fea0daf6c4623cddf16bdd19b8c5c06ab3acc477cdd36f7dd41ad",
"md5": "18ead4b6c9989ecb91fbf051b09b86a9",
"sha256": "c0120cd7bf4868bdc7f543bbcb948cf3096aa54b02bdfbcf5a6542fa32ac6c24"
},
"downloads": -1,
"filename": "paccreator-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "18ead4b6c9989ecb91fbf051b09b86a9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 8020,
"upload_time": "2024-09-17T09:12:00",
"upload_time_iso_8601": "2024-09-17T09:12:00.004691Z",
"url": "https://files.pythonhosted.org/packages/d3/ee/bca1561fea0daf6c4623cddf16bdd19b8c5c06ab3acc477cdd36f7dd41ad/paccreator-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bc52cb2223eff562c31da361a4a7ce7072dba32cd6133f61fd0e0b1f0cc51f10",
"md5": "6c7a125b789a6846260622c4a76c0336",
"sha256": "f97927b879936f8353c2ee573a9dca7eab7ad739cd11f095ecfb74b12e9ba625"
},
"downloads": -1,
"filename": "paccreator-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "6c7a125b789a6846260622c4a76c0336",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 8527,
"upload_time": "2024-09-17T09:12:01",
"upload_time_iso_8601": "2024-09-17T09:12:01.464826Z",
"url": "https://files.pythonhosted.org/packages/bc/52/cb2223eff562c31da361a4a7ce7072dba32cd6133f61fd0e0b1f0cc51f10/paccreator-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-17 09:12:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "73h",
"github_project": "paccreator",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "paccreator"
}