Skip to content

Commit

Permalink
fix: need to parse the referer (#1204)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessy2 authored Aug 1, 2024
1 parent e881d5b commit 23277cc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion web/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"html/template"
"net/http"
"net/url"
"time"

"github.com/jeessy2/ddns-go/v6/config"
Expand Down Expand Up @@ -95,8 +96,10 @@ func LoginFunc(w http.ResponseWriter, r *http.Request) {
returnError(w, util.LogStr("需在 %s 之前完成用户名密码设置,请重启ddns-go", startTime.Add(saveLimit).Format("2006-01-02 15:04:05")))
return
}

conf.NotAllowWanAccess = true
if !util.IsPrivateNetwork(r.Header.Get("referer")) {
u, err := url.Parse(r.Header.Get("referer"))
if err == nil && !util.IsPrivateNetwork(u.Host) {
conf.NotAllowWanAccess = false
}

Expand Down

0 comments on commit 23277cc

Please sign in to comment.