{"id":50265332,"url":"https://github.com/narwhal-cloud/rfw","last_synced_at":"2026-05-27T13:38:17.163Z","repository":{"id":322049107,"uuid":"1086617440","full_name":"narwhal-cloud/rfw","owner":"narwhal-cloud","description":"Rust Firewall","archived":false,"fork":false,"pushed_at":"2026-05-24T12:01:35.000Z","size":193,"stargazers_count":82,"open_issues_count":0,"forks_count":21,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-24T14:05:29.632Z","etag":null,"topics":["aya","ebpf","firewall"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/narwhal-cloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-30T17:00:20.000Z","updated_at":"2026-05-19T09:35:05.000Z","dependencies_parsed_at":"2026-04-21T16:00:42.813Z","dependency_job_id":null,"html_url":"https://github.com/narwhal-cloud/rfw","commit_stats":null,"previous_names":["narwhal-cloud/rfw"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/narwhal-cloud/rfw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narwhal-cloud%2Frfw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narwhal-cloud%2Frfw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narwhal-cloud%2Frfw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narwhal-cloud%2Frfw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/narwhal-cloud","download_url":"https://codeload.github.com/narwhal-cloud/rfw/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narwhal-cloud%2Frfw/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33568857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aya","ebpf","firewall"],"created_at":"2026-05-27T13:38:12.904Z","updated_at":"2026-05-27T13:38:17.151Z","avatar_url":"https://github.com/narwhal-cloud.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rfw\n\nRust Firewall - 基于 eBPF/XDP 的高性能防火墙，支持 GeoIP 过滤和协议深度检测\n\n[![Release](https://github.com/narwhal-cloud/rfw/actions/workflows/build.yml/badge.svg)](https://github.com/narwhal-cloud/rfw/actions/workflows/build.yml)\n\n## 目录\n\n- [功能特性](#功能特性)\n- [快速开始](#快速开始)\n- [使用说明](#使用说明)\n- [技术实现](#技术实现)\n- [编译和安装](#编译和安装)\n- [License](#license)\n\n## 功能特性\n\n### 灵活的 GeoIP 过滤\n\n- **多国家支持** - 支持指定任意国家代码（CN、RU、KP、US 等）\n- **灵活的过滤模式**:\n  - **黑名单模式** - 阻止指定国家的流量\n  - **白名单模式** - 只允许指定国家的流量\n  - **无 GeoIP 模式** - 直接基于协议规则过滤所有流量\n- **自动下载 GeoIP 数据** - 运行时自动下载指定国家的最新 IP 段\n\n### 支持的过滤规则\n\n1. **屏蔽 Email** - 阻止邮件（SMTP: 25/587/465/2525）相关端口流量\n2. **屏蔽 HTTP 入站** - 使用协议深度检测识别 HTTP 流量，配合 GeoIP 或全局过滤\n3. **屏蔽 SOCKS5 入站** - 使用协议深度检测识别 SOCKS5 流量，配合 GeoIP 或全局过滤\n4. **屏蔽全加密流量入站** - 使用 FET 算法识别 Shadowsocks、V2Ray 等加密代理\n5. **屏蔽 WireGuard VPN 入站** - 精准识别 WireGuard VPN 协议\n6. **屏蔽 QUIC 入站** - 精准识别 QUIC 协议（HTTP/3）\n7. **屏蔽所有入站流量** - 阻止所有入站连接（配合 GeoIP 或全局）\n8. **端口访问日志** - 记录所有端口被哪些 IP 访问，以及是否被阻断\n\n### 协议深度检测 (DPI)\n\n与传统的基于端口号的防火墙不同，rfw 使用**协议深度检测**（Deep Packet Inspection, DPI）：\n\n- **HTTP 检测**：识别 HTTP 请求方法（GET, POST 等）\n- **SOCKS5 检测**：识别 SOCKS5 握手协议特征\n- **全加密流量检测**：使用统计算法识别 Shadowsocks、V2Ray 等加密代理\n- **WireGuard 检测**：精准识别 WireGuard VPN 协议\n- **QUIC 检测**：识别 QUIC v1/v2 和 Google QUIC 协议（HTTP/3）\n- **不依赖端口号**：即使服务运行在非标准端口也能识别\n\n### 性能特性\n\n- **XDP (eXpress Data Path)**：在网卡驱动层处理数据包，极低延迟\n- **零拷贝**：直接在内核中处理，无需复制数据到用户空间\n- **高吞吐**：可处理 10Gbps+ 的网络流量\n\n### 协议支持\n\n- **仅支持 IPv4**：目前不支持 IPv6 流量\n- **GeoIP 自动更新**：每次运行时自动下载指定国家的最新 IP 数据\n- **多数据源**：使用 [lyc8503/sing-box-rules](https://github.com/lyc8503/sing-box-rules) 提供的 GeoIP 数据\n\n## 快速开始\n\n### 编译\n\n```bash\n# Linux 环境\ncargo build --release\n\n# macOS 交叉编译到 Linux (x86_64)\nCC=x86_64-linux-musl-gcc cargo build --package rfw --release \\\n  --target=x86_64-unknown-linux-musl \\\n  --config=target.x86_64-unknown-linux-musl.linker=\\\"x86_64-linux-musl-gcc\\\"\n\n# macOS 交叉编译到 Linux (aarch64)\nCC=aarch64-linux-musl-gcc cargo build --package rfw --release \\\n  --target=aarch64-unknown-linux-musl \\\n  --config=target.aarch64-unknown-linux-musl.linker=\\\"aarch64-linux-musl-gcc\\\"\n```\n\n### 基本使用\n\n```bash\n# 查看帮助\nsudo ./target/release/rfw --help\n\n# 阻止指定国家的 HTTP 和 SOCKS5 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN,RU,KP \\\n  --block-http --block-socks5\n\n# 阻止来自中国的所有流量（快捷方式）\nsudo ./target/release/rfw --iface eth0 \\\n  --block-all-from CN\n\n# 白名单模式：只允许来自美国、日本、韩国的流量\nsudo ./target/release/rfw --iface eth0 \\\n  --allow-only-countries US,JP,KR \\\n  --block-http --block-socks5\n\n# 不限国家，阻止所有 HTTP 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --block-http\n\n# 启用详细日志\nsudo RUST_LOG=info ./target/release/rfw --iface eth0 --countries CN --block-wireguard --block-quic\n```\n\n## 使用说明\n\n### GeoIP 配置\n\n#### 1. 黑名单模式（阻止指定国家）\n\n```bash\n# 阻止来自中国、俄罗斯、朝鲜的 HTTP 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN,RU,KP \\\n  --block-http\n\n# 阻止来自指定国家的所有流量\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN,RU \\\n  --block-all\n```\n\n#### 2. 白名单模式（只允许指定国家）\n\n```bash\n# 只允许来自美国、日本、韩国的访问\nsudo ./target/release/rfw --iface eth0 \\\n  --allow-only-countries US,JP,KR \\\n  --block-http --block-socks5\n```\n\n#### 3. 快捷方式：阻止指定国家的所有流量\n\n```bash\n# 等价于 --countries CN --block-all\nsudo ./target/release/rfw --iface eth0 \\\n  --block-all-from CN,RU,KP\n```\n\n#### 4. 不使用 GeoIP（全局协议过滤）\n\n```bash\n# 阻止所有来源的 HTTP 和 SOCKS5 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --block-http --block-socks5\n```\n\n### 协议规则详解\n\n#### 1. 屏蔽发送 Email\n\n```bash\nsudo ./target/release/rfw --iface eth0 --block-email\n```\n\n此规则会**仅阻止发送邮件**的出站流量，**允许接收邮件**：\n\n**阻止的 SMTP 端口（发送邮件）：**\n- 端口 25 - 标准 SMTP（未加密）\n- 端口 587 - SMTP Submission（STARTTLS）\n- 端口 465 - SMTPS（SSL/TLS 加密）\n- 端口 2525 - 备用 SMTP 端口\n\n**允许的端口（接收邮件）：**\n- ✅ 端口 110 - POP3（未加密）\n- ✅ 端口 995 - POP3S（SSL/TLS 加密）\n- ✅ 端口 143 - IMAP（未加密）\n- ✅ 端口 993 - IMAPS（SSL/TLS 加密）\n\n**效果说明：**\n- ❌ 阻止使用邮件客户端（Outlook, Thunderbird, Apple Mail 等）**发送**邮件\n- ❌ 阻止命令行邮件工具（sendmail, mutt 等）发送邮件\n- ✅ **允许**使用邮件客户端**接收**邮件（POP3/IMAP）\n- ✅ 不影响基于浏览器的网页邮箱（如 Gmail 网页版，使用 HTTP/HTTPS）\n\n**使用场景：**\n- 防止服务器被用作垃圾邮件发送源\n- 防止恶意软件发送钓鱼邮件\n- 允许用户正常接收邮件，但禁止发送\n\n#### 2. 屏蔽 HTTP 入站\n\n```bash\n# 阻止指定国家的 HTTP 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN,RU \\\n  --block-http\n\n# 阻止所有来源的 HTTP 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --block-http\n```\n\n阻止 HTTP 入站连接（仅明文 HTTP，不包括 HTTPS）\n\n#### 3. 屏蔽 SOCKS5 入站\n\n```bash\n# 阻止指定国家的 SOCKS5 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN \\\n  --block-socks5\n\n# 阻止所有来源的 SOCKS5 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --block-socks5\n```\n\n阻止 SOCKS5 代理入站连接\n\n#### 4. 屏蔽全加密流量入站\n\n```bash\n# 严格模式：阻止指定国家的全加密流量\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN \\\n  --block-fet-strict\n\n# 宽松模式\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN \\\n  --block-fet-loose\n```\n\n阻止全加密代理流量（Shadowsocks、V2Ray 等）\n\n**特点：**\n- 使用统计算法识别加密代理特征\n- 自动豁免合法的 TLS/HTTPS 流量\n- 基于 GFW 研究论文实现\n\n**注意：**\n- 检测基于统计特征，可能有极少的误报\n\n#### 5. 屏蔽 WireGuard VPN 入站\n\n```bash\n# 阻止指定国家的 WireGuard 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN \\\n  --block-wireguard\n\n# 阻止所有来源的 WireGuard 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --block-wireguard\n```\n\n阻止 WireGuard VPN 流量\n\n**特点：**\n- 基于 WireGuard 协议特征精准识别\n- 误报率极低，性能开销小\n- 不会影响其他 UDP 应用\n\n#### 6. 屏蔽 QUIC 入站\n\n```bash\n# 阻止指定国家的 QUIC 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN \\\n  --block-quic\n\n# 阻止所有来源的 QUIC 流量\nsudo ./target/release/rfw --iface eth0 \\\n  --block-quic\n```\n\n阻止 QUIC 协议流量（HTTP/3）\n\n**特点：**\n- 精准识别 QUIC v1（RFC 9000）和 QUIC v2（RFC 9369）\n- 支持检测 Google QUIC 协议\n- 识别长头部和短头部数据包\n- 误报率极低，不影响其他 UDP 应用\n\n**支持的 QUIC 版本：**\n- QUIC v1（RFC 9000，版本号 0x00000001）\n- QUIC v2（RFC 9369，版本号 0x6b3343cf）\n- Google QUIC（Q0xx 系列）\n- 版本协商包\n\n**使用场景：**\n- 阻止基于 HTTP/3 的服务被滥用\n- 防止 QUIC 代理服务器被滥用\n- 限制新一代加密传输协议的入站连接\n\n#### 7. 屏蔽所有入站流量\n\n```bash\n# 阻止指定国家的所有流量\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN,RU \\\n  --block-all\n\n# 快捷方式\nsudo ./target/release/rfw --iface eth0 \\\n  --block-all-from CN,RU\n\n# 白名单模式：只允许指定国家\nsudo ./target/release/rfw --iface eth0 \\\n  --allow-only-countries US,JP,KR \\\n  --block-all\n\n# 阻止所有来源的流量（不使用 GeoIP）\nsudo ./target/release/rfw --iface eth0 \\\n  --block-all\n```\n\n阻止**所有**入站流量（不限协议、不限端口）\n\n**特点：**\n- 配合 GeoIP 时，仅基于 GeoIP 检测，性能开销最小\n- 最彻底的屏蔽方式\n- 优先级最高，在协议检测之前执行\n\n**使用场景：**\n- 服务器只面向特定地区用户（使用白名单模式）\n- 需要彻底阻止来自特定国家的访问\n\n**注意：**\n- 如果启用此规则，无需启用其他协议检测规则\n- 只影响入站流量，不影响出站流量\n\n#### 8. 端口访问日志\n\n端口访问日志功能可以记录所有端口被哪些 IP 访问，以及这些访问是被允许还是被阻断。\n\n##### 启用日志记录\n\n在启动防火墙时添加 `--log-port-access` 参数即可启用端口访问日志：\n\n```bash\n# 启动防火墙并启用端口访问日志\nsudo ./target/release/rfw --iface eth0 \\\n  --block-http --block-socks5 \\\n  --log-port-access\n\n# 配合 GeoIP 使用\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN,RU \\\n  --block-http --block-wireguard \\\n  --log-port-access\n```\n\n##### 查看统计信息\n\n在防火墙运行时，使用 `stats` 子命令查看访问统计：\n\n```bash\n# 查看所有端口访问记录\nsudo ./target/release/rfw stats\n\n# 按端口过滤\nsudo ./target/release/rfw stats --port 80\n\n# 按源 IP 过滤\nsudo ./target/release/rfw stats --ip 1.2.3.4\n\n# 只显示被阻断的访问\nsudo ./target/release/rfw stats --blocked-only\n\n# 只显示允许通过的访问\nsudo ./target/release/rfw stats --allowed-only\n\n# 按端口分组显示（汇总统计）\nsudo ./target/release/rfw stats --group-by-port\n\n# 组合使用过滤条件\nsudo ./target/release/rfw stats --port 80 --blocked-only\n```\n\n##### 输出示例\n\n**列表模式（默认）：**\n\n```\nSource IP        Proto      Port      Allowed      Blocked        Total\n------------------------------------------------------------------------\n1.2.3.4          TCP          80            0          156          156\n5.6.7.8          TCP        8080           45            0           45\n9.10.11.12       UDP         443           12            8           20\n```\n\n**分组模式（--group-by-port）：**\n\n```\nPort 80/TCP\nSource IP             Allowed      Blocked        Total\n--------------------------------------------------------\n1.2.3.4                     0          156          156\n5.6.7.8                   120            0          120\n\nPort 8080/TCP\nSource IP             Allowed      Blocked        Total\n--------------------------------------------------------\n9.10.11.12               45            0           45\n```\n\n##### 技术实现\n\n- **BPF 文件系统共享**: 使用 `/sys/fs/bpf` pinning 机制实现跨进程 eBPF map 共享\n- **LRU 缓存**: 自动淘汰旧记录，最多存储 65536 条记录\n- **实时更新**: 统计数据在内核中实时记录，无需重启防火墙\n- **低开销**: 仅当启用 `--log-port-access` 时才记录，不影响未启用时的性能\n- **高性能**: 所有统计在 eBPF 内核中完成，几乎无性能损耗\n\n##### 注意事项\n\n1. **需要 root 权限**: 访问 `/sys/fs/bpf` 需要 root 权限\n2. **防火墙必须运行**: `stats` 命令依赖正在运行的防火墙进程（需启用 `--log-port-access`）\n3. **BPF 文件系统**: 需要 `/sys/fs/bpf` 已挂载（大多数 Linux 系统默认已挂载）\n4. **容量限制**: 最多存储 65536 条不同的访问记录（源IP + 目标端口 + 协议组合）\n5. **自动清理**: 使用 LRU 策略，旧记录会被自动淘汰以腾出空间\n6. **协议支持**: 记录 TCP 和 UDP 协议的访问\n\n##### 使用场景\n\n- **安全审计**: 了解服务器上哪些端口被访问，来源 IP 是哪些\n- **攻击分析**: 查看哪些 IP 的访问被阻断，分析攻击模式\n- **服务监控**: 监控特定端口的访问频率和来源分布\n- **规则优化**: 根据访问统计优化防火墙规则\n\n### 组合使用多个规则\n\n```bash\n# 同时启用所有规则（针对指定国家）\nsudo ./target/release/rfw --iface eth0 \\\n  --countries CN,RU,KP \\\n  --block-email \\\n  --block-http \\\n  --block-socks5 \\\n  --block-fet-strict \\\n  --block-wireguard \\\n  --block-quic\n\n# 多国家分别配置（使用白名单）\nsudo ./target/release/rfw --iface eth0 \\\n  --allow-only-countries US,JP,KR,SG \\\n  --block-http \\\n  --block-socks5\n\n# 不使用 GeoIP,全局协议检测\nsudo ./target/release/rfw --iface eth0 \\\n  --block-http \\\n  --block-socks5 \\\n  --block-wireguard \\\n  --block-quic\n\n# 组合使用：邮件 + 特定国家的代理协议\nsudo ./target/release/rfw --iface eth0 \\\n  --block-email \\\n  --countries CN \\\n  --block-http \\\n  --block-socks5\n\n# 最激进模式：阻止指定国家的所有流量\nsudo ./target/release/rfw --iface eth0 \\\n  --block-all-from CN,RU,KP\n```\n\n### 运行要求\n\n1. **Linux 内核版本**: 需要支持 XDP 的内核（通常是 4.8+，推荐 5.x+）\n2. **Root 权限**: 加载 eBPF 程序需要 root 权限\n3. **网络接口**: 确保指定的网卡名称正确（使用 `ip link` 查看）\n4. **协议支持**: 目前仅支持 IPv4，不支持 IPv6\n\n### 日志\n\n程序使用 `env_logger` 记录日志。可以通过设置 `RUST_LOG` 环境变量来控制日志级别：\n\n```bash\n# 显示详细日志\nsudo RUST_LOG=info ./target/release/rfw --iface eth0 --block-email\n\n# 显示调试日志\nsudo RUST_LOG=debug ./target/release/rfw --iface eth0 --block-email\n```\n\n当数据包被阻止时，eBPF 程序会记录相关信息到内核日志中。\n\n### 停止防火墙\n\n按 `Ctrl+C` 即可停止防火墙程序。程序会自动卸载 eBPF 程序并清理资源。\n\n## 技术实现\n\nrfw 基于 **eBPF/XDP** 技术，使用 **Rust** 语言开发。\n\n### 架构\n\n- **rfw-ebpf**: 运行在内核的 eBPF 程序，负责数据包过滤\n- **rfw**: 用户空间程序，负责加载配置和管理 eBPF 程序\n- **rfw-common**: 共享的数据结构定义\n\n### 工作原理\n\n1. 在网卡驱动层拦截数据包（XDP）\n2. 检查是否为 IPv4 数据包（**目前仅支持 IPv4**）\n3. 根据启用的规则进行检测：\n   - **GeoIP 检测**：使用 LpmTrie 高效匹配源 IP 是否在指定国家列表中\n   - **白名单/黑名单模式**：支持阻止指定国家或只允许指定国家\n   - **协议检测**：识别 HTTP、SOCKS5、WireGuard、QUIC 等协议特征\n   - **端口检测**：识别 Email 发送端口\n4. 返回判决：允许通过或丢弃\n\n### GeoIP 数据管理\n\n- **数据源**: [lyc8503/sing-box-rules](https://github.com/lyc8503/sing-box-rules)\n- **存储方式**: 使用 LpmTrie (Longest Prefix Match Trie) 进行高效前缀匹配\n- **容量**: 最多支持 65536 个 CIDR 前缀\n- **性能**: O(1) 时间复杂度的 IP 查询\n- **更新策略**: 每次程序启动时自动下载最新数据\n\n### 性能优势\n\n- 在内核驱动层处理，延迟极低\n- 零拷贝，无需将数据传到用户空间\n- 可处理 10Gbps+ 高速流量\n\n## 编译和安装\n\n### Prerequisites\n\n1. stable rust toolchains: `rustup toolchain install stable`\n2. nightly rust toolchains: `rustup toolchain install nightly --component rust-src`\n3. (if cross-compiling) rustup target: `rustup target add ${ARCH}-unknown-linux-musl`\n4. (if cross-compiling) LLVM: (e.g.) `brew install llvm` (on macOS)\n5. (if cross-compiling) C toolchain: (e.g.) [`brew install filosottile/musl-cross/musl-cross`](https://github.com/FiloSottile/homebrew-musl-cross) (on macOS)\n6. bpf-linker: `cargo install bpf-linker` (`--no-default-features` on macOS)\n\n### 编译\n\n#### Linux 环境\n\n```bash\ncargo build --release\n```\n\n#### macOS 交叉编译\n\n交叉编译适用于 Intel 和 Apple Silicon Mac：\n\n```bash\n# x86_64\nCC=x86_64-linux-musl-gcc cargo build --package rfw --release \\\n  --target=x86_64-unknown-linux-musl \\\n  --config=target.x86_64-unknown-linux-musl.linker=\\\"x86_64-linux-musl-gcc\\\"\n\n# aarch64\nCC=aarch64-linux-musl-gcc cargo build --package rfw --release \\\n  --target=aarch64-unknown-linux-musl \\\n  --config=target.aarch64-unknown-linux-musl.linker=\\\"aarch64-linux-musl-gcc\\\"\n```\n\n交叉编译后的程序位于 `target/${ARCH}-unknown-linux-musl/release/rfw`，可以复制到 Linux 服务器或虚拟机上运行。\n\n### 运行\n\n```bash\n# 基本运行\nsudo ./target/release/rfw --iface eth0\n\n# 启用规则\nsudo ./target/release/rfw --iface eth0 --block-email --block-cn-http\n\n# 查看日志\nsudo RUST_LOG=info ./target/release/rfw --iface eth0 --block-cn-fet-strict\n```\n\n## 参考资料\n\n- [eBPF 文档](https://ebpf.io/)\n- [XDP 教程](https://github.com/xdp-project/xdp-tutorial)\n- [Aya 框架](https://aya-rs.dev/)\n- [OpenGFW 项目](https://github.com/apernet/OpenGFW)\n- [FET 论文](https://gfw.report/publications/usenixsecurity23/data/paper/paper.pdf)\n\n## License\n\nWith the exception of eBPF code, rfw is distributed under the terms\nof either the [MIT license] or the [Apache License] (version 2.0), at your\noption.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\n### eBPF\n\nAll eBPF code is distributed under either the terms of the\n[GNU General Public License, Version 2] or the [MIT license], at your\noption.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this project by you, as defined in the GPL-2 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\n[Apache license]: LICENSE-APACHE\n[MIT license]: LICENSE-MIT\n[GNU General Public License, Version 2]: LICENSE-GPL2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnarwhal-cloud%2Frfw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnarwhal-cloud%2Frfw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnarwhal-cloud%2Frfw/lists"}