From 2880222bc62197dc591fa02018b48db9be4157d9 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sat, 9 Jul 2022 10:46:15 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=BF=BD=E7=95=A5=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E4=B8=AD=E7=9A=84=E4=BB=A3=E7=90=86=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=20Fix=20https://github.com/siyuan-note/siyuan/issues/?= =?UTF-8?q?5377?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/conf.go | 2 ++ kernel/util/runtime.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/kernel/model/conf.go b/kernel/model/conf.go index efe60d9be..7604ecbb8 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -304,6 +304,8 @@ func InitConf() { Environment: util.Mode, }) } + + util.SetNetworkProxy(Conf.System.NetworkProxy.String()) } var langs = map[string]map[int]string{} diff --git a/kernel/util/runtime.go b/kernel/util/runtime.go index e541f5662..779803f80 100644 --- a/kernel/util/runtime.go +++ b/kernel/util/runtime.go @@ -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) + } +}