Skip to content

Commit

Permalink
Merge pull request #95 from ziloka/update-readme
Browse files Browse the repository at this point in the history
instructions to compile proxybroker to shared executable for Major platforms (Windows, Linux, and MacOS)
  • Loading branch information
bluet authored Aug 30, 2022
2 parents a7fbc82 + 5bbd628 commit 5c27520
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"ms-python.python"
]
}
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line to run commands after the container is created - for example installing curl.
// "postCreateCommand": "apt-get update && apt-get install -y curl",
"postCreateCommand": "apt-get update && apt-get install -y binutils upx-ucl && pip install pyinstaller && pip install ."

// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ build
dist
/venv
Pipfile*
*.spec
77 changes: 76 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,83 @@ The latest development version can be installed directly from GitHub:
$ pip install -U git+https://github.com/bluet/proxybroker2.git
```

Usage
### Build bundled one-file executable with pyinstaller

#### Requirements

Unix based systems

Install these tools
- upx
- objdump (this tool is usually in the bintools package)

```
pip install pyinstaller \
&& pip install . \
&& mkdir -p build \
&& cd build \
&& pyinstaller --onefile --name proxybroker --add-data "../proxybroker/data:data" --workpath ./tmp --distpath . --clean ../py2exe_entrypoint.py \
&& rm -rf tmp
```

The executable is now in the build directory

Windows

```
pip install pyinstaller \
&& pip install . \
&& mkdir -p build \
&& cd build \
&& pyinstaller --onefile --name proxybroker --add-data "../proxybroker/data;data" --workpath ./tmp --distpath . --clean ../py2exe_entrypoint.py \
&& rm -rf tmp
```


### Use pre-built Docker image
``` {.sourceCode .bash}
$ docker run --rm bluet/proxybroker2 --help
usage: proxybroker [--max-conn MAX_CONN] [--max-tries MAX_TRIES]
[--timeout SECONDS] [--judge JUDGES] [--provider PROVIDERS]
[--verify-ssl]
[--log [{NOTSET,DEBUG,INFO,WARNING,ERROR,CRITICAL}]]
[--min-queue MINIMUM_PROXIES_IN_QUEUE]
[--version] [--help]
{find,grab,serve,update-geo} ...
Proxy [Finder | Checker | Server]
Commands:
These are common commands used in various situations
{find,grab,serve,update-geo}
find Find and check proxies
grab Find proxies without a check
serve Run a local proxy server
update-geo Download and use a detailed GeoIP database
Options:
--max-conn MAX_CONN The maximum number of concurrent checks of proxies
--max-tries MAX_TRIES
The maximum number of attempts to check a proxy
--timeout SECONDS, -t SECONDS
Timeout of a request in seconds. The default value is
8 seconds
--judge JUDGES Urls of pages that show HTTP headers and IP address
--provider PROVIDERS Urls of pages where to find proxies
--verify-ssl, -ssl Flag indicating whether to check the SSL certificates
--min-queue MINIMUM_PROXIES_IN_QUEUE The minimum number of proxies in the queue for checking connectivity
--log [{NOTSET,DEBUG,INFO,WARNING,ERROR,CRITICAL}]
Logging level
--version, -v Show program's version number and exit
--help, -h Show this help message and exit
Run 'proxybroker <command> --help' for more information on a command.
Suggestions and bug reports are greatly appreciated:
<https://github.com/bluet/proxybroker2/issues>
-----
```

### CLI Examples

Expand Down
3 changes: 3 additions & 0 deletions proxybroker/resolver.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@

import asyncio
import ipaddress
import os.path
import random
import socket
import sys
from collections import namedtuple
from importlib.util import find_spec

import aiodns
import aiohttp
Expand Down
3 changes: 2 additions & 1 deletion proxybroker/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Utils."""

import sys
import logging
import os
import os.path
Expand All @@ -13,7 +14,7 @@
from . import __version__ as version
from .errors import BadStatusLine

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
BASE_DIR = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
DATA_DIR = os.path.join(BASE_DIR, 'data')
log = logging.getLogger(__package__)

Expand Down
2 changes: 2 additions & 0 deletions py2exe_entrypoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import proxybroker.cli as proxybroker_cli
proxybroker_cli.cli()

0 comments on commit 5c27520

Please sign in to comment.