Skip to content

Commit

Permalink
Update config name
Browse files Browse the repository at this point in the history
  • Loading branch information
cyp0633 committed Feb 28, 2023
1 parent 8673bf4 commit e3752c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions internal/util/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ var Conf struct {
}

// drcom-go 专有扩展配置
var ExtConf struct{
var ExtConf struct {
// 检查连接(204)使用的 URL
KeepaliveServer string
ConnectionTestServer string
}

// 解析配置文件
Expand Down Expand Up @@ -69,11 +69,12 @@ func ParseConf() {

// 扩展配置
ext := cfg.Section("extend")
if temp=ext.Key("keep_alive_server").String(); temp!="" {
ExtConf.KeepaliveServer = temp
if temp = ext.Key("connection_test_server").String(); temp != "" {
ExtConf.ConnectionTestServer = temp
} else {
ExtConf.KeepaliveServer = "https://connect.rom.miui.com/generate_204"
ExtConf.ConnectionTestServer = "https://connect.rom.miui.com/generate_204"
}
Logger.Debug("Extended configuration loaded", zap.Any("conf", ExtConf))
}

// 带有转义字符的字符串转换为 byte slice
Expand Down
2 changes: 1 addition & 1 deletion internal/util/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// CheckConnection 检查网络连接,如发现不通,向 ch 中发送信号
func CheckConnection(ch chan bool) {
for {
resp, err := http.Get(ExtConf.KeepaliveServer)
resp, err := http.Get(ExtConf.ConnectionTestServer)
if err != nil || resp.StatusCode != http.StatusNoContent {
ch <- true
Logger.Warn("Network connection lost", zap.Error(err))
Expand Down

0 comments on commit e3752c6

Please sign in to comment.