Skip to content
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

不支持设置代理 #96

Open
AuroraXXXX opened this issue Jun 18, 2024 · 6 comments
Open

不支持设置代理 #96

AuroraXXXX opened this issue Jun 18, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@AuroraXXXX
Copy link

应用本身应该支持代理的设置,否则在某些局域网情况下,无法获取信息

@1111mp
Copy link
Owner

1111mp commented Jun 18, 2024

代理跟nvm-desktop之间没什么关系 开启代理之后更新数据导致访问不了(比如SSL证书报错) 这个取决于你的代理节点和协议(是否是tls加密,tls加密的话你的节点就需要域名) 就算你的代理使用了域名+tls 但是有可能该域名(或者使用了cdn节点)已经被目标服务器加入黑名单(或者通过流量嗅探这种) 这样你也访问不了 这个是网络的问题

我认为你应该去系统的网络设置里添加代理 而不是nvm-desktop中设置代理

@1111mp 1111mp added the enhancement New feature or request label Jun 22, 2024
@1111mp
Copy link
Owner

1111mp commented Jun 26, 2024

我最近在尝试使用 tauri 来重写客户端,发现这个确实可以在客户端来实现(rust中实现简单很多),大概的代码(以获取所有版本列表的接口来举例):

pub async fn version_list(fetch: Option<bool>) -> Result<Option<Vec<NVersion>>> {
    let fetch = fetch.unwrap_or(false);
    if !fetch {
        // return existing data directly
        return Ok(Config::node().latest().get_list());
    }

    let mirror = Config::settings().data().get_mirror();
    if mirror.is_none() {
        bail!("mirror should not be null");
    }

    // fetch list data from remotefetch data from remote
    // 这是不使用代理(系统代理模式下生效 如果开启了 TUN 模式则无效 还是会走代理)
    let list = reqwest::ClientBuilder::new()
        .use_rustls_tls()
        .no_proxy()
        .build()?
        .get(format!("{}/index.json", mirror.unwrap()))
        .send()
        .await?
        .json::<Vec<NVersion>>()
        .await?;
    // update list
    Config::node().data().update_list(&list)?;
    
    // 这是使用自定义代理的情况
    let mut builder = reqwest::ClientBuilder::new().use_rustls_tls().no_proxy();
    // 假设配置的代理服务器ip为 127.0.0.1 port为 8080 
    let proxy_scheme = format!("http:https://127.0.0.1:8080");
    if let Ok(proxy) = reqwest::Proxy::http(&proxy_scheme) {
        builder = builder.proxy(proxy);
    }
    if let Ok(proxy) = reqwest::Proxy::https(&proxy_scheme) {
        builder = builder.proxy(proxy);
    }
    if let Ok(proxy) = reqwest::Proxy::all(&proxy_scheme) {
        builder = builder.proxy(proxy);
    }
    let list = builder
        .build()?
        .get(format!("{}/index.json", &mirror))
        .send()
        .await?
        .json::<Vec<NVersion>>()
        .await?;

    Ok(Some(list))
}

如果使用 tauri 重构的过程顺利的话,会把这个功能加上的 谢谢理解 🌹

@BG7ZAG
Copy link

BG7ZAG commented Jun 28, 2024

我最近在尝试使用 tauri 来重写客户端,发现这个确实可以在客户端来实现(rust中实现简单很多),大概的代码(以获取所有版本列表的接口来举例):

pub async fn version_list(fetch: Option<bool>) -> Result<Option<Vec<NVersion>>> {
    let fetch = fetch.unwrap_or(false);
    if !fetch {
        // return existing data directly
        return Ok(Config::node().latest().get_list());
    }

    let mirror = Config::settings().data().get_mirror();
    if mirror.is_none() {
        bail!("mirror should not be null");
    }

    // fetch list data from remotefetch data from remote
    // 这是不使用代理(系统代理模式下生效 如果开启了 TUN 模式则无效 还是会走代理)
    let list = reqwest::ClientBuilder::new()
        .use_rustls_tls()
        .no_proxy()
        .build()?
        .get(format!("{}/index.json", mirror.unwrap()))
        .send()
        .await?
        .json::<Vec<NVersion>>()
        .await?;
    // update list
    Config::node().data().update_list(&list)?;
    
    // 这是使用自定义代理的情况
    let mut builder = reqwest::ClientBuilder::new().use_rustls_tls().no_proxy();
    // 假设配置的代理服务器ip为 127.0.0.1 port为 8080 
    let proxy_scheme = format!("http:https://127.0.0.1:8080");
    if let Ok(proxy) = reqwest::Proxy::http(&proxy_scheme) {
        builder = builder.proxy(proxy);
    }
    if let Ok(proxy) = reqwest::Proxy::https(&proxy_scheme) {
        builder = builder.proxy(proxy);
    }
    if let Ok(proxy) = reqwest::Proxy::all(&proxy_scheme) {
        builder = builder.proxy(proxy);
    }
    let list = builder
        .build()?
        .get(format!("{}/index.json", &mirror))
        .send()
        .await?
        .json::<Vec<NVersion>>()
        .await?;

    Ok(Some(list))
}

如果使用 tauri 重构的过程顺利的话,会把这个功能加上的 谢谢理解 🌹

tauri 坑多不?

@1111mp
Copy link
Owner

1111mp commented Jun 28, 2024

tauri 坑多不?

@BG7ZAG 目前还处于在tauri这边实现对应功能的阶段,整个开发的感受还是挺好的(vscode代码调试方面可能不是那么友好~),得益于rust,性能确实得到了很大程度的提升,主要是 rust 写起来代码确实很优雅。不过应用的打包发布和更新这块还没开始,应该会是有一些坑的,不过期间也研究了一些开源的tauri的项目,都有各自的解决方案,所以觉得使用tauri替代electron是可行的。

(目前使用的是 tauri 的 v2 beta 版本,相较于 v1,IPC通信的性能得到了非常大的提升...)

后续我会新建一个分支,把这周的进度代码上传上去,如果你有兴趣也可以一起看看~ 👍

@1111mp
Copy link
Owner

1111mp commented Jun 28, 2024

@BG7ZAG 代码已经上传到 tauri 分支

@BG7ZAG
Copy link

BG7ZAG commented Jun 28, 2024

tauri 坑多不?

@BG7ZAG 目前还处于在tauri这边实现对应功能的阶段,整个开发的感受还是挺好的(vscode代码调试方面可能不是那么友好~),得益于rust,性能确实得到了很大程度的提升,主要是 rust 写起来代码确实很优雅。不过应用的打包发布和更新这块还没开始,应该会是有一些坑的,不过期间也研究了一些开源的tauri的项目,都有各自的解决方案,所以觉得使用tauri替代electron是可行的。

(目前使用的是 tauri 的 v2 beta 版本,相较于 v1,IPC通信的性能得到了非常大的提升...)

后续我会新建一个分支,把这周的进度代码上传上去,如果你有兴趣也可以一起看看~ 👍

@BG7ZAG 代码已经上传到 tauri 分支

好勒,感谢,学习学习tauri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants