dsh-gemini-guard: A DSH Plugin for Blocking LLM Traffic by Public IP

Introduction

The plugin ecosystem of DeepSeek Harness (DSH) enables fine-grained control at the routing layer. Many third-party model services determine whether to serve a request based on the caller’s public IP address—for example, regional restrictions or enterprise whitelisting. If these routes are directly exposed in DSH and the egress IP is not in the allowlist, you will receive 403 or 502 responses, or even trigger the API provider’s rate-limiting mechanisms. This leads to disrupted development workflows and unstable call chains.

The dsh-gemini-guard plugin provides a “fail-closed” egress gateway. Before a request reaches a downstream vendor, it performs a pre-check based on the caller’s public IP. If the check fails, the request is blocked immediately and never forwarded upstream.

What It Is

dsh-gemini-guard is a DeepSeek Harness plugin that performs egress checks on vendor model routes based on public IP. It is maintained by xyfann and categorized under admin-security. It does not modify the request source IP, nor does it provide proxy or VPN capabilities. Its sole purpose is to ensure that DSH’s egress IP is within the allowlist, and to detect and circuit-break on anomalous signals such as frequent IP switching, datacenter egress, and timezone mismatches.

Core Features

  • Built-in coverage for four vendor routes: gemini, openai, anthropic, grok. These routes are mapped to their corresponding upstream hosts and paths, eliminating the need to maintain a model list.
  • Pre-check rules: verifies whether the egress country is allowed, whether too many distinct egress IPs appeared within a window (indicating jitter), whether the egress is a datacenter or flagged as a proxy, whether the egress timezone matches the declared timezone, whether N probe confirmations have passed, and whether the vendor returned a region-unsupported or invalid-key response.
  • Circuit-breaking mechanism: requests that fail the check are blocked outright; 429/quota/overload responses trigger a cooldown period that lasts until the Retry-After header indicates recovery.
  • Dashboard and control interface: provides an HTML control panel, status queries, settings read/write, re-check, circuit-break reset, and route unloading endpoints.
  • Consistency check: provides a /_gemini-guard/diff endpoint that compares file paths and content hashes across the workspace source, the GitHub repository, and the installed copy to detect whether a reinstall is needed or drift has occurred.

Installation and Enablement

The plugin is distributed as an npm package. The installation command is as follows (from package.json):

npm install dsh-gemini-guard

After installation, enable the plugin in your DSH profile configuration and adjust the pre-check rules and circuit-breaking strategy as needed.

Typical Usage

  • Reference the plugin in DSH’s profile configuration. DSH will route requests to the gateway provided by this plugin, which then forwards them to the vendor.
  • Use _gemini-guard/status to view the current egress IP, circuit-break state for each target, cooldown duration, and counters.
  • Use _gemini-guard/settings to read or write pre-check rule toggles (e.g., egressProbe, reachabilityProbe, riskRules, headerNormalize, promptContext, burstLimit, streamWatch, autoRoute).
  • Use _gemini-guard/diff to check whether the source code matches the installed copy. If drift or installed-stale is detected, you can reinstall.

Applicable Scenarios and Caveats

  • Suitable for scenarios where you need to uniformly manage egress to multiple vendor models within DSH and have strict restrictions on public IP.
  • The plugin runs with the permissions of the current DSH process. Review the source code and license before installation.
  • The plugin does not guarantee account viability. It primarily addresses issues caused by unstable or frequently shifting egress IPs, and does not provide account management or circumvention of restrictions.

Conclusion

dsh-gemini-guard, through pre-checks and circuit-breaking, blocks non-compliant egress IPs before they reach vendor services, making DSH’s LLM routing more controllable and observable. For further details, refer to the plugin directory page and the GitHub repository.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye