- Proxy Management Application
Proxy Management System for interactions with proxies based on LTE modems using 3proxy. This application provides efficient way to manage and interact with LTE Huawei modems, allowing for seamless proxy management.
- FastAPI for building APIs
- SQLAlchemy for database interactions
- Alembic for database migrations
- Authentication with JWT and Google OAuth2
- WebSocket to handle IP address changes with long modem response times
- Command-line interface (Click) for both client and server
- Lightweight web interface (Jinja2, HTML, CSS, and jQuery). API ready for any JS framework
-
Clone the repository:
$ git clone https://github.com/sergey-vernyk/ProxyManagement.git $ cd ProxyManagement -
Install dependencies using Poetry:
$ poetry install
-
Create and configure the environment file:
$ cp .env.example src/proxy_management/.env
-
Apply database migrations:
$ poetry run alembic upgrade head
POST /auth/login: User basic login (email, password)GET /auth/login/google: Initiate Google authorization (redirects to the Google authorization page after the user clicks on the button)GET /auth/callback: Handles Google authorization after a user authorizes in Google with their Google credentialsPOST /auth/revoke/google: Revoke Google authenticationPOST /auth/registration: User registrationPOST /auth/reset_password: Initiate password resetPOST /auth/reset_password_confirm: Confirm password resetPOST /auth/send_verification_email/: Send an email with OTP for verification after registrationPOST /auth/compare_codes/: Compare OTP from the user and OTP saved in the databasePOST /auth/verify_captcha: Backend Cloudflare reCaptcha verificationPOST /auth/logout: User logout
GET /modems/: List all modemsPOST /modems/: Create a new modemGET /modems/{ip}: Get details of a specific modem by IPPUT /modems/{ip}: Update a specific modem by IPDELETE /modems/{ip}: Delete a specific proxyGET /modems/change_ip_urls/{email}: Get URL for a modem (for rebooting it) for a user with specific email
POST /users/: Create a userGET /users/: Get all usersGET /users/{email}: Get details of a specific user by emailPUT /users/{email}: Update a specific user by emailDELETE /users/{email}: Delete a specific user by email
$ proxy-conf-users [OPTIONS] ENV_FILE COMMAND [ARGS]Arguments:
env_file: Location or URL of the environment configuration file
Commands:
create-user-list: Create a user list file with proxy credentialsdelete-from-user-list: Delete user credentials from the user list fileget-from-user-list: Display user credentials from the user list fileinsert-into-user-list: Insert new credentials into the user list file
Options:
-u, --username TEXT: Username for authenticating if the provided 'env_file' is URL-pass, --password TEXT: Password for authenticating if the provided 'env_file' is URL
$ socket-server [OPTIONS] ENV_FILE COMMAND [ARGS]Commands:
connection-number: Show the current numbers of accepted connection to the socket serverlogs: Show logs for the socket serverrun: Run the socket server with provided host and portstop: Stop the running socket server
Options:
-u, --username TEXT: Username for authenticating if the provided 'env_file' is URL--pass, --password TEXT: Password for authenticating if the provided 'env_file' is URL
$ proxy-conf-protocols [OPTIONS] COMMAND [ARGS]Commands:
create-connection-protocol: Create one line for protocol in the proxy conf file (e.g. proxy -n -a -p49153 -i192.168.1.105 -e192.168.8.100)
Options:
--env-file TEXT: Location or URL of the environment configuration file-u, --username TEXT: Username for authenticating if the provided 'env_file' is URL-pass, --password TEXT: Password for authenticating if the provided
$ web-server [OPTIONS] COMMAND [ARGS]Commands:
runserver: Run the FastAPI server with the provided options
-
Run the application:
$ cd src/proxy_management $ uvicorn main:app --reload -
Access the application at
http://127.0.0.1:8000.
.
├── alembic.ini
├── Dockerfile
├── LICENSE
├── poetry.lock
├── pyproject.toml
├── README.md
├── ruff.toml
├── src
│ └── proxy_management
│ ├── auth
│ │ ├── auth_bearer.py
│ │ ├── crud.py
│ │ ├── __init__.py
│ │ ├── otp
│ │ │ ├── crud.py
│ │ │ ├── __init__.py
│ │ │ ├── models.py
│ │ │ ├── schemas.py
│ │ │ └── utils.py
│ │ ├── router_api.py
│ │ ├── router_templates.py
│ │ ├── schemas.py
│ │ ├── tasks.py
│ │ └── utils.py
│ ├── cli
│ │ ├── __init__.py
│ │ ├── proxy_protocol_types.py
│ │ ├── proxy_userlist.py
│ │ ├── schemas.py
│ │ ├── socket_server.py
│ │ ├── utils.py
│ │ └── web_server.py
│ ├── common
│ │ ├── decorators.py
│ │ ├── __init__.py
│ │ ├── sending_email.py
│ │ └── utils.py
│ ├── config.py
│ ├── conn_utils.py
│ ├── db_connection.py
│ ├── dependencies.py
│ ├── exceptions.py
│ ├── __init__.py
│ ├── logs
│ │ ├── __init__.py
│ │ └── logging_conf.py
│ ├── main.py
│ ├── migrations
│ │ ├── env.py
│ │ ├── README
│ │ └── script.py.mako
│ ├── modem_api.py
│ ├── modems
│ │ ├── crud.py
│ │ ├── __init__.py
│ │ ├── models.py
│ │ ├── router.py
│ │ ├── router_templates.py
│ │ ├── router_ws.py
│ │ └── schemas.py
│ ├── security.py
│ ├── sockets
│ │ ├── async_client.py
│ │ ├── async_server.py
│ │ └── __init__.py
│ ├── static
│ │ ├── css
│ │ │ ├── authentication.css
│ │ │ ├── base.css
│ │ │ ├── change_ip.css
│ │ │ ├── index.css
│ │ │ ├── proxies.css
│ │ │ ├── registration.css
│ │ │ ├── reset_password_confirm.css
│ │ │ ├── reset_password.css
│ │ │ └── verify_otp.css
│ │ ├── img
│ │ │ └── favicon.png
│ │ └── js
│ │ ├── authentication.js
│ │ ├── change_ip.js
│ │ ├── check_opened_modal_windows.js
│ │ ├── delete_account.js
│ │ ├── disconnect_google_account.js
│ │ ├── get_cookies.js
│ │ ├── logout.js
│ │ ├── registration.js
│ │ ├── reset_password_confirm.js
│ │ ├── reset_password.js
│ │ ├── verify_cf_captcha.js
│ │ └── verify_otp.js
│ ├── templates
│ │ ├── authentication.html
│ │ ├── base.html
│ │ ├── change_ip.html
│ │ ├── email_verification.html
│ │ ├── index.html
│ │ ├── proxies.html
│ │ ├── registration.html
│ │ ├── reset_password_confirm.html
│ │ ├── reset_password_email.html
│ │ ├── reset_password.html
│ │ ├── verify_email_deferred.html
│ │ └── verify_otp.html
│ ├── users
│ │ ├── crud.py
│ │ ├── __init__.py
│ │ ├── models.py
│ │ ├── router.py
│ │ ├── schemas.py
│ │ └── utils.py
│ ├── validators.py
│ └── wait-for.sh
└── tests
├── conftest.py
├── __init__.py
├── mocks.py
└── test_auth.py- Build the Docker image:
$ docker build -t proxy-management .- Create docker network:
$ docker network create proxy-management-networkit will create the bridge type of docker network that we need to use for the FastAPI server connections with the PostgreSQL server.
- Run PostgreSQL server:
$ docker run \
--name proxy-management-db \
-e POSTGRES_PASSWORD=mysecretpassword \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-v /tmp/postgres_data:/var/lib/postgresql/data \
-e POSTGRES_USER=proxy_admin \
-e POSTGRES_DB=proxies \
--network=proxy-management-network postgres:16.3-alpineNote: is required to assign to DATABASE_URL environment variable the value: postgresql://proxy_admin:mysecretpassword@proxy-management-db:5432/proxies where proxy-management-db is the value defined while running PostgreSQL server above. With 127.0.0.1 it won't work as expected. The FastAPI server won't be able to connect to PostgreSQL server. You can choose any credentials for the PostgreSQL server as you want.
/tmp/postgres_data in -v /tmp/postgres_data:/var/lib/postgresql/data can be mount to other places you want.
- Run the Docker container:
$ docker run \
-w /app/src/proxy_management \
-p 8000:8000 \
--name proxy-management-fastapi \
--network=proxy-management-network \
--env-file src/proxy_management/.env proxy-management uvicorn main:app --host 0.0.0.0You can chose .env file from other location where actual .env file is located.
- And after this you will see:
INFO: Started server process [1]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)Open a browser on http://127.0.0.1:8000 and you will see the home page.
We welcome contributions of all kinds — bug fixes, new features, documentation improvements, or suggestions!
To contribute:
- Fork this repository to your own GitHub account.
- Clone your fork locally and create a new branch:
$ git clone https://github.com/sergey-vernyk/ProxyManagement.git
$ git checkout -b my-feature-branch- Make your changes and follow the existing coding style.
- Test your changes if applicable.
- Commit your changes with a clear message:
$ git commit -m "Add brief description of changes"- Push your branch to your fork:
$ git push origin my-feature-branch- Open a Pull Request from your branch to the main repository, explaining what you changed and why.
We appreciate all contributions and will review pull requests as quickly as possible. Be respectful and constructive when interacting with others in this project.
This project is licensed under the MIT License. See the LICENSE file for details.