zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
42.58k stars 2.27k forks source link

Global socks5/http/https proxy support #14036

Closed Zicar491 closed 1 week ago

Zicar491 commented 2 weeks ago

Check for existing issues

Describe the feature

The editor seems pretty awesome and I'd like to try and switch to it but one of the systems I use is a windows computer on an isolated network without any internet connectivity except for a temporary socks5 proxy.

I know I can simply install all extensions that I need on a computer with internet access and move them over, but a better suited approach would be to have a few config lines for a proxy and have all the requests go through there when enabled.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

JunkuiZhang commented 2 weeks ago

It's already supported. You can set a proxy by setting the following in your settings.json:

"proxy": "socks5://127.0.0.1:10808",
notpeter commented 2 weeks ago

For future reference this you can see this by opening the command palette (cmd+shift+p or ctrl+shift+p) and searching for zed: default settings:

https://github.com/zed-industries/zed/blob/95637a032028a5225dc2e39c8b6e0f35365eba50/assets/settings/default.json#L910-L922

KiraTheGenius commented 2 weeks ago

I set this but nothing change!!

{
  "ui_font_size": 18,
  "buffer_font_size": 16,
  "theme": {
    "mode": "system",
    "light": "One Light",
    "dark": "Andromeda"
  },
  "proxy": "http://127.0.0.1:2082"
}

when I use curl in terminal nothing changed!!!!

notpeter commented 2 weeks ago

The proxy setting only applies to Zed and it's network calls. You will have to set environment variables for other programs run under terminal separately.

Looking at the curl proxy docs I think it's something like:

export ALL_PROXY="socks5h://127.0.0.1:2082"
curl https://zed.dev
Vzhangs commented 1 week ago

same problem as you. I tried all_proxy=socks5://127.0.0.1:7890 zed <myproject>, set "proxy": "socks5://127.0.0.1: 7890" in setting.json . I'm sure the proxy setting is not working

JunkuiZhang commented 1 week ago

same problem as you. I tried all_proxy=socks5://127.0.0.1:7890 zed <myproject>, set "proxy": "socks5://127.0.0.1: 7890" in setting.json . I'm sure the proxy setting is not working

Zed does NOT set the system proxy for you. The "proxy" setting in settings.json is only used by Zed itself. If you want other applications to use a proxy, please refer to their documentation.

For example, to use rustup through a proxy, you should create a configuration file ~/.cargo/config.toml and insert the following:

[http]
proxy = "socks5://localhost:10808"
Vzhangs commented 1 week ago

same problem as you. I tried all_proxy=socks5://127.0.0.1:7890 zed <myproject>, set "proxy": "socks5://127.0.0.1: 7890" in setting.json . I'm sure the proxy setting is not working

Zed does NOT set the system proxy for you. The "proxy" setting in settings.json is only used by Zed itself. If you want other applications to use a proxy, please refer to their documentation.

For example, to use rustup through a proxy, you should create a configuration file ~/.cargo/config.toml and insert the following:

[http]
proxy = "socks5://localhost:10808"

I can't get into the extensions market, and my authentication isn't working in application, and the auto update keeps failing. I guess this is a job with the Zed itself.

截屏2024-07-17 21 13 40 截屏2024-07-17 21 04 02
notpeter commented 1 week ago

Are you on a truly isolated network without functioning DNS? It appears you keep using socks5 instead of socks5h -- I believe the latter is required if you need the SOCKS proxy to handle host resolution. Can you try that and report back?

JunkuiZhang commented 1 week ago

set "proxy": "socks5://127.0.0.1: 7890" in setting.json . I'm sure the proxy setting is not working

Your settings socks5://127.0.0.1: 7890 has a wihtespace, is this what you are using right now? Try remove that whitespace, or try to use a http proxy: http://127.0.0.1:7890

Vzhangs commented 1 week ago

set "proxy": "socks5://127.0.0.1: 7890" in setting.json . I'm sure the proxy setting is not working

Your settings socks5://127.0.0.1: 7890 has a wihtespace, is this what you are using right now? Try remove that whitespace, or try to use a http proxy: http://127.0.0.1:7890

It was a typing mistik. There's no space in the actual configuration.

Vzhangs commented 1 week ago

Are on a truly isolated network without functioning DNS? It appears you keep using socks5 instead of socks5h -- I believe the latter is required if you need the SOCKS proxy to handle host resolution. Can you try that and report back?

I'll check on it in the next few days and report back

Vzhangs commented 1 week ago

It appears to be an issue of the timeout setting being set too short. When I use a cross-country network proxy, I encounter higher network latency, which usually reaches seconds. I modified the timeout configuration and rebuild zed, the problem was resolved.

notpeter commented 1 week ago

@Vzhangs Glad to hear it. For the benefit of future searchers which timeout did you modify, CONNECTION_TIMEOUT in crates/client/src/client.rs?

https://github.com/zed-industries/zed/blob/4852e170ffd63532bc751da8ecc3cae05056586c/crates/client/src/client.rs#L89-L92

Vzhangs commented 1 week ago

@notpeter In here

https://github.com/zed-industries/zed/blob/4852e170ffd63532bc751da8ecc3cae05056586c/crates/http/src/http.rs#L189-L198

Modifying these two configurations allowed my zed to auto update and access the extension market, but it still didn't solve the problem of not being able to sign in, which still showing time out.

JunkuiZhang commented 1 week ago

but it still didn't solve the problem of not being able to sign in, which still showing time out.

The first login attempt shows a timeout, then it retries with the proxy. On my Windows and macOS builds with a proxy server located in New York, USA (with a 600ms lag), the login process can take 1-2 minutes.

Additionally, on Discord, someone using an isolated network was able to log in through a proxy, so I think the functionality is working correctly.

Screenshot 2024-07-18 182231

Vzhangs commented 1 week ago

but it still didn't solve the problem of not being able to sign in, which still showing time out.

The first login attempt shows a timeout, then it retries with the proxy. On my Windows and macOS builds with a proxy server located in New York, USA (with a 600ms lag), the login process can take 1-2 minutes.

Additionally, on Discord, someone using an isolated network was able to log in through a proxy, so I think the functionality is working correctly.

Screenshot 2024-07-18 182231

Correct, there should be no problem with the proxy function, it should be my network delay is too high