Skip to content

Commit

Permalink
fix(proxy): change whitelist-domain setting get function
Browse files Browse the repository at this point in the history
  • Loading branch information
JacieChao committed May 26, 2023
1 parent e4f13c2 commit 24e5006
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions pkg/server/proxy/http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ import (
"regexp"
"strings"

"github.com/cnrancher/autok3s/pkg/common"
"github.com/cnrancher/autok3s/pkg/settings"

"github.com/sirupsen/logrus"
utilnet "k8s.io/apimachinery/pkg/util/net"
)

const (
forwardProto = "X-Forwarded-Proto"
whiteListDomainSettingName = "whitelist-domain"
hostRegex = "[A-Za-z0-9-]+"
forwardProto = "X-Forwarded-Proto"
hostRegex = "[A-Za-z0-9-]+"
)

var (
Expand Down Expand Up @@ -51,12 +50,7 @@ func NewProxy(prefix string) http.Handler {
}

func (p *proxy) isAllowed(host string) bool {
setting, err := common.DefaultDB.GetSetting(whiteListDomainSettingName)
if err != nil || setting == nil {
logrus.Errorf("failed to get whitelist-domain setting, err %v", err)
return false
}
validHosts := strings.Split(setting.Value, ",")
validHosts := strings.Split(settings.WhitelistDomain.Get(), ",")
for _, valid := range validHosts {
if valid == host {
return true
Expand Down

0 comments on commit 24e5006

Please sign in to comment.