Skip to content

Commit e3c664f

Browse files
jyxjjjKirCute
andauthored
Merge commit from fork
Co-authored-by: KirCute <951206789@qq.com>
1 parent 7b78fed commit e3c664f

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

internal/bootstrap/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func InitConfig() {
5454
}
5555
}
5656
configPath = filepath.Clean(configPath)
57+
conf.ConfigPath = configPath
5758
log.Infof("reading config file: %s", configPath)
5859
if !utils.Exists(configPath) {
5960
log.Infof("config file not exists, creating default config file")

internal/bootstrap/patch/all.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ var UpgradePatches = []VersionPatches{
4444
Version: "v4.1.9",
4545
Patches: []func(){
4646
v4_1_9.EnableWebDavProxy,
47+
v4_1_9.ResetSkipTlsVerify,
4748
},
4849
},
4950
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package v4_1_9
2+
3+
import (
4+
"os"
5+
"strings"
6+
7+
"github.com/OpenListTeam/OpenList/v4/internal/conf"
8+
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
9+
)
10+
11+
func ResetSkipTlsVerify() {
12+
if !conf.Conf.TlsInsecureSkipVerify {
13+
return
14+
}
15+
if !strings.HasPrefix(conf.Version, "v") {
16+
return
17+
}
18+
19+
conf.Conf.TlsInsecureSkipVerify = false
20+
21+
confBody, err := utils.Json.MarshalIndent(conf.Conf, "", " ")
22+
if err != nil {
23+
utils.Log.Errorf("[ResetSkipTlsVerify] failed to rewrite config: marshal config error: %+v", err)
24+
return
25+
}
26+
err = os.WriteFile(conf.ConfigPath, confBody, 0o777)
27+
if err != nil {
28+
utils.Log.Errorf("[ResetSkipTlsVerify] failed to rewrite config: update config struct error: %+v", err)
29+
return
30+
}
31+
utils.Log.Infof("[ResetSkipTlsVerify] succeeded to set tls_insecure_skip_verify to false")
32+
}

internal/conf/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func DefaultConfig(dataDir string) *Config {
182182
MmapThreshold: 4,
183183
MaxConnections: 0,
184184
MaxConcurrency: 64,
185-
TlsInsecureSkipVerify: true,
185+
TlsInsecureSkipVerify: false,
186186
Tasks: TasksConfig{
187187
Download: TaskConfig{
188188
Workers: 5,

internal/conf/var.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ var (
1515
)
1616

1717
var (
18-
Conf *Config
19-
URL *url.URL
18+
Conf *Config
19+
URL *url.URL
20+
ConfigPath string
2021
)
2122

2223
var SlicesMap = make(map[string][]string)

0 commit comments

Comments
 (0)