Documentation
¶
Overview ¶
Package netproxy decides which proxy magpie's own requests to vendors go through. An app started from the Dock or the Start menu has no HTTPS_PROXY in its environment, so without this every call to a vendor that is only reachable through a proxy hangs until the agent gives up.
In order: the proxy set in magpie's settings (or "direct" for none), the usual *_PROXY variables, then the system's proxy (macOS network settings, Windows Internet Options). Loopback is never proxied.
Index ¶
- func Choice(ctx context.Context) string
- func Describe() (proxy, source string)
- func Dispatch(base *http.Transport) http.RoundTripper
- func Env(env []string) []string
- func EnvWith(choice string, env []string) []string
- func For(u *url.URL) (*url.URL, error)
- func Func(req *http.Request) (*url.URL, error)
- func Install()
- func Parse(s string) (*url.URL, error)
- func With(ctx context.Context, choice string) context.Context
- type Proxy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Choice ¶ added in v0.1.427
Choice is the proxy ctx names (With), "" when it names none — for a CLI run on a provider's behalf, whose *_PROXY is set from it (EnvWith).
func Describe ¶
func Describe() (proxy, source string)
Describe says, for the settings page, what a request to u would use.
func Dispatch ¶ added in v0.1.418
func Dispatch(base *http.Transport) http.RoundTripper
Dispatch is a RoundTripper sending a request through base, unless its context names a provider's own proxy (With): then through a clone of base kept for that proxy alone. Connections are so reused among the requests going through one proxy and never carried to another — HTTP/2 ones, which a transport shares by host whatever proxy they were dialled through, among them.
func Env ¶ added in v0.1.53
Env is env (the process's own when nil) for an agent's CLI that magpie starts — a sign-in, or a subscription's run — told to use the proxy magpie's own requests would: the CLI reads only *_PROXY, which an app started from the Dock or the Start menu doesn't have, so a proxy set in magpie or the system's alone left it trying the vendor directly. A proxy set in magpie replaces any in env and "direct" drops them; the system's is only added where env names none. Loopback never goes through it, since a CLI calls back to magpie there.
func EnvWith ¶ added in v0.1.418
EnvWith is Env for a CLI run on one provider's behalf, whose own proxy is choice (see With): "" is Env's.
func Func ¶
Func is an http.Transport Proxy function: the proxy the request's context names (With), or else the global one.
func Install ¶
func Install()
Install routes http.DefaultTransport (and so http.DefaultClient) through Func, and http.DefaultClient's requests made on a provider's behalf (With) through a transport of that provider's proxy (Dispatch).
func With ¶ added in v0.1.418
With is ctx for requests made on behalf of one provider, whose own proxy is choice (issue #237: Codex through a proxy, a vendor at home without): "" follows the global one (ctx is returned as it is), "direct" goes through none, anything else is the proxy's address (http://, https://, socks5://; host:port means http). Requests made with it through Func, or through a transport Dispatch made, take that proxy.