npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yehuo2003/ha-frp-rn

v1.0.0

Published

React Native FRP module for network penetration

Readme

ha-frp-rn

React Native FRP (Fast Reverse Proxy) 模块,用于网络穿透,支持 Android 平台。

项目概述

ha-frp-rn 是一个 React Native 原生模块,实现了 FRP 客户端功能,用于建立从设备到 FRP 服务器的连接,实现网络穿透。该模块基于 ha-shared-core 中定义的 IFrpService 接口,提供了跨平台的 FRP 功能支持。

功能特性

  • ✅ 支持 Android 平台
  • ✅ 实现 IFrpService 接口,与 ha-shared-core 无缝集成
  • ✅ 支持远程配置获取与本地默认配置 fallback
  • ✅ TypeScript 完全支持
  • ✅ 模块化设计,易于扩展和维护
  • ✅ 支持 FRP 状态监控和日志记录
  • ✅ 支持多种 FRP 配置类型

安装

npm

npm install ha-frp-rn

yarn

yarn add ha-frp-rn

对等依赖

该模块依赖于以下包:

  • react-native (^0.72.0)
  • ha-shared-core (本地依赖)

使用示例

基本使用

import { createFrpService, FrpConfigType } from 'ha-frp-rn';

// 创建 FRP 服务实例
const frpService = createFrpService();

// 初始化服务
await frpService.initialize();

// 启动 FRP 服务(使用默认配置)
const instanceId = await frpService.start();

// 获取 FRP 状态
const status = await frpService.getStatus(instanceId);

// 停止 FRP 服务
await frpService.stop(instanceId);

自定义配置

import { createFrpService, FrpConfig, FrpConfigType } from 'ha-frp-rn';

const frpService = createFrpService();

// 创建自定义配置
const customConfig: FrpConfig = {
  name: 'custom-config',
  type: FrpConfigType.VISITOR,
  enabled: true,
  visitorConfig: {
    name: 'custom-visitor',
    type: FrpConfigType.VISITOR,
    enabled: true,
    serverAddr: 'your-frps-server.com',
    serverPort: 7000,
    token: 'your-token',
    proxies: [
      // 代理配置
    ]
  }
};

// 使用自定义配置启动
await frpService.start(customConfig);

强制使用远程配置

// 强制从远程API获取配置
const instanceId = await frpService.start(undefined, true);

打包命令

构建模块

npm run build

开发模式(监听文件变化)

npm run build:dev

类型检查

npm run typecheck

代码检查

npm run lint

生成打包文件

npm pack

API 文档

核心类

ReactNativeFrpService

实现了 IFrpService 接口,提供了完整的 FRP 功能:

  • initialize(): 初始化 FRP 服务
  • start(config?: FrpConfig | string, forceRemoteConfig?: boolean): 启动 FRP 服务
  • stop(instanceId?: string): 停止 FRP 服务
  • restart(instanceId: string, forceRemoteConfig?: boolean): 重启 FRP 服务
  • getStatus(instanceId?: string): 获取 FRP 状态
  • getStats(instanceId: string): 获取 FRP 统计信息
  • loadConfig(config: string | FrpConfig): 加载 FRP 配置
  • saveConfig(config: FrpConfig, filePath: string): 保存 FRP 配置
  • validateConfig(config: FrpConfig): 验证 FRP 配置
  • getLogs(instanceId: string, limit?: number, offset?: number): 获取 FRP 日志
  • onLog(instanceId: string, callback: (log: FrpLogEntry) => void): 监听 FRP 日志
  • onStatusChange(callback: (instanceId: string, status: FrpStatus) => void): 监听 FRP 状态变化
  • onError(callback: (instanceId: string, error: Error) => void): 监听 FRP 错误
  • getVersion(): 获取 FRP 版本
  • cleanup(): 清理 FRP 服务资源

FrpConfigManager

用于管理 FRP 配置,支持从远程 API 获取和本地默认配置:

  • getConfig(forceRemote: boolean = false): 获取 FRP 配置
  • clearCache(): 清除配置缓存
  • getLastUpdated(): 获取配置最后更新时间

配置管理

配置优先级

  1. 远程配置:通过 API 请求获取的配置(优先级最高)
  2. 本地默认配置:打包在 assets 目录中的 frpc-visitor-default.toml 文件

默认配置

默认配置文件位于 assets/frpc-visitor-default.toml,包含了基本的 FRP 访问者配置。

平台支持

| 平台 | 状态 | |------|------| | Android | ✅ 支持 | | iOS | ⏳ 开发中 |

开发指南

目录结构

ha-frp-rn/
├── assets/                  # 资源文件目录
│   └── frpc-visitor-default.toml  # 默认 FRP 配置
├── src/                     # 源代码目录
│   ├── index.ts             # 入口文件
│   └── android/             # Android 原生代码
├── .gitignore              # Git 忽略文件
├── package.json            # 项目配置
├── tsconfig.json           # TypeScript 配置
├── tsconfig.build.json     # 构建用 TypeScript 配置
└── README.md               # 项目说明文档

开发流程

  1. 克隆仓库
  2. 安装依赖:npm install
  3. 运行类型检查:npm run typecheck
  4. 构建模块:npm run build
  5. 在 React Native 项目中测试使用

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

联系我们

如有问题或建议,请通过 GitHub Issues 反馈。