Repository navigation
fix(cli): 代理回环直连、无法解析时不中断、空大写变量回退(0.9.2) #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
compose/src/commonMain/kotlin/app/tinyui/generated/RuntimeBytecode.kt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,35 @@ | ||
| const PROXY_ENV = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"] as const; | ||
| /** The loopback hosts `requireSecureUrl` accepts over plain http, in the form undici's NO_PROXY matching expects. */ | ||
| const LOOPBACK = ["localhost", "127.0.0.1", "[::1]"]; | ||
|
|
||
| /** | ||
| * Node's built-in fetch ignores the proxy environment variables that curl, npm and pnpm honour (unless the process was | ||
| * started with NODE_USE_ENV_PROXY), so behind a proxy every command that talks to the updates server fails with | ||
| * "fetch failed". When one is set, route the global fetch through undici's EnvHttpProxyAgent, which also reads NO_PROXY. | ||
| * undici is imported only then: environments without a proxy, such as reproducible builds, never load it. | ||
| * | ||
| * Loopback always goes direct: a local instance would be unreachable through the proxy, and over plain http the proxy | ||
| * would see the bearer token. A proxy setting the agent rejects is reported and skipped rather than failing the | ||
| * command, so offline commands (build, bundle, schema) keep working. | ||
| */ | ||
| export async function useEnvProxy(env: NodeJS.ProcessEnv = process.env): Promise<boolean> { | ||
| if (!PROXY_ENV.some((name) => env[name])) return false; | ||
| const { EnvHttpProxyAgent, setGlobalDispatcher } = await import("undici"); | ||
| const httpProxy = env.HTTP_PROXY ?? env.http_proxy; | ||
| const httpsProxy = env.HTTPS_PROXY ?? env.https_proxy; | ||
| const noProxy = env.NO_PROXY ?? env.no_proxy; | ||
| setGlobalDispatcher(new EnvHttpProxyAgent({ | ||
| ...(httpProxy !== undefined && { httpProxy }), | ||
| ...(httpsProxy !== undefined && { httpsProxy }), | ||
| ...(noProxy !== undefined && { noProxy }), | ||
| })); | ||
| return true; | ||
| // `||`, not `??`: an empty uppercase variable must not hide a configured lowercase one | ||
| const httpProxy = env.HTTP_PROXY || env.http_proxy; | ||
| const httpsProxy = env.HTTPS_PROXY || env.https_proxy; | ||
| if (!httpProxy && !httpsProxy) return false; | ||
| const noProxy = [env.NO_PROXY || env.no_proxy, ...LOOPBACK].filter(Boolean).join(","); | ||
| let undici: typeof import("undici") | undefined; | ||
| try { | ||
| undici = await import("undici"); | ||
| undici.setGlobalDispatcher(new undici.EnvHttpProxyAgent({ | ||
| ...(httpProxy ? { httpProxy } : {}), | ||
| ...(httpsProxy ? { httpsProxy } : {}), | ||
| noProxy, | ||
| })); | ||
| return true; | ||
| } catch (e) { | ||
| // make "directly" true even if an earlier call had installed a proxy | ||
| undici?.setGlobalDispatcher(new undici.Agent()); | ||
| process.stderr.write(`tinyui: ignoring the proxy settings (${e instanceof Error ? e.message : String(e)}); connecting directly\n`); | ||
| return false; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| /** The tinyui-core version; a package records it as the runtime it needs (docs/updates.md §1.1). */ | ||
| export const VERSION = "0.9.1"; | ||
| export const VERSION = "0.9.2"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.