tworjaga/PiNetCore
GitHub: tworjaga/PiNetCore
为 Raspberry Pi 5 打造的生产级网络设备,提供实时抓包、nftables 防火墙、VPN 与插件化 IDS/IPS 的完整解决方案。
Stars: 1 | Forks: 0
# PiNetCore -- Raspberry Pi 网络设备
[](https://github.com/tworjaga/PiNetCore/actions)
[](https://opensource.org/licenses/MIT)
[](https://www.rust-lang.org)
[](https://www.docker.com)
[](https://react.dev)
## 概述
PiNetCore 是为 Raspberry Pi 5 打造的生产级网络设备。提供完整的路由器控制、实时数据包记录、nftables 防火墙、模块化插件(WireGuard VPN、Pi-hole DNS、Suricata IDS)、带有实时指标的 React 仪表板。
## 架构
```
Internet/WAN → Rust Core (pnet TAP/bridge + Axum API + SQLite) → Plugins → React Dashboard (Vite/Tailwind/Recharts)
```
## 关键特性
- 数据包捕获/记录(以太网/IP/TCP/UDP → SQLite)
- nftables 防火墙(黑名单/白名单)
- 插件系统(VPN/Pi-hole/Suricata 就绪)
- Axum REST + /metrics(Prometheus)
- React 仪表板 + 实时 WebSocket
- Docker ARM + systemd 部署
- 专为 Pi5 LiteOS 优化
## 项目结构
```
PiNetCore/
├── core-engine/ # Rust backend (Tokio/Axum/pnet/sqlx)
│ ├── src/{api,capture,firewall,plugins,storage}
│ ├── Cargo.toml
│ └── tests/
├── dashboard/ # React frontend (Vite/Tailwind/React Query)
│ ├── src/{components,hooks,services,store}
│ ├── package.json
│ └── tests/
├── deployments/ # Docker + systemd + Pi scripts
│ ├── docker/
│ ├── scripts/install_pi.sh
│ └── docker-compose.yml
└── configs/ # nftables/wireguard
```
## 快速启动
### Docker(推荐)
```
git clone https://github.com/tworjaga/PiNetCore
cd PiNetCore
docker compose up -d
```
API: http://localhost:8080/api/connections
仪表板: http://localhost:3000
指标: http://localhost:8080/metrics
### 原生 Pi5
```
./deployments/scripts/install_pi.sh
sudo systemctl start pinetcore
```
## 兼容性
| 路由器 | 桥接模式 | VLAN | ISP 调制解调器 |
|--------|-------------|------|-----------|
| ASUS/TP-Link/Netgear | 是 | 是 | 是 |
| OpenWrt/DD-WRT | 是 | 是 | 是 |
| ISP 锁定 | 手动 | 否 | 否 |
## 技术栈
**后端(Rust)**
运行时: Tokio
Web: Axum
数据包: pnet
数据库: sqlx(SQLite)
防火墙: nftables 绑定
**前端(TypeScript)**
框架: Vite + React 18
样式: Tailwind CSS
图表: Recharts
查询: TanStack Query
**基础设施**
容器: Docker ARM64
编排: 多服务栈
部署: systemd 服务
## 测试
```
# 后端
cd core-engine
cargo test # Unit/integration
cargo clippy # Lints
# 前端
cd dashboard
npm test # Vitest (100% coverage)
npm run build # Production build
```
## 配置
`.env` 或 `core-engine/config.yaml`:
```
database_url = "sqlite://pinetcore.db"
api_port = 8080
capture:
interface = "eth0"
firewall:
enabled = true
```
## API
**REST**:
```
GET /api/connections # Recent connections
GET /health # Status
GET /metrics # Prometheus
```
**示例**:
```
curl http://localhost:8080/api/connections
```
## 部署
**Docker Compose**(Grafana/Prometheus/Loki 已就绪):
```
docker compose -f docker-compose.monitoring.yml up -d
```
**Pi 生产环境**:
1. `./deployments/scripts/install_pi.sh`
2. `sudo systemctl enable pinetcore`
3. `sudo systemctl status pinetcore`
## 插件
```
pub struct MyPlugin;
impl Plugin for MyPlugin {
fn name(&self) -> &str { "MyPlugin" }
fn start(&self) -> anyhow::Result<()> { Ok(()) }
}
```
在 `main.rs` 中注册 → 自动启动/停止。
## 许可证
MIT 许可证 - 详情见 LICENSE。
仓库: https://github.com/tworjaga/PiNetCore
电报: @al7exy
标签:Axum, DNS, Docker, IP, IPS, LiteOS, Metrics, nftables, OpenVPN, Pi5, Pi-hole, pnet, Raspberry Pi, React 18, Recharts, REST API, Rust, Rust 1.75, SQLite, Suricata, systemd, Tailwind, TCP, Tokio, UDP, Vite, VPN, WebSocket, WireGuard, 互联网扫描, 以太网, 依赖分析, 内存执行, 包捕获, 可视化仪表盘, 可视化界面, 威胁检测与响应, 安全防御评估, 实时图表, 家庭实验室, 嵌入式, 日志聚合, 模块化插件, 流量日志, 现代安全运营, 生产就绪, 网络嗅探, 网络控制, 网络流量审计, 网络设备, 请求拦截, 通知系统, 部署, 防火墙, 集中日志, 黑白名单