🎨 忽略环境变量中的代理设置 Fix https://github.com/siyuan-note/siyuan/issues/5377

This commit is contained in:
Liang Ding 2022-07-09 10:46:15 +08:00
parent 289d7e820b
commit 2880222bc6
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 16 additions and 0 deletions

View file

@ -304,6 +304,8 @@ func InitConf() {
Environment: util.Mode,
})
}
util.SetNetworkProxy(Conf.System.NetworkProxy.String())
}
var langs = map[string]map[int]string{}

View file

@ -17,6 +17,7 @@
package util
import (
"os"
"reflect"
"runtime"
"sync"
@ -74,3 +75,16 @@ func GetDeviceID() string {
}
return gulu.Rand.String(12)
}
func SetNetworkProxy(proxyURL string) {
if err := os.Setenv("HTTPS_PROXY", proxyURL); nil != err {
logger.Errorf("set env [HTTPS_PROXY] failed: %s", err)
}
if err := os.Setenv("HTTP_PROXY", proxyURL); nil != err {
logger.Errorf("set env [HTTP_PROXY] failed: %s", err)
}
if "" != proxyURL {
logger.Infof("use network proxy [%s]", proxyURL)
}
}