A simple TCP tunnel over WebSocket.
Project description
# yanghao.portlink
> Expose your local port to the public internet with a single command.
```bash
pip install yanghao.portlink
portlink tcp 8000
🚀 Quick Start
-
Install
pip install yanghao.portlink
-
Expose a local TCP service
portlink tcp 8000
Output:
✓ Tunnel created Public URL: tcp://abc123.portlink.dev:8000 -> localhost:8000 -
Programmatic usage
from yanghao.portlink import Client async with Client(token="YOUR_TOKEN") as c: url = await c.expose(8000, protocol="http") print(url)
✨ Features
- Zero-config – one binary, one command
- TCP protocol – simple and reliable
- Auto-reconnect – survives network hiccups
- Async & sync APIs – fits any codebase
- Cross-platform – Linux, macOS, Windows
📦 Installation
| Method | Command |
|---|---|
| PyPI | pip install yanghao.portlink |
| Source | git clone https://github.com/yahao333/portlink && pip install -e . |
Requires Python 3.8+.
🛠 Usage
CLI
| Command | Description |
|---|---|
portlink tcp 8000 |
Expose local port 8000 |
portlink tcp 22 |
Expose local SSH |
portlink --config ~/.portlink.yml |
Use custom config |
Python API (sync)
from yanghao.portlink import Client
client = Client(token="YOUR_TOKEN")
url = client.expose(8000, protocol="tcp")
print(url) # tcp://abc123.portlink.dev:8000
Python API (async)
import asyncio
from yanghao.portlink import AsyncClient
async def main():
async with AsyncClient(token="YOUR_TOKEN") as c:
url = await c.expose(8000, protocol="tcp")
print(url) # tcp://abc123.portlink.dev:8000
asyncio.run(main())
⚙️ Configuration
Create ~/.portlink.yml:
token: YOUR_TOKEN
server: tcp://tunnel.portlink.dev
region: auto
Environment variables are also supported:
export PORTLINK_TOKEN="YOUR_TOKEN"
🔐 Authentication
- Sign in → Settings → API Tokens
- Copy the token, export or save in config.
🤝 Contributing
- Fork the repo
pip install -e ".[dev]"pytest(≥ 90 % coverage required)- Open a PR
📄 License
MIT © 2025 yahao333
💬 Help
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
yanghao_portlink-0.0.4.tar.gz
(10.9 kB
view details)
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 yanghao_portlink-0.0.4.tar.gz.
File metadata
- Download URL: yanghao_portlink-0.0.4.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c71f5a1340a556984fc209837001ae0471b53d864a503dc57a0b387024dbfc9
|
|
| MD5 |
9b641bb0289a4e3bb8de0ac632cdde6e
|
|
| BLAKE2b-256 |
a061101276408e1461e9af01b9cba1bb704cc562c234d86e2752d50334387a8c
|
File details
Details for the file yanghao_portlink-0.0.4-py3-none-any.whl.
File metadata
- Download URL: yanghao_portlink-0.0.4-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a27986333778b3d0eecf75d1cce0608a614fe984c39fcdc8780b098b48ba4ae0
|
|
| MD5 |
f53aa52e1245f25bcaabc9c575580e47
|
|
| BLAKE2b-256 |
9224a8e3b2cdca58e4a3c61d72aa9b8a611449db26637cf0b934ad110db68423
|