Skip to main content

Tunneling tool

Project description

Pinggy

A Python SDK for Pinggy — create and manage HTTP, TCP, TLS, and UDP tunnels from your code.

Pinggy lets you expose a local server to the internet through a secure tunnel without changing your application. The Python SDK wraps the native libpinggy library and gives you a small, ergonomic API for everything Pinggy supports: multi-port forwarding, basic / bearer / IP-whitelist auth, header rewriting, web debugging, auto-reconnect, and more.

Features

  • Multiple protocols: HTTP, TCP, TLS, TLS-over-TCP, and UDP.
  • Multi-port forwarding: declare several public bindings on a single tunnel.
  • Authentication: Basic Auth, Bearer tokens, and IP whitelisting.
  • Header rewriting: add, remove, or update request headers on the fly.
  • Web debugger: inspect every request flowing through the tunnel.
  • Reverse proxy & local TLS: control whether the tunnel rewrites Host / SNI for the upstream.
  • Auto-reconnect: configurable retry behaviour for long-running tunnels.
  • Event handlers: subclass BaseTunnelHandler to react to lifecycle events (forwardings, disconnect, reconnect, usage updates, …).

Installation

pip install pinggy

Quick start

The fastest way to spin up a tunnel is pinggy.start_tunnel. It builds a tunnel on a background thread and returns a handle you can query.

HTTP tunnel

import pinggy

tunnel = pinggy.start_tunnel(forwardto="localhost:8080")
print("Public URLs:", tunnel.urls)

tunnel.wait()  # block until the tunnel ends

Authenticated TCP tunnel with IP whitelist

import pinggy

tunnel = pinggy.start_tunnel(
    forwardto="localhost:22",
    type="tcp",
    token="your_token_here",
    force=True,
    ipwhitelist=["192.168.1.100", "23.15.30.223/32"],
)
print("Public TCP URLs:", tunnel.urls)

UDP tunnel with web debugger

import pinggy

tunnel = pinggy.start_udptunnel(
    forwardto="localhost:53",
    token="your_token_here",
    webdebuggerport=4300,
)
print("Public UDP URLs:", tunnel.urls)

Local TLS, header rewriting, reverse proxy off

import pinggy

tunnel = pinggy.start_tunnel(
    forwardto="localhost:443",
    type="tls",
    token="your_token_here",
    localservertls=True,
    headermodification=[
        {"type": "remove", "key": "Accept"},
        {"type": "update", "key": "User-Agent", "value": ["PinggyTestServer 1.2.3"]},
    ],
    reverseproxy=False,
)

Lower-level API

If you need finer control, build a Tunnel directly. Configure it via attributes / add_forwarding, then call start().

import pinggy

tunnel = pinggy.Tunnel(server_address="a.pinggy.io:443")
tunnel.token = "your_token_here"
tunnel.add_forwarding("localhost:8080")                  # primary HTTP forwarding
tunnel.add_forwarding("localhost:8443", type="tls")      # additional forwarding
tunnel.auto_reconnect = True
tunnel.start(thread=True)

print(tunnel.urls)
tunnel.wait()

Reacting to events

Override the methods on BaseTunnelHandler you care about and pass the class to the tunnel:

import pinggy

class MyHandler(pinggy.BaseTunnelHandler):
    def tunnel_established(self, urls):
        print("Tunnel up:", urls)

    def tunnel_failed(self, msg):
        print("Tunnel failed:", msg)

    def disconnected(self, msg):
        print("Disconnected:", msg)

tunnel = pinggy.start_tunnel(forwardto=8080, eventclass=MyHandler)
tunnel.wait()

Key API surface

Function / class Purpose
pinggy.start_tunnel(...) Convenience: build, configure, and start a tunnel in one call.
pinggy.start_udptunnel(...) Same, for UDP-only tunnels.
pinggy.Tunnel(...) Low-level tunnel object — configure attributes then start().
pinggy.BaseTunnelHandler Base class for event handlers.
Tunnel.add_forwarding(address, ...) Add a forwarding rule (primary or additional).
Tunnel.forwardings Get / set all forwardings as a string or list of dicts.
Tunnel.start(thread=False) Start the tunnel; pass thread=True to run it in the background.
Tunnel.stop() Stop a running tunnel.
Tunnel.urls Public URLs assigned by the server.
Tunnel.is_active() Whether the tunnel is currently active.
Tunnel.start_web_debugging(port) Enable the web debugger on a port after forwarding succeeds.

Documentation

Full SDK reference: see API_DOC.md in the source tree. Pinggy product docs: https://pinggy.io/docs.

License

Apache 2.0. See LICENSE.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pinggy-0.1.0-cp310-abi3-win_arm64.whl (3.0 MB view details)

