Skip to content

Commit

Permalink
feat: 启用外网访问, 必须输入登录用户名/密码
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessy2 committed Sep 27, 2022
1 parent 0b4002a commit 0a3f300
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions web/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func Save(writer http.ResponseWriter, request *http.Request) {

conf, _ := config.GetConfigCache()

idNew := request.FormValue("DnsID")
secretNew := request.FormValue("DnsSecret")
idNew := strings.TrimSpace(request.FormValue("DnsID"))
secretNew := strings.TrimSpace(request.FormValue("DnsSecret"))

idHide, secretHide := getHideIDSecret(&conf)

Expand Down Expand Up @@ -51,6 +51,12 @@ func Save(writer http.ResponseWriter, request *http.Request) {
conf.NotAllowWanAccess = request.FormValue("NotAllowWanAccess") == "on"
conf.TTL = request.FormValue("TTL")

// 如启用公网访问,帐号密码不能为空
if !conf.NotAllowWanAccess && (conf.Username == "" || conf.Password == "") {
writer.Write([]byte("启用外网访问, 必须输入登录用户名/密码"))
return
}

// 保存到用户目录
err := conf.SaveConfig()

Expand Down

0 comments on commit 0a3f300

Please sign in to comment.