summaryrefslogtreecommitdiff
path: root/packages/cli/src/gemini.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/gemini.tsx')
-rw-r--r--packages/cli/src/gemini.tsx23
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/cli/src/gemini.tsx b/packages/cli/src/gemini.tsx
index 73f3fdd0..48dbd271 100644
--- a/packages/cli/src/gemini.tsx
+++ b/packages/cli/src/gemini.tsx
@@ -12,9 +12,11 @@ import { readStdin } from './utils/readStdin.js';
import { basename } from 'node:path';
import v8 from 'node:v8';
import os from 'node:os';
+import dns from 'node:dns';
import { spawn } from 'node:child_process';
import { start_sandbox } from './utils/sandbox.js';
import {
+ DnsResolutionOrder,
LoadedSettings,
loadSettings,
SettingScope,
@@ -44,6 +46,23 @@ import { checkForUpdates } from './ui/utils/updateCheck.js';
import { handleAutoUpdate } from './utils/handleAutoUpdate.js';
import { appEvents, AppEvent } from './utils/events.js';
+export function validateDnsResolutionOrder(
+ order: string | undefined,
+): DnsResolutionOrder {
+ const defaultValue: DnsResolutionOrder = 'ipv4first';
+ if (order === undefined) {
+ return defaultValue;
+ }
+ if (order === 'ipv4first' || order === 'verbatim') {
+ return order;
+ }
+ // We don't want to throw here, just warn and use the default.
+ console.warn(
+ `Invalid value for dnsResolutionOrder in settings: "${order}". Using default "${defaultValue}".`,
+ );
+ return defaultValue;
+}
+
function getNodeMemoryArgs(config: Config): string[] {
const totalMemoryMB = os.totalmem() / (1024 * 1024);
const heapStats = v8.getHeapStatistics();
@@ -138,6 +157,10 @@ export async function main() {
argv,
);
+ dns.setDefaultResultOrder(
+ validateDnsResolutionOrder(settings.merged.dnsResolutionOrder),
+ );
+
if (argv.promptInteractive && !process.stdin.isTTY) {
console.error(
'Error: The --prompt-interactive flag is not supported when piping input from stdin.',