moonrepo / proto

A pluggable multi-language version manager.
https://moonrepo.dev/proto
MIT License
678 stars 34 forks source link

Configure DNS server #604

Closed bjoern-reetz closed 1 month ago

bjoern-reetz commented 1 month ago

What version?

0.40.4

Which command?

proto install deno --log trace

What happened?

tl;dr: Proto fails resolving domain names because I must use my corporate's DNS server.

I find proto quite interesting and I am trying to make it work at my corporation. Installing proto works fine but after that, any proto command (which uses internet) is complaining about missing internet connection. The example given is me trying to install deno.

My corporation requires all internet traffic to use my corporate's proxy server for both HTTP and HTTPS traffic. As far as I can tell, proto has good support for configuring my corporate's proxy.

As of my current understanding, the problem is that I cannot use DNS servers other than the one my corporation supplies.

DNS resolution using Google DNS fails:

$ nslookup -port=53 github.com 8.8.8.8
;; connection timed out; no servers could be reached

DNS resolution using my corporate's DNS works:

$ nslookup github.com
Server:         <censored>
Address:        <censored>

Non-authoritative answer:
Name:   github.com
Address: ...

I read through the documentation of proto but could not find anything about how to configure the DNS server that proto uses. Is that already a configurable option? If not, would it be possible to add an option to customize the DNS server that proto uses? (..or to tell proto to use the default one.)

Trace logs?

[DEBUG 2024-09-04 14:41:18.332] proto Running proto v0.40.4 bin="proto" args=["install", "deno", "--log", "trace"] pid=1369735 [TRACE 14:41:18.333] starbase::app Running startup phase [DEBUG 14:41:18.333] proto_core::proto Creating proto environment, detecting store store="/home/breetz/media/remote-dev/proto/" [TRACE 14:41:18.333] starbase::app Running analyze phase [DEBUG 14:41:18.333] proto::systems Loading configuration in upwards mode [DEBUG 14:41:18.333] proto_core::proto_config Loading .prototools file="/home/breetz/.prototools" [TRACE 14:41:18.333] starbase_utils::fs Reading file file="/home/breetz/.prototools" [TRACE 14:41:18.333] schematic::config::loader Loading partial configuration config="ProtoConfig" [TRACE 14:41:18.333] schematic::config::loader Creating layer from source config="ProtoConfig" source="" [TRACE 14:41:18.333] schematic::config::loader Merging partial layers into a final result config="ProtoConfig" [DEBUG 14:41:18.333] proto_core::proto_config Merging loaded configs without global [DEBUG 14:41:18.333] proto_core::proto_config Merged 1 configs [TRACE 14:41:18.333] starbase::app Running execute phase [DEBUG 14:41:18.333] proto::commands::install Loading tool id="deno" [TRACE 14:41:18.333] starbase_utils::net Checking for an internet connection timeout=750 [DEBUG 14:41:18.333] proto_core::tool_loader Finding a configured plugin tool="deno" [DEBUG 14:41:18.333] proto_core::proto_config Merging loaded configs with global [DEBUG 14:41:18.334] proto_core::proto_config Merged 1 configs [DEBUG 14:41:18.334] proto_core::tool_loader Using a built-in plugin plugin="https://github.com/moonrepo/tools/releases/download/deno_tool-v0.12.0/deno_tool.wasm" [TRACE 14:41:18.334] starbase_utils::net::offline Resolving 1.1.1.1:53 [TRACE 14:41:18.334] warpgate::loader Creating plugin loader cache_dir="/home/breetz/media/remote-dev/proto/plugins" [TRACE 14:41:18.334] warpgate::loader Loading plugin deno id="deno" locator="https://github.com/moonrepo/tools/releases/download/deno_tool-v0.12.0/deno_tool.wasm" [TRACE 14:41:18.334] warpgate::loader Plugin not cached, downloading id="deno" [TRACE 14:41:19.085] starbase_utils::net::offline Resolving 1.0.0.1:53 [TRACE 14:41:19.836] starbase_utils::net::offline Resolving 8.8.8.8:53 [TRACE 14:41:20.587] starbase_utils::net::offline Resolving 8.8.4.4:53 [TRACE 14:41:22.089] starbase_utils::net::offline Resolving 216.58.212.174:80

[TRACE 14:41:23.590] starbase_utils::net::offline Resolving 34.107.221.82:80

[TRACE 14:41:25.092] starbase_utils::net::offline Resolving 142.250.186.110:80

[TRACE 14:41:25.843] starbase_utils::net Offline!!! [TRACE 14:41:25.843] starbase::app Running shutdown phase (because another phase failed) Error: plugin::offline

× Unable to download plugin. An internet connection is required to request https://github.com/moonrepo/tools/releases/download/deno_tool-v0.12.0/ │ deno_tool.wasm.

Operating system?

Linux

Architecture?

x64

milesj commented 1 month ago

@bjoern-reetz It's not documented, but you can try using PROTO_OFFLINE_HOSTS env var.

https://github.com/moonrepo/proto/blob/f9e4e9422dea473c7eebd60a6bf9d818137b27a5/crates/core/src/helpers.rs#L27

bjoern-reetz commented 1 month ago

Works like a charm - thank you so much!

bjoern-reetz commented 1 month ago

A quick follow-up question: Am I right that exporting PROTO_OFFLINE=0 would also kind-of solve my issue by skipping this hole is_offline() altogether? Would you advise for/aggainst using it? Are there serious tradeoffs to consider?

(I am asking because it takes a couple of seconds to check all the hosts until finally checking the one supplied by myself - and I'm a little impatient.)

milesj commented 1 month ago

@bjoern-reetz You can do that also. Just be aware that if you're truly offline, some commands will probably just crash with a weird error depending on context. The offline checks short-circuit a bunch of this kind of logic.

milesj commented 1 month ago

It looks like the original hosts are still called, so that's probably what the slowdown is. Let me add a work around for this.

bjoern-reetz commented 1 month ago

Thank you in advance - really appreciate it. I will definetly switch to using offline-hosts then.

milesj commented 1 month ago

Added settings for this, give it a shot. https://moonrepo.dev/docs/proto/config#settingsoffline

bjoern-reetz commented 2 days ago

Sorry that I did not react. Just tried it out - works like a charm. A million thanks!