Metadata-Version: 2.4
Name: dpmp
Version: 1.0.0
Summary: DPMP - Dual-Punch Multi-Path Protocol: P2P connectivity & transport library
Author-email: DPMP <a1354343110804@outlook.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/a13543431108/DPMP
Project-URL: Source, https://github.com/a13543431108/DPMP
Project-URL: Issues, https://github.com/a13543431108/DPMP/issues
Keywords: p2p,nat-traversal,hole-punching,multi-path,udp,tcp,peer-to-peer,nat
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet
Classifier: Topic :: System :: Networking
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# DPMP · Python 端

**DPMP 的 Python 实现** —— 纯标准库，零第三方依赖。

只做一件事：**把字节可靠地从 A 送到 B**。

---

## 安装

```bash
cd python && pip install -e .
```

或从 PyPI：

```bash
pip install dpmp
```

---

## 快速开始

```python
from dpmp.room import RoomClient
from dpmp.util import get_or_create_device_id

cli = RoomClient(
    server_ip="your.server.ip", room="my-room", name="my-device",
    tcp_port=9995, device_id=get_or_create_device_id(), log=print,
)
cli.on_tcp_ready = lambda pid, sock, m: print("TCP 直连就绪", pid)
cli.on_udp_ready = lambda pid, rtp:      print("UDP 直连就绪", pid)

cli.start()
cli.send(peer_id, b"hi")
cli.stop()
```

信令服务器：

```bash
dpmp-signaling-server            # 或 python -m dpmp.signaling_server
```

---

## 分层

| 层 | 模块 | 职责 |
|---|---|---|
| 传输 | `dpmp.udp_reliable` | UDP-RTP 可靠字节流 |
| 协议 | `dpmp.protocol` | 线格式常量与帧读写 |
| 房间 | `dpmp.room` | 信令 / 打洞 / 路径调度 / 连接管理 / 端口监听 |
| 工具 | `dpmp.util` | 本机 IP / 设备标识 / 子网 / 广播 |
| 服务器 | `dpmp.signaling_server` | 信令服务器（可独立运行）|

---

## 端口说明

| 端口 | 协议 | 用途 |
|---|---|---|
| 3336 | UDP | 信令服务器 |
| 3337 | TCP | TCP 映射观测 |
| 3338 | UDP | NAT 类型探测 |
| 9995 | TCP | 房间模式打洞 / 长连接 / 映射观测 |
| 9996 | UDP | 房间模式 UDP 打洞 |
| 9997 | UDP | 局域网主动扫描 |
| 9998 | UDP | 局域网设备发现 |
| 9999 | TCP | 局域网文件传输 |

---

## 许可

Apache License 2.0。
