Skip to main content

Provider-neutral proxy leases for Python applications.

Project description

cmdop-proxy

cmdop-proxy gives Python applications one provider-neutral contract for acquiring and using bounded proxy leases. It is a client library, not a proxy server and not a scraping framework.

The package intentionally separates two responsibilities:

  • a broker selects and leases an endpoint;
  • the application sends traffic directly through that endpoint with its native HTTP client.

Provider management APIs and account keys do not belong in this package.

Install

pip install cmdop-proxy

SOCKS support in HTTPX is optional:

pip install "cmdop-proxy[socks]"

Static/offline use

import asyncio
from datetime import timedelta

from cmdop_proxy import (
    AcquireRequest,
    IdentityMode,
    ProxyEndpoint,
    ProxyProtocol,
    StaticBroker,
    create_async_client,
)


async def main() -> None:
    broker = StaticBroker(
        pools={
            "parser": [
                ProxyEndpoint(
                    endpoint_id="local-1",
                    host="127.0.0.1",
                    port=8080,
                    protocol=ProxyProtocol.HTTP,
                    username="user",
                    password="secret",
                )
            ]
        }
    )
    lease = await broker.acquire(
        AcquireRequest(
            pool="parser",
            purpose="source-acquisition",
            target="example",
            protocols=(ProxyProtocol.HTTP,),
            identity_mode=IdentityMode.FIXED,
            affinity="account-primary",
            ttl=timedelta(minutes=15),
        ),
        idempotency_key="run-001",
    )

    async with create_async_client(lease, timeout=30) as client:
        response = await client.get("https://example.com/")
        response.raise_for_status()


asyncio.run(main())

StaticBroker is deterministic, process-local and network-free. It is useful for tests, local deployments and as the reference semantics for remote broker contract tests. It does not persist leases across process restarts.

Security properties

  • Credentials never appear in endpoint or lease repr output.
  • Proxy URLs percent-encode user information.
  • The library does not set HTTP_PROXY, HTTPS_PROXY or any other global environment variable.
  • Observations are typed categories and cannot carry response bodies, cookies, headers or arbitrary error messages.
  • A renewal preserves identity or fails; it never silently changes endpoint.

Applications should keep leases in memory and persist only the lease ID when a remote broker supports lease recovery.

Cloudflare control plane

CloudflareBroker implements the same async contract over the versioned proxy.sdkrouter.com API. The workload receives only its broker token; provider management keys stay in Worker secrets.

from cmdop_proxy import CloudflareBroker

async with CloudflareBroker(
    base_url="https://proxy.sdkrouter.com",
    token=workload_token,
) as broker:
    lease = await broker.acquire(request, idempotency_key="parser-run-001")

The broker token is excluded from repr, remote error messages are mapped to stable typed exceptions, and arbitrary response bodies are never copied into exceptions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmdop_proxy-0.1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmdop_proxy-0.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file cmdop_proxy-0.1.0.tar.gz.

File metadata

  • Download URL: cmdop_proxy-0.1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for cmdop_proxy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0cb819de36499159b2ebf32b41ca70728395bcdec2cdb7c882b7ae20619b97ca
MD5 7d662ddf0012edea888c46355b19fcb5
BLAKE2b-256 78fda6e9ee79695784c7172fd335b7787dcaf0bab7cbf285ed442f1e6dabfa6f

See more details on using hashes here.

File details

Details for the file cmdop_proxy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cmdop_proxy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for cmdop_proxy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0b8f65fa45411e1cab532db51f02198a270b49198888e10457dc9220173ec43
MD5 57dabc3d9814b20d4b79ddc55d83a7b4
BLAKE2b-256 d02ad0425542e40b9e197f948fdfb8a3f41f1c8cebd794bb63321a22a1b04c73

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page