Make work with http proxy
This commit is contained in:
parent
bf0542bf18
commit
952584e064
@ -754,6 +754,7 @@ func (cfg *HTTPProxyConf) UnmarshalFromMsg(pMsg *msg.NewProxy) {
|
||||
cfg.HostHeaderRewrite = pMsg.HostHeaderRewrite
|
||||
cfg.HTTPUser = pMsg.HTTPUser
|
||||
cfg.HTTPPwd = pMsg.HTTPPwd
|
||||
cfg.HashedPwd = pMsg.HashedPwd
|
||||
cfg.Headers = pMsg.Headers
|
||||
}
|
||||
|
||||
@ -767,6 +768,7 @@ func (cfg *HTTPProxyConf) MarshalToMsg(pMsg *msg.NewProxy) {
|
||||
pMsg.HostHeaderRewrite = cfg.HostHeaderRewrite
|
||||
pMsg.HTTPUser = cfg.HTTPUser
|
||||
pMsg.HTTPPwd = cfg.HTTPPwd
|
||||
pMsg.HashedPwd = cfg.HashedPwd
|
||||
pMsg.Headers = cfg.Headers
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,7 @@ type NewProxy struct {
|
||||
Locations []string `json:"locations"`
|
||||
HTTPUser string `json:"http_user"`
|
||||
HTTPPwd string `json:"http_pwd"`
|
||||
HashedPwd bool `json:"hashed_pwd"`
|
||||
HostHeaderRewrite string `json:"host_header_rewrite"`
|
||||
Headers map[string]string `json:"headers"`
|
||||
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
|
||||
frpLog "github.com/fatedier/frp/pkg/util/log"
|
||||
"github.com/fatedier/frp/pkg/util/util"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"github.com/fatedier/golib/pool"
|
||||
)
|
||||
@ -154,7 +155,14 @@ func (rp *HTTPReverseProxy) CheckAuth(domain, location, user, passwd string) boo
|
||||
if ok {
|
||||
checkUser := vr.payload.(*RouteConfig).Username
|
||||
checkPasswd := vr.payload.(*RouteConfig).Password
|
||||
if (checkUser != "" || checkPasswd != "") && (checkUser != user || checkPasswd != passwd) {
|
||||
hashed := vr.payload.(*RouteConfig).Hashed
|
||||
var correctPwd bool
|
||||
if hashed {
|
||||
correctPwd = bcrypt.CompareHashAndPassword([]byte(checkPasswd), []byte(passwd)) == nil
|
||||
} else {
|
||||
correctPwd = checkPasswd == passwd
|
||||
}
|
||||
if (checkUser != "" || checkPasswd != "") && (checkUser != user || !correctPwd) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ type RouteConfig struct {
|
||||
Headers map[string]string
|
||||
|
||||
CreateConnFn CreateConnFunc
|
||||
Hashed bool
|
||||
}
|
||||
|
||||
// listen for a new domain name, if rewriteHost is not empty and rewriteFunc is not nil
|
||||
|
@ -43,6 +43,7 @@ func (pxy *HTTPProxy) Run() (remoteAddr string, err error) {
|
||||
Username: pxy.cfg.HTTPUser,
|
||||
Password: pxy.cfg.HTTPPwd,
|
||||
CreateConnFn: pxy.GetRealConn,
|
||||
Hashed: pxy.cfg.HashedPwd,
|
||||
}
|
||||
|
||||
locations := pxy.cfg.Locations
|
||||
|
Loading…
Reference in New Issue
Block a user