Skip to content

Google AI Studio gets SNI‑rewritten → connects directly with Iran IP and gets sanctioned #701

Closed

Description

@TKZ700

When trying to access Google AI Studio (aistudio.google.com) through mhrv-rs, the domain gets SNI‑rewritten (like other Google subdomains). This causes the connection to bypass the proxy tunnel and go directly from my Iran IP address, resulting in a sanctions block.

Expected behavior:
Google AI Studio should be proxied properly so it bypasses sanctions, just like other external sites. [client -> google_script -> cf-worker-node -> website]

Actual behavior:
Because aistudio.google.com is treated as a Google subdomain, mhrv-rs rewrites its SNI to www.google.com. The connection then exits through my direct Iran IP (not through the Apps Script relay) and gets blocked due to sanctions.

Root cause:
The default SNI‑rewrite logic for *.google.com sends these domains through the direct/rewrite tunnel instead of the proxy tunnel.

Proposed solution / request:

Please add a configuration option like:

"include_google_subdomain_proxy_hosts": ["aistudio.google.com"]

This would allow specific Google subdomains to be excluded from SNI rewrite and instead be proxied normally through the Apps Script relay (or exit node), so they can bypass sanctions.

Activity

  1. therealaleph commented on May 4, 2026

    @therealaleph
    Owner

    @(author) — accurate diagnosis but the "proxy tunnel" you have in mind doesn't exist for Google domains. Two facts:

    1. SNI rewrite doesn't hide your IP, just your SNI. When mhrv-rs SNI-rewrites aistudio.google.com to www.google.com, it still TCP-connects to Google's edge IP from your machine's IP. Google's edge sees your real Iran IP. The SNI rewrite only hides the destination hostname from your ISP's DPI — it doesn't proxy the connection through Google.

    2. Apps Script can't relay Google services (self-loop block). If we routed aistudio.google.com through the Apps Script relay (= what your cf-worker-node mental model does), Apps Script's UrlFetchApp.fetch() to aistudio.google.com returns Exception: DNS Hatası — Google blocks Apps Script from reaching its own services. Same root cause as why YouTube videos can't go through the relay.

    Solution: exit-node. The path that works is client → Apps Script (Google datacenter IP) → val.town (non-Google, non-Iran IP) → aistudio.google.com. The destination sees val.town's IP, which is neither Iran nor Google — sanction check passes, anti-bot doesn't fire.

    Setup steps: assets/exit_node/README.fa.md. 5 minutes, free tier. Then in config.json:

    "exit_node": {
      "enabled": true,
      "relay_url": "https://your-handle-mhrv.web.val.run",
      "psk": "<openssl rand -hex 32>",
      "mode": "selective",
      "hosts": ["aistudio.google.com", "ai.google.dev", "chatgpt.com", "claude.ai"]
    }

    When aistudio.google.com is in exit_node.hosts, mhrv-rs bypasses the SNI-rewrite path for that host and sends it through the exit node instead — exactly what you wanted, just via existing config rather than a new flag.

    I'll add aistudio.google.com + ai.google.dev to the example config. No code change needed — the routing is already in place. Closing as resolved by exit-node.


    [reply via Anthropic Claude | reviewed by @therealaleph]

  2. TKZ700 commented on May 4, 2026

    @TKZ700
    Author

    Hi, thank you for the recent changes. The setup works perfectly in full_node mode with an exit node.

    However, when using the Google Script -> CF Worker flow (i.e., running the app in app_script mode), Google hosts cannot be proxied as expected.

    The root cause:
    In app_script mode, all Google subdomains have their SNI rewritten by default. This becomes problematic when trying to reach Google AI Studio because we are connecting to it with our real IP from Iran which will be blocked. so we can bypass the sanctions by connecting to it through app_script proxy, not directly from the Google Script itself, but when a Cloudflare Worker is used as the endpoint of the chain (via Code.cfw.gs).

    To successfully connect to Google AI Studio through the app_script -> CF Worker chain, we need to bypass SNI rewriting for certain Google subdomains, so they can be properly proxied and thus circumvent sanctions.

    Proposed fix:
    Add an EXCLUDE_SNI_REWRITE_SUBDOMAINS_LIST configuration option to app_script mode. This would allow users to specify addresses like Google AI Studio, ensuring they are proxied through the Google Script -> CF Worker pipeline without SNI modification.

    Looking forward to your thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions