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

mobile-dev-proxy

v1.0.0

Published

移动端开发代理工具 - 让手机通过域名访问电脑本地服务

Downloads

3

Readme

Mobile Dev Proxy

npm version license node downloads

🚀 移动端开发代理工具

让手机通过域名访问电脑本地开发服务的专业工具,完美解决移动端开发调试问题。

✨ 特性

  • 🔍 DNS 劫持 - 自动将指定域名解析到本地IP
  • 🔄 HTTP 代理 - 高性能的HTTP请求转发
  • 🌐 多域名支持 - 同时代理多个域名到不同服务
  • ⚙️ 灵活配置 - JSON配置文件,支持热更新
  • 📊 监控日志 - 详细的请求日志和统计信息
  • 🛡️ 安全控制 - IP白名单和访问控制
  • 🎯 零配置启动 - 开箱即用,自动检测网络配置
  • 📱 移动端优化 - 专为移动端开发调试设计

🎯 使用场景

微信开发调试

{
  "name": "test.wechat.com",
  "target": "localhost:8080"
}

多服务调试

{
  "domains": [
    {"name": "app.local", "target": "localhost:3000"},
    {"name": "api.local", "target": "localhost:8080"}
  ]
}

团队协作

让同事的手机访问你的本地服务,无需复杂的网络配置。

🚀 快速开始

全局安装

npm install -g mobile-dev-proxy

基础使用

# 1. 创建配置文件
mdp config

# 2. 启动服务 (需要sudo权限)
sudo mdp start --daemon

# 3. 查看服务状态和IP地址
sudo mdp status

# 4. 手机DNS设置为显示的IP地址
# iOS: 设置 > WiFi > (网络名) > 配置DNS > 手动
# Android: 设置 > WiFi > (网络名) > 修改网络 > 高级选项 > DNS

# 5. 手机访问配置的域名即可

📋 配置说明

基础配置文件

{
  "server": {
    "host": "auto",           // 自动检测或指定IP地址
    "dnsPort": 53,           // DNS服务端口
    "httpPort": 80,          // HTTP代理端口
    "adminPort": 3000        // 管理端口(未来功能)
  },
  "domains": [
    {
      "name": "local.dev",           // 域名
      "target": "localhost:3000",    // 目标服务
      "ssl": false,                  // 是否HTTPS
      "description": "开发服务"       // 描述信息
    }
  ]
}

高级配置

{
  "dns": {
    "upstream": ["8.8.8.8", "114.114.114.114"],  // 上游DNS服务器
    "ttl": 300,                                    // DNS缓存时间
    "cacheSize": 1000                              // 缓存大小
  },
  "proxy": {
    "timeout": 30000,                              // 请求超时时间
    "retries": 3,                                  // 重试次数
    "cors": true,                                  // 启用CORS
    "compression": true                            // 启用压缩
  },
  "security": {
    "allowedIPs": ["192.168.*.*", "10.*.*.*"],    // IP白名单
    "blockPrivateIPs": false,                      // 阻止私有IP
    "rateLimit": {
      "windowMs": 60000,                           // 限流时间窗口
      "max": 1000                                  // 最大请求数
    }
  }
}

🛠️ 命令行工具

服务管理

# 启动服务
mdp start                  # 前台运行
mdp start --daemon         # 后台运行

# 停止服务
mdp stop

# 重启服务
mdp restart

# 查看状态
mdp status

日志管理

# 查看日志
mdp logs                   # 显示最近50行
mdp logs --lines 100       # 显示最近100行
mdp logs --follow          # 实时跟踪日志

配置管理

# 创建配置文件
mdp config

📊 监控与日志

日志级别

  • error - 错误信息
  • warn - 警告信息
  • info - 一般信息
  • debug - 调试信息
  • trace - 详细跟踪

日志示例

[2025-10-15T10:30:45.123Z] [INFO] 🚀 Mobile Dev Proxy starting...
[2025-10-15T10:30:45.456Z] [INFO] 🔍 DNS Server listening on 192.168.1.100:53
[2025-10-15T10:30:45.789Z] [INFO] 🔄 HTTP Proxy Server listening on 192.168.1.100:80
[2025-10-15T10:30:46.012Z] [INFO] GET /api/user 200 150ms [192.168.1.101] iPhone Safari
[2025-10-15T10:30:46.345Z] [DEBUG] DNS Query: app.local (A) -> 192.168.1.100

🔧 故障排除

常见问题

1. 权限错误

# 错误:EACCES: permission denied, bind EADDRINUSE :::53
# 解决:使用sudo运行
sudo mdp start

2. 端口占用

# 错误:EADDRINUSE: address already in use :::80
# 解决:检查端口占用并修改配置
lsof -i :80

3. DNS解析失败

# 检查DNS配置
nslookup test.local 192.168.1.100

# 检查防火墙设置
sudo ufw status

4. 手机无法访问

  • 检查网络连通性:ping 192.168.1.100
  • 检查DNS设置是否正确
  • 确保手机和电脑在同一网络

调试模式

{
  "logs": {
    "level": "debug"
  }
}

🏗️ 工作原理

┌─────────────┐    DNS查询     ┌─────────────┐    转发请求    ┌─────────────┐
│             │ ───────────→   │             │ ───────────→   │             │
│   手机设备   │                │  电脑代理    │                │  本地服务    │
│             │ ←─────────────  │             │ ←─────────────  │             │
└─────────────┘    HTTP响应    └─────────────┘    服务响应    └─────────────┘
  1. DNS劫持: 拦截指定域名的DNS查询,返回电脑IP
  2. HTTP代理: 接收HTTP请求并转发到本地服务
  3. 响应转发: 将本地服务的响应返回给手机

🔧 系统要求

  • Node.js: ≥ 14.0.0
  • 操作系统: macOS / Linux
  • 权限: 需要sudo权限(使用特权端口53和80)
  • 网络: 手机和电脑需在同一WiFi网络

📄 许可证

MIT License

👨‍💻 作者

whpuedison - [email protected]

如果这个项目对你有帮助,请给它一个 ⭐️ (在npm上)