mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
♻️ 重构内核代理设置 Fix https://github.com/siyuan-note/siyuan/issues/5380
This commit is contained in:
parent
2880222bc6
commit
70b8a7d8eb
16 changed files with 89 additions and 93 deletions
|
|
@ -54,17 +54,17 @@ type Icon struct {
|
|||
Downloads int `json:"downloads"`
|
||||
}
|
||||
|
||||
func Icons(proxyURL string) (icons []*Icon) {
|
||||
func Icons() (icons []*Icon) {
|
||||
icons = []*Icon{}
|
||||
result, err := util.GetRhyResult(false, proxyURL)
|
||||
result, err := util.GetRhyResult(false)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
bazaarIndex := getBazaarIndex(proxyURL)
|
||||
bazaarIndex := getBazaarIndex()
|
||||
bazaarHash := result["bazaar"].(string)
|
||||
result = map[string]interface{}{}
|
||||
request := httpclient.NewBrowserRequest(proxyURL)
|
||||
request := httpclient.NewBrowserRequest()
|
||||
u := util.BazaarOSSServer + "/bazaar@" + bazaarHash + "/stage/icons.json"
|
||||
resp, err := request.SetResult(&result).Get(u)
|
||||
if nil != err {
|
||||
|
|
@ -86,7 +86,7 @@ func Icons(proxyURL string) (icons []*Icon) {
|
|||
|
||||
icon := &Icon{}
|
||||
innerU := util.BazaarOSSServer + "/package/" + repoURL + "/icon.json"
|
||||
innerResp, innerErr := httpclient.NewBrowserRequest(proxyURL).SetResult(icon).Get(innerU)
|
||||
innerResp, innerErr := httpclient.NewBrowserRequest().SetResult(icon).Get(innerU)
|
||||
if nil != innerErr {
|
||||
util.LogErrorf("get bazaar package [%s] failed: %s", repoURL, innerErr)
|
||||
return
|
||||
|
|
@ -126,9 +126,9 @@ func Icons(proxyURL string) (icons []*Icon) {
|
|||
return
|
||||
}
|
||||
|
||||
func InstallIcon(repoURL, repoHash, installPath, proxyURL string, chinaCDN bool, systemID string) error {
|
||||
func InstallIcon(repoURL, repoHash, installPath string, chinaCDN bool, systemID string) error {
|
||||
repoURLHash := repoURL + "@" + repoHash
|
||||
data, err := downloadPackage(repoURLHash, proxyURL, chinaCDN, true, systemID)
|
||||
data, err := downloadPackage(repoURLHash, chinaCDN, true, systemID)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ import (
|
|||
"golang.org/x/text/transform"
|
||||
)
|
||||
|
||||
func GetPackageREADME(repoURL, repoHash, proxyURL string, chinaCDN bool, systemID string) (ret string) {
|
||||
func GetPackageREADME(repoURL, repoHash string, chinaCDN bool, systemID string) (ret string) {
|
||||
repoURLHash := repoURL + "@" + repoHash
|
||||
data, err := downloadPackage(repoURLHash+"/README.md", proxyURL, chinaCDN, false, systemID)
|
||||
data, err := downloadPackage(repoURLHash+"/README.md", chinaCDN, false, systemID)
|
||||
if nil != err {
|
||||
ret = "Load bazaar package's README.md failed: " + err.Error()
|
||||
return
|
||||
|
|
@ -74,7 +74,7 @@ func GetPackageREADME(repoURL, repoHash, proxyURL string, chinaCDN bool, systemI
|
|||
return
|
||||
}
|
||||
|
||||
func downloadPackage(repoURLHash, proxyURL string, chinaCDN, pushProgress bool, systemID string) (data []byte, err error) {
|
||||
func downloadPackage(repoURLHash string, chinaCDN, pushProgress bool, systemID string) (data []byte, err error) {
|
||||
// repoURLHash: https://github.com/88250/Comfortably-Numb@6286912c381ef3f83e455d06ba4d369c498238dc
|
||||
pushID := repoURLHash[:strings.LastIndex(repoURLHash, "@")]
|
||||
repoURLHash = strings.TrimPrefix(repoURLHash, "https://github.com/")
|
||||
|
|
@ -83,14 +83,14 @@ func downloadPackage(repoURLHash, proxyURL string, chinaCDN, pushProgress bool,
|
|||
u = util.BazaarOSSServer + "/package/" + repoURLHash
|
||||
}
|
||||
buf := &bytes.Buffer{}
|
||||
resp, err := httpclient.NewBrowserDownloadRequest(proxyURL).SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
|
||||
resp, err := httpclient.NewBrowserDownloadRequest().SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
|
||||
if pushProgress {
|
||||
util.PushDownloadProgress(pushID, float32(info.DownloadedSize)/float32(info.Response.ContentLength))
|
||||
}
|
||||
}).Get(u)
|
||||
if nil != err {
|
||||
u = util.BazaarOSSServer + "/package/" + repoURLHash
|
||||
resp, err = httpclient.NewBrowserDownloadRequest(proxyURL).SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
|
||||
resp, err = httpclient.NewBrowserDownloadRequest().SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
|
||||
if pushProgress {
|
||||
util.PushDownloadProgress(pushID, float32(info.DownloadedSize)/float32(info.Response.ContentLength))
|
||||
}
|
||||
|
|
@ -106,18 +106,18 @@ func downloadPackage(repoURLHash, proxyURL string, chinaCDN, pushProgress bool,
|
|||
}
|
||||
data = buf.Bytes()
|
||||
|
||||
go incPackageDownloads(repoURLHash, proxyURL, systemID)
|
||||
go incPackageDownloads(repoURLHash, systemID)
|
||||
return
|
||||
}
|
||||
|
||||
func incPackageDownloads(repoURLHash, proxyURL, systemID string) {
|
||||
func incPackageDownloads(repoURLHash, systemID string) {
|
||||
if strings.Contains(repoURLHash, ".md") {
|
||||
return
|
||||
}
|
||||
|
||||
repo := strings.Split(repoURLHash, "@")[0]
|
||||
u := util.AliyunServer + "/apis/siyuan/bazaar/addBazaarPackageDownloadCount"
|
||||
httpclient.NewCloudRequest(proxyURL).SetBody(
|
||||
httpclient.NewCloudRequest().SetBody(
|
||||
map[string]interface{}{
|
||||
"systemID": systemID,
|
||||
"repo": repo,
|
||||
|
|
@ -182,7 +182,7 @@ var cachedBazaarIndex = map[string]*bazaarPackage{}
|
|||
var bazaarIndexCacheTime int64
|
||||
var bazaarIndexLock = sync.Mutex{}
|
||||
|
||||
func getBazaarIndex(proxyURL string) map[string]*bazaarPackage {
|
||||
func getBazaarIndex() map[string]*bazaarPackage {
|
||||
bazaarIndexLock.Lock()
|
||||
defer bazaarIndexLock.Unlock()
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ func getBazaarIndex(proxyURL string) map[string]*bazaarPackage {
|
|||
return cachedBazaarIndex
|
||||
}
|
||||
|
||||
request := httpclient.NewBrowserRequest(proxyURL)
|
||||
request := httpclient.NewBrowserRequest()
|
||||
u := util.BazaarStatServer + "/bazaar/index.json"
|
||||
resp, reqErr := request.SetResult(&cachedBazaarIndex).Get(u)
|
||||
if nil != reqErr {
|
||||
|
|
|
|||
|
|
@ -54,17 +54,17 @@ type Template struct {
|
|||
Downloads int `json:"downloads"`
|
||||
}
|
||||
|
||||
func Templates(proxyURL string) (templates []*Template) {
|
||||
func Templates() (templates []*Template) {
|
||||
templates = []*Template{}
|
||||
result, err := util.GetRhyResult(false, proxyURL)
|
||||
result, err := util.GetRhyResult(false)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
bazaarIndex := getBazaarIndex(proxyURL)
|
||||
bazaarIndex := getBazaarIndex()
|
||||
bazaarHash := result["bazaar"].(string)
|
||||
result = map[string]interface{}{}
|
||||
request := httpclient.NewBrowserRequest(proxyURL)
|
||||
request := httpclient.NewBrowserRequest()
|
||||
u := util.BazaarOSSServer + "/bazaar@" + bazaarHash + "/stage/templates.json"
|
||||
resp, reqErr := request.SetResult(&result).Get(u)
|
||||
if nil != reqErr {
|
||||
|
|
@ -87,7 +87,7 @@ func Templates(proxyURL string) (templates []*Template) {
|
|||
|
||||
template := &Template{}
|
||||
innerU := util.BazaarOSSServer + "/package/" + repoURL + "/template.json"
|
||||
innerResp, innerErr := httpclient.NewBrowserRequest(proxyURL).SetResult(template).Get(innerU)
|
||||
innerResp, innerErr := httpclient.NewBrowserRequest().SetResult(template).Get(innerU)
|
||||
if nil != innerErr {
|
||||
util.LogErrorf("get community template [%s] failed: %s", repoURL, innerErr)
|
||||
return
|
||||
|
|
@ -129,9 +129,9 @@ func Templates(proxyURL string) (templates []*Template) {
|
|||
return
|
||||
}
|
||||
|
||||
func InstallTemplate(repoURL, repoHash, installPath, proxyURL string, chinaCDN bool, systemID string) error {
|
||||
func InstallTemplate(repoURL, repoHash, installPath string, chinaCDN bool, systemID string) error {
|
||||
repoURLHash := repoURL + "@" + repoHash
|
||||
data, err := downloadPackage(repoURLHash, proxyURL, chinaCDN, true, systemID)
|
||||
data, err := downloadPackage(repoURLHash, chinaCDN, true, systemID)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,17 +55,17 @@ type Theme struct {
|
|||
Downloads int `json:"downloads"`
|
||||
}
|
||||
|
||||
func Themes(proxyURL string) (ret []*Theme) {
|
||||
func Themes() (ret []*Theme) {
|
||||
ret = []*Theme{}
|
||||
result, err := util.GetRhyResult(false, proxyURL)
|
||||
result, err := util.GetRhyResult(false)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
bazaarIndex := getBazaarIndex(proxyURL)
|
||||
bazaarIndex := getBazaarIndex()
|
||||
bazaarHash := result["bazaar"].(string)
|
||||
result = map[string]interface{}{}
|
||||
request := httpclient.NewBrowserRequest(proxyURL)
|
||||
request := httpclient.NewBrowserRequest()
|
||||
u := util.BazaarOSSServer + "/bazaar@" + bazaarHash + "/stage/themes.json"
|
||||
resp, reqErr := request.SetResult(&result).Get(u)
|
||||
if nil != reqErr {
|
||||
|
|
@ -88,7 +88,7 @@ func Themes(proxyURL string) (ret []*Theme) {
|
|||
|
||||
theme := &Theme{}
|
||||
innerU := util.BazaarOSSServer + "/package/" + repoURL + "/theme.json"
|
||||
innerResp, innerErr := httpclient.NewBrowserRequest(proxyURL).SetResult(theme).Get(innerU)
|
||||
innerResp, innerErr := httpclient.NewBrowserRequest().SetResult(theme).Get(innerU)
|
||||
if nil != innerErr {
|
||||
util.LogErrorf("get bazaar package [%s] failed: %s", innerU, innerErr)
|
||||
return
|
||||
|
|
@ -128,9 +128,9 @@ func Themes(proxyURL string) (ret []*Theme) {
|
|||
return
|
||||
}
|
||||
|
||||
func InstallTheme(repoURL, repoHash, installPath, proxyURL string, chinaCDN bool, systemID string) error {
|
||||
func InstallTheme(repoURL, repoHash, installPath string, chinaCDN bool, systemID string) error {
|
||||
repoURLHash := repoURL + "@" + repoHash
|
||||
data, err := downloadPackage(repoURLHash, proxyURL, chinaCDN, true, systemID)
|
||||
data, err := downloadPackage(repoURLHash, chinaCDN, true, systemID)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,17 +54,17 @@ type Widget struct {
|
|||
Downloads int `json:"downloads"`
|
||||
}
|
||||
|
||||
func Widgets(proxyURL string) (widgets []*Widget) {
|
||||
func Widgets() (widgets []*Widget) {
|
||||
widgets = []*Widget{}
|
||||
result, err := util.GetRhyResult(false, proxyURL)
|
||||
result, err := util.GetRhyResult(false)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
bazaarIndex := getBazaarIndex(proxyURL)
|
||||
bazaarIndex := getBazaarIndex()
|
||||
bazaarHash := result["bazaar"].(string)
|
||||
result = map[string]interface{}{}
|
||||
request := httpclient.NewBrowserRequest(proxyURL)
|
||||
request := httpclient.NewBrowserRequest()
|
||||
u := util.BazaarOSSServer + "/bazaar@" + bazaarHash + "/stage/widgets.json"
|
||||
resp, err := request.SetResult(&result).Get(u)
|
||||
if nil != err {
|
||||
|
|
@ -87,7 +87,7 @@ func Widgets(proxyURL string) (widgets []*Widget) {
|
|||
|
||||
widget := &Widget{}
|
||||
innerU := util.BazaarOSSServer + "/package/" + repoURL + "/widget.json"
|
||||
innerResp, innerErr := httpclient.NewBrowserRequest(proxyURL).SetResult(widget).Get(innerU)
|
||||
innerResp, innerErr := httpclient.NewBrowserRequest().SetResult(widget).Get(innerU)
|
||||
if nil != innerErr {
|
||||
util.LogErrorf("get bazaar package [%s] failed: %s", repoURL, innerErr)
|
||||
return
|
||||
|
|
@ -127,9 +127,9 @@ func Widgets(proxyURL string) (widgets []*Widget) {
|
|||
return
|
||||
}
|
||||
|
||||
func InstallWidget(repoURL, repoHash, installPath, proxyURL string, chinaCDN bool, systemID string) error {
|
||||
func InstallWidget(repoURL, repoHash, installPath string, chinaCDN bool, systemID string) error {
|
||||
repoURLHash := repoURL + "@" + repoHash
|
||||
data, err := downloadPackage(repoURLHash, proxyURL, chinaCDN, true, systemID)
|
||||
data, err := downloadPackage(repoURLHash, chinaCDN, true, systemID)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ require (
|
|||
github.com/qiniu/go-sdk/v7 v7.13.0
|
||||
github.com/radovskyb/watcher v1.0.7
|
||||
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220707164542-13640068715e
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220709030539-d73a81b0ae9b
|
||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f
|
||||
github.com/siyuan-note/filelock v0.0.0-20220704090116-54dfb035283f
|
||||
github.com/siyuan-note/httpclient v0.0.0-20220629022115-8de64709cc5e
|
||||
github.com/siyuan-note/httpclient v0.0.0-20220709030145-2bfb50f28e73
|
||||
github.com/vmihailenco/msgpack/v5 v5.3.5
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673
|
||||
golang.org/x/image v0.0.0-20220601225756-64ec528b34cd
|
||||
|
|
@ -102,9 +102,9 @@ require (
|
|||
go.uber.org/multierr v1.8.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
|
||||
golang.org/x/mod v0.5.1 // indirect
|
||||
golang.org/x/net v0.0.0-20220706163947-c90051bbdb60 // indirect
|
||||
golang.org/x/net v0.0.0-20220708220712-1185a9018129 // indirect
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
|
||||
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e // indirect
|
||||
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d // indirect
|
||||
golang.org/x/tools v0.1.8 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
google.golang.org/protobuf v1.28.0 // indirect
|
||||
|
|
|
|||
|
|
@ -424,16 +424,16 @@ github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJ
|
|||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220707164542-13640068715e h1:byd5iI5dHsebxRgsYNiEap8IXU192IBkzx1yazBZN9Q=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220707164542-13640068715e/go.mod h1:ral+X0pNW6nSQVvIcxllUXSczCaY4UOCT2iGlO4YNg0=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220709030539-d73a81b0ae9b h1:dAicoPtCjujSYNz2OcOrq423DklGZXg3ZnTHRWPBgDA=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220709030539-d73a81b0ae9b/go.mod h1:cri+XyZAqmK5fJ98En9aOHB+YkuU8+XQcJdQ31EUhis=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676 h1:QB9TjJQFhXhZ6dAtPpY02DlzHAQm1C+WqZq6OadG8mI=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f h1:JMobMNZ7AqaKKyEK+WeWFhix/2TDQXgPZDajU00IybU=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f/go.mod h1:Sqo4FYX5lAXu7gWkbEdJF0e6P57tNNVV4WDKYDctokI=
|
||||
github.com/siyuan-note/filelock v0.0.0-20220704090116-54dfb035283f h1:IXZ4SWPjQLqMrBwDWcWYFE/SihUHRS9FYhk/0bnySok=
|
||||
github.com/siyuan-note/filelock v0.0.0-20220704090116-54dfb035283f/go.mod h1:c4vwvWRrnfa75OXiO21K/76BFRJ4cFITKNoVs5lFdwc=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20220629022115-8de64709cc5e h1:5tKpe6YubHcr60lKRtqD4TbqsbnF/Zl6D/K/CixRHUY=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20220629022115-8de64709cc5e/go.mod h1:UTb1xAQC/eCSDklGWp8qQYlY0+qrVA3+MyOIKcliRLg=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20220709030145-2bfb50f28e73 h1:NAw9IJtD0/NU2lhraQjELAcU9Bf6mRLrhvx57Q3qmsw=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20220709030145-2bfb50f28e73/go.mod h1:sCMZurEZaMFiwGbdppizHT3NPO/HUdd+1FqtAyfdEsE=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
|
|
@ -590,8 +590,8 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx
|
|||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220706163947-c90051bbdb60 h1:8NSylCMxLW4JvserAndSgFL7aPli6A68yf0bYFTcWCM=
|
||||
golang.org/x/net v0.0.0-20220706163947-c90051bbdb60/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.0.0-20220708220712-1185a9018129 h1:vucSRfWwTsoXro7P+3Cjlr6flUMtzCwzlvkxEQtHHB0=
|
||||
golang.org/x/net v0.0.0-20220708220712-1185a9018129/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
|
|
@ -669,8 +669,8 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e h1:CsOuNlbOuf0mzxJIefr6Q4uAUetRUwZE4qt7VfzP+xo=
|
||||
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d h1:/m5NbqQelATgoSPVC2Z23sR4kVNokFwDDyWh/3rGY+I=
|
||||
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.0.0-20180302201248-b7ef84aaf62a/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func NetImg2LocalAssets(rootID string) (err error) {
|
|||
}
|
||||
}
|
||||
util.PushUpdateMsg(msgId, fmt.Sprintf(Conf.Language(119), u), 15000)
|
||||
request := httpclient.NewBrowserRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewBrowserRequest()
|
||||
resp, reqErr := request.Get(u)
|
||||
if nil != reqErr {
|
||||
util.LogErrorf("download net img [%s] failed: %s", u, reqErr)
|
||||
|
|
@ -286,7 +286,7 @@ func uploadCloud(sqlAssets []*sql.Asset) (err error) {
|
|||
}
|
||||
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
request := httpclient.NewCloudFileRequest2m(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudFileRequest2m()
|
||||
resp, reqErr := request.
|
||||
SetResult(requestResult).
|
||||
SetFile("file[]", absAsset).
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ import (
|
|||
)
|
||||
|
||||
func GetPackageREADME(repoURL, repoHash string) (ret string) {
|
||||
ret = bazaar.GetPackageREADME(repoURL, repoHash, Conf.System.NetworkProxy.String(), IsSubscriber(), Conf.System.ID)
|
||||
ret = bazaar.GetPackageREADME(repoURL, repoHash, IsSubscriber(), Conf.System.ID)
|
||||
return
|
||||
}
|
||||
|
||||
func BazaarWidgets() (widgets []*bazaar.Widget) {
|
||||
widgets = bazaar.Widgets(Conf.System.NetworkProxy.String())
|
||||
widgets = bazaar.Widgets()
|
||||
for _, widget := range widgets {
|
||||
widget.Installed = gulu.File.IsDir(filepath.Join(util.DataDir, "widgets", widget.Name))
|
||||
if widget.Installed {
|
||||
|
|
@ -54,7 +54,7 @@ func InstallBazaarWidget(repoURL, repoHash, widgetName string) error {
|
|||
defer writingDataLock.Unlock()
|
||||
|
||||
installPath := filepath.Join(util.DataDir, "widgets", widgetName)
|
||||
err := bazaar.InstallWidget(repoURL, repoHash, installPath, Conf.System.NetworkProxy.String(), IsSubscriber(), Conf.System.ID)
|
||||
err := bazaar.InstallWidget(repoURL, repoHash, installPath, IsSubscriber(), Conf.System.ID)
|
||||
if nil != err {
|
||||
return errors.New(fmt.Sprintf(Conf.Language(46), widgetName))
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ func UninstallBazaarWidget(widgetName string) error {
|
|||
}
|
||||
|
||||
func BazaarIcons() (icons []*bazaar.Icon) {
|
||||
icons = bazaar.Icons(Conf.System.NetworkProxy.String())
|
||||
icons = bazaar.Icons()
|
||||
for _, installed := range Conf.Appearance.Icons {
|
||||
for _, icon := range icons {
|
||||
if installed == icon.Name {
|
||||
|
|
@ -96,7 +96,7 @@ func InstallBazaarIcon(repoURL, repoHash, iconName string) error {
|
|||
defer writingDataLock.Unlock()
|
||||
|
||||
installPath := filepath.Join(util.IconsPath, iconName)
|
||||
err := bazaar.InstallIcon(repoURL, repoHash, installPath, Conf.System.NetworkProxy.String(), IsSubscriber(), Conf.System.ID)
|
||||
err := bazaar.InstallIcon(repoURL, repoHash, installPath, IsSubscriber(), Conf.System.ID)
|
||||
if nil != err {
|
||||
return errors.New(fmt.Sprintf(Conf.Language(46), iconName))
|
||||
}
|
||||
|
|
@ -121,7 +121,7 @@ func UninstallBazaarIcon(iconName string) error {
|
|||
}
|
||||
|
||||
func BazaarThemes() (ret []*bazaar.Theme) {
|
||||
ret = bazaar.Themes(Conf.System.NetworkProxy.String())
|
||||
ret = bazaar.Themes()
|
||||
installs := Conf.Appearance.DarkThemes
|
||||
installs = append(installs, Conf.Appearance.LightThemes...)
|
||||
for _, installed := range installs {
|
||||
|
|
@ -145,7 +145,7 @@ func InstallBazaarTheme(repoURL, repoHash, themeName string, mode int, update bo
|
|||
closeThemeWatchers()
|
||||
|
||||
installPath := filepath.Join(util.ThemesPath, themeName)
|
||||
err := bazaar.InstallTheme(repoURL, repoHash, installPath, Conf.System.NetworkProxy.String(), IsSubscriber(), Conf.System.ID)
|
||||
err := bazaar.InstallTheme(repoURL, repoHash, installPath, IsSubscriber(), Conf.System.ID)
|
||||
if nil != err {
|
||||
return errors.New(fmt.Sprintf(Conf.Language(46), themeName))
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ func UninstallBazaarTheme(themeName string) error {
|
|||
}
|
||||
|
||||
func BazaarTemplates() (templates []*bazaar.Template) {
|
||||
templates = bazaar.Templates(Conf.System.NetworkProxy.String())
|
||||
templates = bazaar.Templates()
|
||||
for _, template := range templates {
|
||||
template.Installed = gulu.File.IsExist(filepath.Join(util.DataDir, "templates", template.Name))
|
||||
if template.Installed {
|
||||
|
|
@ -202,7 +202,7 @@ func InstallBazaarTemplate(repoURL, repoHash, templateName string) error {
|
|||
defer writingDataLock.Unlock()
|
||||
|
||||
installPath := filepath.Join(util.DataDir, "templates", templateName)
|
||||
err := bazaar.InstallTemplate(repoURL, repoHash, installPath, Conf.System.NetworkProxy.String(), IsSubscriber(), Conf.System.ID)
|
||||
err := bazaar.InstallTemplate(repoURL, repoHash, installPath, IsSubscriber(), Conf.System.ID)
|
||||
if nil != err {
|
||||
return errors.New(fmt.Sprintf(Conf.Language(46), templateName))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,9 +210,6 @@ func InitConf() {
|
|||
if nil == Conf.System.NetworkProxy {
|
||||
Conf.System.NetworkProxy = &conf.NetworkProxy{}
|
||||
}
|
||||
if "" != Conf.System.NetworkProxy.Scheme {
|
||||
util.LogInfof("using network proxy [%s]", Conf.System.NetworkProxy.String())
|
||||
}
|
||||
if "" == Conf.System.ID {
|
||||
Conf.System.ID = util.GetDeviceID()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ func StartFreeTrial() (err error) {
|
|||
}
|
||||
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
_, err = request.
|
||||
SetResult(requestResult).
|
||||
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.User.UserToken}).
|
||||
|
|
@ -55,7 +55,7 @@ func StartFreeTrial() (err error) {
|
|||
|
||||
func DeactivateUser() (err error) {
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(requestResult).
|
||||
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.User.UserToken}).
|
||||
|
|
@ -80,7 +80,7 @@ func DeactivateUser() (err error) {
|
|||
func SetCloudBlockReminder(id, data string, timed int64) (err error) {
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
payload := map[string]interface{}{"dataId": id, "data": data, "timed": timed}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(requestResult).
|
||||
SetBody(payload).
|
||||
|
|
@ -113,7 +113,7 @@ func LoadUploadToken() (err error) {
|
|||
}
|
||||
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(requestResult).
|
||||
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.User.UserToken}).
|
||||
|
|
@ -252,7 +252,7 @@ func loadUserFromConf() *conf.User {
|
|||
|
||||
func RemoveCloudShorthands(ids []string) (err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
body := map[string]interface{}{
|
||||
"ids": ids,
|
||||
}
|
||||
|
|
@ -283,7 +283,7 @@ func RemoveCloudShorthands(ids []string) (err error) {
|
|||
|
||||
func GetCloudShorthands(page int) (result map[string]interface{}, err error) {
|
||||
result = map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.User.UserToken}).
|
||||
|
|
@ -320,7 +320,7 @@ var errInvalidUser = errors.New("invalid user")
|
|||
|
||||
func getUser(token string) (*conf.User, error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
_, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"token": token}).
|
||||
|
|
@ -351,7 +351,7 @@ func getUser(token string) (*conf.User, error) {
|
|||
|
||||
func UseActivationcode(code string) (err error) {
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
_, err = request.
|
||||
SetResult(requestResult).
|
||||
SetBody(map[string]string{"data": code}).
|
||||
|
|
@ -370,7 +370,7 @@ func UseActivationcode(code string) (err error) {
|
|||
func CheckActivationcode(code string) (retCode int, msg string) {
|
||||
retCode = 1
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
_, err := request.
|
||||
SetResult(requestResult).
|
||||
SetBody(map[string]string{"data": code}).
|
||||
|
|
@ -390,7 +390,7 @@ func CheckActivationcode(code string) (retCode int, msg string) {
|
|||
|
||||
func Login(userName, password, captcha string) (ret *gulu.Result, err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
_, err = request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"userName": userName, "userPassword": password, "captcha": captcha}).
|
||||
|
|
@ -416,7 +416,7 @@ func Login(userName, password, captcha string) (ret *gulu.Result, err error) {
|
|||
|
||||
func Login2fa(token, code string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
_, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"twofactorAuthCode": code}).
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import (
|
|||
|
||||
func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize int64, err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
|
||||
var resp *req.Response
|
||||
if Conf.Sync.UseDataRepo {
|
||||
|
|
@ -82,7 +82,7 @@ func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize int64, e
|
|||
|
||||
func removeCloudDirPath(dirPath string) (err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"dirPath": dirPath, "token": Conf.User.UserToken}).
|
||||
|
|
@ -107,7 +107,7 @@ func removeCloudDirPath(dirPath string) (err error) {
|
|||
|
||||
func createCloudSyncDirOSS(name string) (err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"name": name, "token": Conf.User.UserToken}).
|
||||
|
|
@ -138,7 +138,7 @@ func createCloudSyncDirOSS(name string) (err error) {
|
|||
|
||||
func listCloudSyncDirOSS() (dirs []map[string]interface{}, size int64, err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetBody(map[string]interface{}{"token": Conf.User.UserToken}).
|
||||
SetResult(&result).
|
||||
|
|
@ -290,7 +290,7 @@ func ossDownload0(localDirPath, cloudDirPath, fetch string, fetchedFiles *int, t
|
|||
localFilePath := filepath.Join(localDirPath, fetch)
|
||||
remoteFileURL := path.Join(cloudDirPath, fetch)
|
||||
var result map[string]interface{}
|
||||
resp, err := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String()).
|
||||
resp, err := httpclient.NewCloudRequest().
|
||||
SetResult(&result).
|
||||
SetBody(map[string]interface{}{"token": Conf.User.UserToken, "path": remoteFileURL}).
|
||||
Post(util.AliyunServer + "/apis/siyuan/data/getSiYuanFile?uid=" + Conf.User.UserId)
|
||||
|
|
@ -325,9 +325,9 @@ func ossDownload0(localDirPath, cloudDirPath, fetch string, fetchedFiles *int, t
|
|||
os.Remove(localFilePath)
|
||||
|
||||
if bootORExit {
|
||||
resp, err = httpclient.NewCloudFileRequest15s(Conf.System.NetworkProxy.String()).Get(downloadURL)
|
||||
resp, err = httpclient.NewCloudFileRequest15s().Get(downloadURL)
|
||||
} else {
|
||||
resp, err = httpclient.NewCloudFileRequest2m(Conf.System.NetworkProxy.String()).Get(downloadURL)
|
||||
resp, err = httpclient.NewCloudFileRequest2m().Get(downloadURL)
|
||||
}
|
||||
if nil != err {
|
||||
util.LogErrorf("download request [%s] failed: %s", downloadURL, err)
|
||||
|
|
@ -470,7 +470,7 @@ func ossRemove0(cloudDirPath string, removes []string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetBody(map[string]interface{}{"token": Conf.User.UserToken, "dirPath": cloudDirPath, "paths": removes}).
|
||||
Post(util.AliyunServer + "/apis/siyuan/data/removeSiYuanFile?uid=" + Conf.User.UserId)
|
||||
|
|
@ -524,7 +524,7 @@ func getOssUploadToken(filename, cloudDirPath string, length int64) (ret string,
|
|||
// 因为需要指定 key,所以每次上传文件都必须在云端生成 Token,否则有安全隐患
|
||||
|
||||
var result map[string]interface{}
|
||||
req := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String()).
|
||||
req := httpclient.NewCloudRequest().
|
||||
SetResult(&result)
|
||||
req.SetBody(map[string]interface{}{
|
||||
"token": Conf.User.UserToken,
|
||||
|
|
@ -564,7 +564,7 @@ func getOssUploadToken(filename, cloudDirPath string, length int64) (ret string,
|
|||
func getCloudSyncVer(cloudDir string) (cloudSyncVer int64, err error) {
|
||||
start := time.Now()
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"syncDir": cloudDir, "token": Conf.User.UserToken}).
|
||||
|
|
@ -604,7 +604,7 @@ func getCloudSyncVer(cloudDir string) (cloudSyncVer int64, err error) {
|
|||
func getCloudSync(cloudDir string) (assetSize, backupSize int64, device string, err error) {
|
||||
start := time.Now()
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"syncDir": cloudDir, "token": Conf.User.UserToken}).
|
||||
|
|
@ -669,7 +669,7 @@ func getLocalFileListOSS(isBackup bool) (ret map[string]*CloudIndex, err error)
|
|||
|
||||
func getCloudFileListOSS(cloudDirPath string) (ret map[string]*CloudIndex, err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"dirPath": cloudDirPath, "token": Conf.User.UserToken}).
|
||||
|
|
@ -694,7 +694,7 @@ func getCloudFileListOSS(cloudDirPath string) (ret map[string]*CloudIndex, err e
|
|||
|
||||
retData := result["data"].(map[string]interface{})
|
||||
downloadURL := retData["url"].(string)
|
||||
resp, err = httpclient.NewCloudFileRequest15s(Conf.System.NetworkProxy.String()).Get(downloadURL)
|
||||
resp, err = httpclient.NewCloudFileRequest15s().Get(downloadURL)
|
||||
if nil != err {
|
||||
util.LogErrorf("download request [%s] failed: %s", downloadURL, err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -667,7 +667,6 @@ func buildCloudInfo() (ret *dejavu.CloudInfo, err error) {
|
|||
UserID: Conf.User.UserId,
|
||||
Token: Conf.User.UserToken,
|
||||
LimitSize: int64(Conf.User.UserSiYuanRepoSize - Conf.User.UserSiYuanAssetSize),
|
||||
ProxyURL: Conf.System.NetworkProxy.String(),
|
||||
Server: util.AliyunServer,
|
||||
}
|
||||
return
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ func CheckUpdate(showMsg bool) {
|
|||
checkUpdateLock.Lock()
|
||||
defer checkUpdateLock.Unlock()
|
||||
|
||||
result, err := util.GetRhyResult(showMsg, Conf.System.NetworkProxy.String())
|
||||
result, err := util.GetRhyResult(showMsg)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ var cachedRhyResult = map[string]interface{}{}
|
|||
var rhyResultCacheTime int64
|
||||
var rhyResultLock = sync.Mutex{}
|
||||
|
||||
func GetRhyResult(force bool, proxyURL string) (map[string]interface{}, error) {
|
||||
func GetRhyResult(force bool) (map[string]interface{}, error) {
|
||||
rhyResultLock.Lock()
|
||||
defer rhyResultLock.Unlock()
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ func GetRhyResult(force bool, proxyURL string) (map[string]interface{}, error) {
|
|||
return cachedRhyResult, nil
|
||||
}
|
||||
|
||||
request := httpclient.NewCloudRequest(proxyURL)
|
||||
request := httpclient.NewCloudRequest()
|
||||
_, err := request.SetResult(&cachedRhyResult).Get(AliyunServer + "/apis/siyuan/version?ver=" + Ver)
|
||||
if nil != err {
|
||||
LogErrorf("get version meta info failed: %s", err)
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ func checkPort() {
|
|||
|
||||
LogInfof("port [%s] is opened, try to check version of running kernel", ServerPort)
|
||||
result := NewResult()
|
||||
_, err := httpclient.NewBrowserRequest("").
|
||||
_, err := httpclient.NewBrowserRequest().
|
||||
SetResult(result).
|
||||
SetHeader("User-Agent", UserAgent).
|
||||
Get("http://127.0.0.1:" + ServerPort + "/api/system/version")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue