Documentation
¶
Overview ¶
Package egress finds where this computer's way out to the internet is, through each proxy a Claude subscription's requests go through, and says when it is in a region Anthropic doesn't list as supported (Supported): a proxy that dropped, a VPN turned off, a node in the wrong country (@alterxyz4 on X asked for this "canary").
The lookup asks Cloudflare's trace page (TraceURL) through the same proxy, and reads its loc= line. It never touches Anthropic or the user's account. It runs when magpie starts, when the network or a proxy setting changes, and every Every, never per request (Keep). A lookup that fails says nothing: its state is Unknown, which neither warns nor holds.
Index ¶
Constants ¶
const ( OK = "ok" // in a supported region Unsupported = "unsupported" // in a region the policy doesn't list Unknown = "unknown" // not looked up, or the lookup failed )
The states a way out can be in.
const HeldWords = "magpie held this Claude request"
HeldWords begin every HeldError's text; the gateway reads them as a request that never left (nobody rests for it).
Variables ¶
var ( // Every is how often each choice is looked up again with nothing // changed; Poll how often Keep looks for a change of network or // proxy; Fresh how old an Unsupported may be before Hold looks again. Every = 15 * time.Minute Poll = 20 * time.Second Fresh = 30 * time.Second )
var Client = http.DefaultClient
Client sends the lookup. http.DefaultClient goes through netproxy (netproxy.Install), so the choice With names is the proxy it takes.
var Supported = map[string]string{}/* 185 elements not displayed */
Supported is Anthropic's Supported Regions Policy (https://www.anthropic.com/supported-countries, effective 2026-11-12, read 2026-11-21): every country and region it lists, by ISO 3166-1 code, with the name the page gives. testdata/supported-regions.txt is the page's list as it was read, and a test holds this map to it.
var Timeout = 10 * time.Second
Timeout is how long one lookup may take.
var TraceURL = "https://www.cloudflare.com/cdn-cgi/trace"
TraceURL is the page asked; a test points it at its own server.
Functions ¶
func Hold ¶
Hold is the error a Claude subscription's request through choice is held with: when the user turned the hold on (settings ClaudeRegionHold) and the way out through choice is in an unsupported region. An Unsupported older than Fresh is looked up again first, so a proxy turned back on lets the next request go. Unknown holds nothing.
Types ¶
type HeldError ¶
type HeldError struct{ Result Result }
HeldError is a request Hold kept from going out.
type Result ¶
type Result struct {
State string `json:"state"`
Loc string `json:"loc,omitempty"` // ISO 3166-1 code, as Cloudflare names it
At time.Time `json:"at,omitempty"`
Error string `json:"error,omitempty"`
// Via is the proxy it went through, as magpie may show it
// (netproxy.Redact): "" for the global one, "direct" for none.
Via string `json:"via,omitempty"`
}
Result is what the last lookup through one proxy choice found.