Uploaded CPython 3.10+Windows ARM64

pinggy-0.1.0-cp310-abi3-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.10+Windows x86-64

pinggy-0.1.0-cp310-abi3-win32.whl (6.4 MB view details)

Uploaded CPython 3.10+Windows x86

pinggy-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

pinggy-0.1.0-cp310-abi3-manylinux_2_28_i686.whl (6.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ i686

pinggy-0.1.0-cp310-abi3-manylinux_2_28_armv7l.whl (5.3 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARMv7l

pinggy-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl (7.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

pinggy-0.1.0-cp310-abi3-macosx_11_0_universal2.whl (10.8 MB view details)

Uploaded CPython 3.10+macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file pinggy-0.1.0-cp310-abi3-win_arm64.whl.

File metadata

  • Download URL: pinggy-0.1.0-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: CPython 3.10+, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.15

File hashes

Hashes for pinggy-0.1.0-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 e4251d2c547402a12ea07e0046132856d0a654542ac746c16e369e55b99edcff
MD5 44ae3edc83fa22fb11d119d51b58b7d9
BLAKE2b-256 c2a40dac834fcfa4843641c0b235cc274993295388b1edb7b7f4b6e9921930ee

See more details on using hashes here.

File details

Details for the file pinggy-0.1.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: pinggy-0.1.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.15

File hashes

Hashes for pinggy-0.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9141c252d067c1e7c8535c0ad877c3bf33a3b0b386d1e5e0a548833359b63b35
MD5 26a5498e413042734e85435d889c0ef4
BLAKE2b-256 ce0cb7a451c50654488530bd9875f38107be6fe713ed6910e42c8d96fa9b2fda

See more details on using hashes here.

File details

Details for the file pinggy-0.1.0-cp310-abi3-win32.whl.

File metadata

  • Download URL: pinggy-0.1.0-cp310-abi3-win32.whl
  • Upload date:
  • Size: 6.4 MB
  • Tags: CPython 3.10+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.15

File hashes

Hashes for pinggy-0.1.0-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 c0927885454e3bec236700dbab77601e6fe6997a511f7f6d48b5d3db96b89b98
MD5 52c4cacc63fdeed466012c48e2e0535f
BLAKE2b-256 d0c8ebbaaead17ec755135662928548602f27b4427bf4e3acee85edda267ff8e

See more details on using hashes here.

File details

Details for the file pinggy-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pinggy-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d23a9c1b6f019053c7c1051966b3c5d6e1cf0d4aebb7de1bfa0e73ce34d4f9ad
MD5 0dd6541b300be7681775b6857292a304
BLAKE2b-256 bc9710159f421dcd5272d3b7aef27cbeeecdd758f7f3a7fcdb9a15d53ca171c1

See more details on using hashes here.

File details

Details for the file pinggy-0.1.0-cp310-abi3-manylinux_2_28_i686.whl.

File metadata

File hashes

Hashes for pinggy-0.1.0-cp310-abi3-manylinux_2_28_i686.whl
Algorithm Hash digest
SHA256 4e9f552d3125540341458521ed74eb5959a4ffe6070ab0e8fce161fcd91254bb
MD5 ac29d5544e3cbad91a0fadac05020ea2
BLAKE2b-256 b020e621f86e42be54d698446f2ac5c1e1be84e3d171bf202d6517471d7ba005

See more details on using hashes here.

File details

Details for the file pinggy-0.1.0-cp310-abi3-manylinux_2_28_armv7l.whl.

File metadata

File hashes

Hashes for pinggy-0.1.0-cp310-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 f06915712375305c9a2148d5f2e6c0640c41bdaa0484d29aa5f5d85688ed397b
MD5 722f465dc2506b5f788bf566a7dee351
BLAKE2b-256 eb2bc1af7746b40415243a6e02c8584f39e4d66af1b0a72aa365f8bf7ab0858c

See more details on using hashes here.

File details

Details for the file pinggy-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pinggy-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 21904ce9e9f31dda2f5104058c5b91a8dc5791c227674abb99e14ce537c4ce1a
MD5 8038cff650f40c97db155a1b8b4c6aee
BLAKE2b-256 32d00e20aefebb42a4c264b18b07c0e531d59b7c808b45704fd5f16267f96959

See more details on using hashes here.

File details

Details for the file pinggy-0.1.0-cp310-abi3-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for pinggy-0.1.0-cp310-abi3-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 939118f65dbce35541c8676e48f1496705b423c42f33fb474713071be242c5b8
MD5 1882d5d6250e97d36778f8568f3b4122
BLAKE2b-256 708e98d850d30ad530d511053a9943616304e825ca996cda11486f92087074ab

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