Python implementation of Guacamole WebSocket proxy server
Project description
Guapy
Guapy is a modern, async Python implementation of the Apache Guacamole WebSocket proxy server. It enables secure, clientless remote desktop access via web browsers, bridging web clients and remote desktop servers using the Guacamole protocol.
Features
- Multi-Protocol: RDP, VNC, SSH, Telnet
- WebSocket Communication: Real-time, bidirectional
- Token-Based Security: AES-encrypted connection tokens
- Async & Scalable: Built with FastAPI and asyncio
- RESTful API: Health, stats, and management endpoints
- Flexible Usage: Use as a library, standalone server, or integrate with your FastAPI app
Installation
pip install guapy
Usage
1. Standalone Server See examples/standalone_server.py:
import asyncio
import logging
import uvicorn
from guapy import create_server
from guapy.models import ClientOptions, CryptConfig, GuacdOptions
logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s %(levelname)s %(name)s %(message)s"
)
logger = logging.getLogger(__name__)
async def main():
"""Main function to start the Guapy server."""
client_options = ClientOptions(
crypt=CryptConfig(
cypher="AES-256-CBC",
key="MySuperSecretKeyForParamsToken12",
),
cors_allow_origins=[
"http://localhost:3000", # React dev server
],
cors_allow_credentials=True,
cors_allow_methods=["GET", "POST", "OPTIONS"],
cors_allow_headers=["Content-Type", "Authorization"],
)
guacd_options = GuacdOptions(host="10.21.34.133", port=4822)
# guacd_options = GuacdOptions(host="127.0.0.1", port=4822)
server = create_server(client_options, guacd_options)
logger.info("Starting Guapy server...")
logger.info("WebSocket endpoint: ws://localhost:8080/")
logger.info("Health check: http://localhost:8080/health")
logger.info("Stats: http://localhost:8080/stats")
logger.info("Press Ctrl+C to stop")
config = uvicorn.Config(app=server.app, host="0.0.0.0", port=8080) # noqa: S104
server_instance = uvicorn.Server(config)
await server_instance.serve()
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
logger.info("Server stopped by user")
except Exception as e:
logger.error(f"Server error: {e}")
raise
2. CLI Server
Run with flexible config using Typer CLI:
python -m guapy.cli run --host 0.0.0.0 --port 8080 --guacd-host 127.0.0.1 --guacd-port 4822 --secret-key MySuperSecretKeyForParamsToken12
See python -m guapy.cli --help for all options.
3. Integrate with Your FastAPI App See examples/integrated_fastapi_app.py:
from fastapi import FastAPI
from guapy import create_server
from guapy.models import ClientOptions, CryptConfig, GuacdOptions
app = FastAPI()
@app.get("/root")
async def root():
return {"message": "Hello, World!"}
client_options = ClientOptions(
crypt=CryptConfig(
cypher="AES-256-CBC",
key="MySuperSecretKeyForParamsToken12",
),
max_inactivity_time=10000,
)
guacd_options = GuacdOptions(host="127.0.0.1", port=4822)
guapy_server = create_server(client_options, guacd_options)
app.mount("/guapy", guapy_server.app)
Configuration
- Use CLI options, environment variables, or a config file (
config.jsonor.env). - See
src/guapy/config.pyfor details.
API Endpoints
- WebSocket:
ws://localhost:8080/webSocket?token=... - REST:
/,/health,/stats(or/guapy/...if mounted) - Swagger docs:
/docs(main app),/guapy/docs(mounted Guapy)
Security
- Use strong encryption keys and HTTPS/WSS in production
- Restrict guacd access with firewalls
- Monitor logs for suspicious activity
Development & Examples
- See the
examples/directory for usage patterns - Run tests:
uv run pytest - Lint:
uv run ruff check . - Format:
uv run ruff format . - Security audit:
uv run pip-audit - Full verification:
uv run python scripts/verify_package.py
CI/CD
This project uses GitHub Actions for:
- Continuous Integration: Automated testing across Python 3.9-3.13 on Linux, Windows, and macOS
- Security Scanning: Dependency vulnerability checks with pip-audit
- Automated Publishing: Secure releases to TestPyPI and PyPI using Trusted Publishing
- Pre-release Support: Alpha/beta/rc versions automatically go to TestPyPI only
See PUBLISHING_SETUP.md for complete setup instructions.
License
MIT. See LICENSE.
Acknowledgments
- Apache Guacamole project
- FastAPI
- Python asyncio community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file guapy-1.0.0.tar.gz.
File metadata
- Download URL: guapy-1.0.0.tar.gz
- Upload date:
- Size: 160.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e1aad73662f301a99a3b628b149f41d00491f489f3faf227cf77c413214608f
|
|
| MD5 |
79aa0a8b9302b786da690a5e691372fd
|
|
| BLAKE2b-256 |
ec1547a29ae3650181d1d7cf42249d196c036059137efc9637a980e7063822d2
|
Provenance
The following attestation bundles were made for guapy-1.0.0.tar.gz:
Publisher:
release.yml on Adithya1331/guapy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
guapy-1.0.0.tar.gz -
Subject digest:
7e1aad73662f301a99a3b628b149f41d00491f489f3faf227cf77c413214608f - Sigstore transparency entry: 445144261
- Sigstore integration time:
-
Permalink:
Adithya1331/guapy@0d5a1d096a110c5568ae32e58117fefa1f7fb7dc -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Adithya1331
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0d5a1d096a110c5568ae32e58117fefa1f7fb7dc -
Trigger Event:
push
-
Statement type:
File details
Details for the file guapy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: guapy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 26.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c09d3ddf83d6628fdedf6466b2e17d862a1bc107e8516e6b5eba01f97feac71
|
|
| MD5 |
b0b6f2621ce98c2d672f8cb0a8b68375
|
|
| BLAKE2b-256 |
bfe5a67eb9ccf9b8a1745a317c8c43ee4247363810c91f6a242877050a33f5fb
|
Provenance
The following attestation bundles were made for guapy-1.0.0-py3-none-any.whl:
Publisher:
release.yml on Adithya1331/guapy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
guapy-1.0.0-py3-none-any.whl -
Subject digest:
5c09d3ddf83d6628fdedf6466b2e17d862a1bc107e8516e6b5eba01f97feac71 - Sigstore transparency entry: 445144269
- Sigstore integration time:
-
Permalink:
Adithya1331/guapy@0d5a1d096a110c5568ae32e58117fefa1f7fb7dc -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Adithya1331
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0d5a1d096a110c5568ae32e58117fefa1f7fb7dc -
Trigger Event:
push
-
Statement type: