fakeip-compat
其他 活跃维护

fakeip-compat

iwinoid/fakeip-compat

在Mihomo/Clash TUN网络环境下,提供兼容Fake-IP的web.fetch数据源,自动识别假IP并回源真实地址,同时固定局域网CIDR放行,避免策略误伤,确保动态规则稳定拉取。

0
Stars 标星
0
Forks 分支
0
Watchers 关注
0
Open Issues
JavaScript
主要语言
MIT
开源协议
74 KB
仓库大小
1 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:iwinoid/fakeip-compat
git clone https://github.com/iwinoid/fakeip-compat.git
git clone git@github.com:iwinoid/fakeip-compat.git
README.md main

fakeip-compat

standard-readme compliant
License: MIT
topic: dsh-plugin
powered by dsh

[!WARNING]
Personal-use project. It is built and tested for my own machine and workflow only; I do not guarantee it works on other DSH versions, platforms or setups. Review the code first and use it at your own risk.

Fake-IP-aware web.fetch provider for TUN (Mihomo/Clash) DNS environments plus pinned LAN CIDR access

Table of Contents

Background

The stock http fetch provider guards against SSRF. It rejects any hostname that resolves to a non-public address. Under a TUN proxy with Fake-IP DNS (Mihomo/Clash), every public site resolves to a fake address such as 198.18.0.11. The guard then rejects all of them, although the traffic itself works. Local LAN debugging hits the same wall from the other side.

An earlier v1 approach patched web.fetch directly and shelled out to curl/getent. That bypassed the provider registry, hid from --dump-config, allowed command injection through the model-controlled URL, and validated with one resolver while transporting through another. v2 drops all of that. It registers a real provider through ctx.web.registerFetchProvider, uses only node:dns/promises plus undici (no shell, no subprocess), throws the stock WebError codes, and transports only to DoH-validated addresses.

Install

Dependencies

Runtime dependencies install with the package (@deepseek-ai/schemastery, ipaddr.js, undici, plus the DSH peers). A TUN proxy is only needed for the Fake-IP path. The LAN path needs no proxy.

dsh plugin --profile web add github:iwinoid/fakeip-compat

Local development uses a link install instead:

dsh plugin --profile web add link:/path/to/fakeip-compat

The package has no build step, so a git install needs no allowBuilds exception.

This package only registers the provider. It never selects itself. The official multi-provider rule applies: without an explicit choice the seam reports WEB_PROVIDER_AMBIGUOUS. Point the web seam at it from the profile layer:

- id: web
  name: '@deepseek-ai/dsh-web'
  config:
    searchProvider: deepseek-official   # keep your existing search choice, never drop it
    fetchProvider: fakeip-http

A patch replaces the whole row config, so always restate searchProvider next to fetchProvider. Or select per process:

DSH_WEB_FETCH_PROVIDER=fakeip-http

Verify after the change:

dsh --profile <name> --dump-config | grep -A8 fakeip

Usage

Configuration

Key Default Notes
lanCidr 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10 LAN allowlist (comma/whitespace separated): all RFC1918 ranges plus Tailscale CGNAT. System-resolved results inside it transport pinned. Tradeoff: broader than strictly-LAN (notably 100.64/10, which ISPs also use) — a hostile DNS answer inside these ranges would be fetched rather than refused. lanInsecure: false keeps TLS verification on the LAN path.
fakeV4Cidr / fakeV6Cidr 198.18.0.0/16 / 2001:2::/48, fdfe:dcba:9876::/48 Local Fake-IP pools. Each accepts a comma/whitespace separated CIDR list — one stack may answer several pools (Mihomo commonly returns 198.18.0.0/16 for A and 2001:2::/48 for AAAA). Match them to the Clash Verge fake-ip-range / fake-ip-range6.
dohEndpoints https://1.1.1.1/dns-query, https://8.8.8.8/resolve Trusted DoH (JSON API). Every entry must be an https:// URL whose host is an IP literal (hostnames are rejected at boot and by the settings UI); first fully successful endpoint wins.
dohTimeoutMs 8000 Budget for one DoH lookup. Must be a positive integer no greater than 2147483647 (Node's timer limit); larger values are rejected at boot.
lanInsecure false Skip TLS check on the LAN path only. Turn it on for self-signed devices.
maxResponseBytes / maxBodyChars / timeoutMs / maxRedirects / userAgent 5000000 / 100000 / 30000 / 5 / official UA Same meaning as the official provider.

Settings UI

The plugin declares every field volatile, so edits apply live with no restart and no remount: the row's page on the Plugins page edits the active profile entry, and loader/volatile-update swaps the runtime. A live edit is merged field by field: invalid fields keep their previous values while valid fields in the same save take effect, so one bad entry cannot discard the whole edit; boot-time validation stays strict and a broken composition entry still fails loud. Each fetch reads one consistent runtime snapshot. The card (lib/client.js, hand-written, no build step) registers into plugins.row.config for fakeip-compat#web-fetch-fakeip-compat while the Host serves the entry.

API

Provider id: fakeip-http. Select it through web.fetchProvider or DSH_WEB_FETCH_PROVIDER.

The contract has two green lights and keeps the stock denial for the rest:

  1. TUN Fake-IP path. When system resolution returns a fake address, the provider re-checks the name over trusted DoH, then pins transport to the DoH-validated real address set with the official pin mechanism. No second resolution happens at transport time.
  2. LAN path. System-resolved results inside lanCidr transport pinned, with TLS checks kept by default.

Everything else keeps the official http provider refusal meaning and error codes: other private ranges, mixed answers (fake plus real together), hosts-pinned names outside the LAN allowlist, and non-allowlisted literals. A hosts entry that pins a name to LAN stays pinned. The provider never bypasses it through DoH.

Maintainers

Contributing

Bug reports and questions are welcome on the GitHub Issues page. Pull requests are accepted. The browser card is hand-written with no build step. Keep it that way.

License

MIT © iwinoid