Simple TCP public network tunnel
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://106.75.139.203:8000 -> localhost:8000 -
Programmatic usage
from yanghao.portlink import PortLinkClient as Client
async def main():
async with Client(8000) as c:
await c.link(8000)
if __name__ == "__main__":
import asyncio
asyncio.run(main())
✨ 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+.
It is recommended to use a virtual environment (.venv) to avoid dependency conflicts.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
🛠 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.14.tar.gz
(12.3 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.14.tar.gz.
File metadata
- Download URL: yanghao_portlink-0.0.14.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5899daa59e3c46228aabc6f995e26fd2701b87a2df88df2a6f092d7bee36bb7
|
|
| MD5 |
052bd61af203ce90f9c88bd8ab280601
|
|
| BLAKE2b-256 |
12c0abb886e522ec0f54a11e2d8de10e797b3cfb93f6b85ebae65eea77b92909
|
File details
Details for the file yanghao_portlink-0.0.14-py3-none-any.whl.
File metadata
- Download URL: yanghao_portlink-0.0.14-py3-none-any.whl
- Upload date:
- Size: 6.7 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 |
c6df776186ec79d766963cbd27a587058194aae027e960f876e7a190e30b65ff
|
|
| MD5 |
fc898ab00b93d8b8f54d6c2ddc5cd2d7
|
|
| BLAKE2b-256 |
30eea5a6c8beaac3ff7cf3f51d154efc0e7c86323b87973ba193e52552578a88
|