A simple TCP tunnel over WebSocket.
Project description
# yanghao.portlink
> 一条命令,把你的本地端口暴露到公网。
```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/yanghao/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 © 2024 yanghao
💬 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
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.1.tar.gz.
File metadata
- Download URL: yanghao_portlink-0.0.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
316a9af009d37aa12e9ea442ffea662dd477b2db6f21f91dce7697b2057a0817
|
|
| MD5 |
d49eb47ace04c07ea916210650acacd0
|
|
| BLAKE2b-256 |
c9978d321b280e16880d02c108b26da82f01395cad4ce9a9fc71a11e70e8d6ec
|
File details
Details for the file yanghao_portlink-0.0.1-py3-none-any.whl.
File metadata
- Download URL: yanghao_portlink-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.4 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 |
3869368ee9b0917c5d2df4ee29c114b0858907be23d6372cd070a7f4b602149f
|
|
| MD5 |
a6f8f08a1187f71fecbaa7e93302ee30
|
|
| BLAKE2b-256 |
a44e098bc7673b88e68a5892bc9856204df777c095d33a149bb8b3e7a2ee5a96
|