Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
28d29609b5
12 changed files with 48 additions and 57 deletions
|
@ -368,6 +368,7 @@ func setNetworkProxy(c *gin.Context) {
|
|||
|
||||
proxyURL := model.Conf.System.NetworkProxy.String()
|
||||
util.SetNetworkProxy(proxyURL)
|
||||
util.PushMsg(model.Conf.Language(102), 3000)
|
||||
}
|
||||
|
||||
func addUIProcess(c *gin.Context) {
|
||||
|
|
|
@ -305,14 +305,14 @@ func downloadPackage(repoURLHash string, pushProgress bool, systemID string) (da
|
|||
repoURLHash = strings.TrimPrefix(repoURLHash, "https://github.com/")
|
||||
u := util.BazaarOSSServer + "/package/" + repoURLHash
|
||||
buf := &bytes.Buffer{}
|
||||
resp, err := httpclient.NewBrowserDownloadRequest().SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
|
||||
resp, err := httpclient.NewBrowserRequest().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().SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
|
||||
resp, err = httpclient.NewBrowserRequest().SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
|
||||
if pushProgress {
|
||||
util.PushDownloadProgress(pushID, float32(info.DownloadedSize)/float32(info.Response.ContentLength))
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ func incPackageDownloads(repoURLHash, systemID string) {
|
|||
|
||||
repo := strings.Split(repoURLHash, "@")[0]
|
||||
u := util.AliyunServer + "/apis/siyuan/bazaar/addBazaarPackageDownloadCount"
|
||||
httpclient.NewCloudRequest().SetBody(
|
||||
httpclient.NewCloudRequest30s().SetBody(
|
||||
map[string]interface{}{
|
||||
"systemID": systemID,
|
||||
"repo": repo,
|
||||
|
|
|
@ -27,7 +27,7 @@ require (
|
|||
github.com/gin-contrib/gzip v0.0.6
|
||||
github.com/gin-contrib/sessions v0.0.5
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/imroc/req/v3 v3.26.3
|
||||
github.com/imroc/req/v3 v3.26.4
|
||||
github.com/jinzhu/copier v0.3.5
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
||||
|
@ -37,11 +37,11 @@ require (
|
|||
github.com/panjf2000/ants/v2 v2.6.0
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/radovskyb/watcher v1.0.7
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221204123650-c456e15f08bd
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221205145512-e55f9d23efdc
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da
|
||||
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e
|
||||
github.com/siyuan-note/httpclient v0.0.0-20221204023746-16d8a3bf1d66
|
||||
github.com/siyuan-note/httpclient v0.0.0-20221205145344-d1926f2a6c3f
|
||||
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a
|
||||
github.com/steambap/captcha v1.4.1
|
||||
github.com/studio-b12/gowebdav v0.0.0-20221109171924-60ec5ad56012
|
||||
|
@ -49,7 +49,7 @@ require (
|
|||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673
|
||||
golang.org/x/image v0.1.0
|
||||
golang.org/x/mobile v0.0.0-20220722155234-aaac322e2105
|
||||
golang.org/x/text v0.4.0
|
||||
golang.org/x/text v0.5.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -114,11 +114,11 @@ require (
|
|||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
golang.org/x/crypto v0.3.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 // indirect
|
||||
golang.org/x/exp v0.0.0-20221204150635-6dcec336b2bb // indirect
|
||||
golang.org/x/mod v0.7.0 // indirect
|
||||
golang.org/x/net v0.2.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.2.0 // indirect
|
||||
golang.org/x/sys v0.3.0 // indirect
|
||||
golang.org/x/tools v0.3.0 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
|
|
|
@ -199,8 +199,8 @@ github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq
|
|||
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
|
||||
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
||||
github.com/imroc/req/v3 v3.26.3 h1:l5GZD4JYgfpYXq4PrXSs/TrviQr7jm9SM+G6J5BH28c=
|
||||
github.com/imroc/req/v3 v3.26.3/go.mod h1:EluRnkfh8A39BmrCARYhcUrfGyR8qPw+O0BZyTy4j9k=
|
||||
github.com/imroc/req/v3 v3.26.4 h1:944CqSuk1TQcpDf6cfADl5mMueRCief15Atu2VyLWak=
|
||||
github.com/imroc/req/v3 v3.26.4/go.mod h1:AQ5kNHHkid1ibNfsYz3QvpMHJsagqNxbe3RYX7+8T1U=
|
||||
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
|
||||
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
|
||||
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
||||
|
@ -359,16 +359,16 @@ github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1l
|
|||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
|
||||
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221204123650-c456e15f08bd h1:lXVZCfAqeQjZKlT4aa9b+omId+W+QpiHo3qJ6kIOI5k=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221204123650-c456e15f08bd/go.mod h1:YKJSOrRHSJ9Fdkx37e2+8e/fJGrW1xU71hXmlH2ybzA=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221205145512-e55f9d23efdc h1:Qhha41FHR6VGMN+kFZm7aIPY8SPe7rcVxojFrl6dP+8=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221205145512-e55f9d23efdc/go.mod h1:1gRpmw/KgEAvRAH7MR7cRibdMbhEpi8w09pwKwQ7V9I=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da/go.mod h1:Sqo4FYX5lAXu7gWkbEdJF0e6P57tNNVV4WDKYDctokI=
|
||||
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e h1:i3RKrdrddr4AuaHJtoWYAEVNuR7Y9wIsEqPmuFFbJC4=
|
||||
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e/go.mod h1:NmpSIVtIGy8eNWapjDIiiCw5+5r5wxC76k40oG+WRXQ=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20221204023746-16d8a3bf1d66 h1:MhkMijp0VgDDZHLyAt2J+OhEVuoQYmFTbTybNBNra8E=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20221204023746-16d8a3bf1d66/go.mod h1:5EFpLEJzPTzRqj8Het+KJg4tUqu0mc7yKGY+p4lCO8c=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20221205145344-d1926f2a6c3f h1:Zi5est0fVQBNSUA4vV9PmBdqT4v1PWeukyfAALMYPnY=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20221205145344-d1926f2a6c3f/go.mod h1:tB4OHLzYkIrv1M7V9abkLCorMjzFX6HhHJm0De5vFGI=
|
||||
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a h1:b9VJCE8IccYjsadwNBI11he+Wn25hI9lCma4uYoIYEM=
|
||||
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a/go.mod h1:t1zRGxK13L/9ZFoGyTD39IbFCbee3CsypDj4b5dt4qM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
|
@ -438,8 +438,8 @@ golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
|
|||
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
|
||||
golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 h1:yZNXmy+j/JpX19vZkVktWqAo7Gny4PBWYYK3zskGpx4=
|
||||
golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/exp v0.0.0-20221204150635-6dcec336b2bb h1:QIsP/NmClBICkqnJ4rSIhnrGiGR7Yv9ZORGGnmmLTPk=
|
||||
golang.org/x/exp v0.0.0-20221204150635-6dcec336b2bb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20190823064033-3a9bac650e44/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
|
@ -533,8 +533,9 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
|
@ -547,8 +548,9 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
||||
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
|
|
|
@ -42,7 +42,7 @@ func StartFreeTrial() (err error) {
|
|||
}
|
||||
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
request := httpclient.NewCloudRequest()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
_, err = request.
|
||||
SetResult(requestResult).
|
||||
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.User.UserToken}).
|
||||
|
@ -59,7 +59,7 @@ func StartFreeTrial() (err error) {
|
|||
|
||||
func DeactivateUser() (err error) {
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
request := httpclient.NewCloudRequest()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
resp, err := request.
|
||||
SetResult(requestResult).
|
||||
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.User.UserToken}).
|
||||
|
@ -84,7 +84,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()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
resp, err := request.
|
||||
SetResult(requestResult).
|
||||
SetBody(payload).
|
||||
|
@ -117,7 +117,7 @@ func LoadUploadToken() (err error) {
|
|||
}
|
||||
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
request := httpclient.NewCloudRequest()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
resp, err := request.
|
||||
SetResult(requestResult).
|
||||
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.User.UserToken}).
|
||||
|
@ -333,7 +333,7 @@ func loadUserFromConf() *conf.User {
|
|||
|
||||
func RemoveCloudShorthands(ids []string) (err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
body := map[string]interface{}{
|
||||
"ids": ids,
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ func RemoveCloudShorthands(ids []string) (err error) {
|
|||
|
||||
func GetCloudShorthand(id string) (ret map[string]interface{}, err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.User.UserToken}).
|
||||
|
@ -395,7 +395,7 @@ func GetCloudShorthand(id string) (ret map[string]interface{}, err error) {
|
|||
|
||||
func GetCloudShorthands(page int) (result map[string]interface{}, err error) {
|
||||
result = map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.User.UserToken}).
|
||||
|
@ -432,7 +432,7 @@ var errInvalidUser = errors.New("invalid user")
|
|||
|
||||
func getUser(token string) (*conf.User, error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
_, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"token": token}).
|
||||
|
@ -465,7 +465,7 @@ func UseActivationcode(code string) (err error) {
|
|||
code = strings.TrimSpace(code)
|
||||
code = gulu.Str.RemoveInvisible(code)
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
request := httpclient.NewCloudRequest()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
_, err = request.
|
||||
SetResult(requestResult).
|
||||
SetBody(map[string]string{"data": code}).
|
||||
|
@ -486,7 +486,7 @@ func CheckActivationcode(code string) (retCode int, msg string) {
|
|||
code = gulu.Str.RemoveInvisible(code)
|
||||
retCode = 1
|
||||
requestResult := gulu.Ret.NewResult()
|
||||
request := httpclient.NewCloudRequest()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
_, err := request.
|
||||
SetResult(requestResult).
|
||||
SetBody(map[string]string{"data": code}).
|
||||
|
@ -506,7 +506,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()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
_, err = request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"userName": userName, "userPassword": password, "captcha": captcha}).
|
||||
|
@ -532,7 +532,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()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
_, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"twofactorAuthCode": code}).
|
||||
|
|
|
@ -39,6 +39,7 @@ import (
|
|||
"github.com/siyuan-note/dejavu/entity"
|
||||
"github.com/siyuan-note/encryption"
|
||||
"github.com/siyuan-note/eventbus"
|
||||
"github.com/siyuan-note/httpclient"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||
|
@ -831,7 +832,7 @@ func newRepository() (ret *dejavu.Repo, err error) {
|
|||
case conf.ProviderSiYuan:
|
||||
cloudRepo = cloud.NewSiYuan(&cloud.BaseCloud{Conf: cloudConf})
|
||||
case conf.ProviderS3:
|
||||
s3HTTPClient := &http.Client{Transport: util.NewTransport(cloudConf.S3.SkipTlsVerify)}
|
||||
s3HTTPClient := &http.Client{Transport: httpclient.NewTransport(cloudConf.S3.SkipTlsVerify)}
|
||||
s3HTTPClient.Timeout = time.Duration(cloudConf.S3.Timeout) * time.Second
|
||||
cloudRepo = cloud.NewS3(&cloud.BaseCloud{Conf: cloudConf}, s3HTTPClient)
|
||||
case conf.ProviderWebDAV:
|
||||
|
@ -841,7 +842,7 @@ func newRepository() (ret *dejavu.Repo, err error) {
|
|||
webdavClient.SetHeader("Authorization", auth)
|
||||
webdavClient.SetHeader("User-Agent", util.UserAgent)
|
||||
webdavClient.SetTimeout(time.Duration(cloudConf.WebDAV.Timeout) * time.Second)
|
||||
webdavClient.SetTransport(util.NewTransport(cloudConf.WebDAV.SkipTlsVerify))
|
||||
webdavClient.SetTransport(httpclient.NewTransport(cloudConf.WebDAV.SkipTlsVerify))
|
||||
cloudRepo = cloud.NewWebDAV(&cloud.BaseCloud{Conf: cloudConf}, webdavClient)
|
||||
default:
|
||||
err = fmt.Errorf("unknown cloud provider [%d]", Conf.Sync.Provider)
|
||||
|
|
|
@ -886,7 +886,7 @@ func markReplaceSpan(n *ast.Node, unlinks *[]*ast.Node, keywords []string, markS
|
|||
return true
|
||||
}
|
||||
} else if ast.NodeTextMark == n.Type {
|
||||
// 搜索结果高亮支持大部分行级元素 https://github.com/siyuan-note/siyuan/issues/6745
|
||||
// TODO 搜索结果高亮支持大部分行级元素 https://github.com/siyuan-note/siyuan/issues/6745
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -17,12 +17,9 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"github.com/siyuan-note/httpclient"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -54,22 +51,7 @@ func JsonArg(c *gin.Context, result *gulu.Result) (arg map[string]interface{}, o
|
|||
return
|
||||
}
|
||||
|
||||
func NewTransport(skipTlsVerify bool) *http.Transport {
|
||||
return &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
DialContext: defaultTransportDialContext(&net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}),
|
||||
ForceAttemptHTTP2: true,
|
||||
MaxIdleConns: 100,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: skipTlsVerify}}
|
||||
}
|
||||
|
||||
func defaultTransportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
|
||||
return dialer.DialContext
|
||||
func initHttpClient() {
|
||||
http.DefaultClient = httpclient.GetCloudFileClient2Min()
|
||||
http.DefaultTransport = httpclient.NewTransport(false)
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ func GetRhyResult(force bool) (map[string]interface{}, error) {
|
|||
return cachedRhyResult, nil
|
||||
}
|
||||
|
||||
request := httpclient.NewCloudRequest()
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
_, err := request.SetResult(&cachedRhyResult).Get(AliyunServer + "/apis/siyuan/version?ver=" + Ver)
|
||||
if nil != err {
|
||||
logging.LogErrorf("get version info failed: %s", err)
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/denisbrodbeck/machineid"
|
||||
"github.com/siyuan-note/httpclient"
|
||||
"github.com/siyuan-note/logging"
|
||||
)
|
||||
|
||||
|
@ -87,6 +88,8 @@ func SetNetworkProxy(proxyURL string) {
|
|||
} else {
|
||||
logging.LogInfof("use network proxy [system]")
|
||||
}
|
||||
|
||||
httpclient.CloseIdleConnections()
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
|
@ -54,6 +54,7 @@ func Boot() {
|
|||
IncBootProgress(3, "Booting...")
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
initMime()
|
||||
initHttpClient()
|
||||
|
||||
workspacePath := flag.String("workspace", "", "dir path of the workspace, default to ~/Documents/SiYuan/")
|
||||
wdPath := flag.String("wd", WorkingDir, "working directory of SiYuan")
|
||||
|
|
|
@ -32,6 +32,7 @@ func BootMobile(container, appDir, workspaceDir, nativeLibDir, privateDataDir, l
|
|||
IncBootProgress(3, "Booting...")
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
initMime()
|
||||
initHttpClient()
|
||||
|
||||
HomeDir = filepath.Join(workspaceDir, "home")
|
||||
userHomeConfDir := filepath.Join(HomeDir, ".config", "siyuan")
|
||||
|
|
Loading…
Add table
Reference in a new issue