mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
vhost: check host and location for url router
This commit is contained in:
parent
8bf61d5e39
commit
04a4591caa
@ -271,6 +271,8 @@ func (p *ProxyServer) Start(c *conn.Conn) (err error) {
|
||||
|
||||
func (p *ProxyServer) Close() {
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
|
||||
if p.Status != consts.Closed {
|
||||
p.Status = consts.Closed
|
||||
for _, l := range p.listeners {
|
||||
@ -298,7 +300,6 @@ func (p *ProxyServer) Close() {
|
||||
if p.PrivilegeMode {
|
||||
DeleteProxy(p.Name)
|
||||
}
|
||||
p.Unlock()
|
||||
}
|
||||
|
||||
func (p *ProxyServer) WaitUserConn() (closeFlag bool) {
|
||||
|
@ -82,6 +82,24 @@ func (r *VhostRouters) Get(host, path string) (vr *VhostRouter, exist bool) {
|
||||
return
|
||||
}
|
||||
|
||||
func (r *VhostRouters) Exist(host, path string) (vr *VhostRouter, exist bool) {
|
||||
r.mutex.RLock()
|
||||
defer r.mutex.RUnlock()
|
||||
|
||||
vrs, found := r.RouterByDomain[host]
|
||||
if !found {
|
||||
return
|
||||
}
|
||||
|
||||
for _, vr = range vrs {
|
||||
if path == vr.location {
|
||||
return vr, true
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// sort by location
|
||||
type ByLocation []*VhostRouter
|
||||
|
||||
|
@ -56,6 +56,11 @@ func (v *VhostMuxer) Listen(name, location, rewriteHost, userName, passWord stri
|
||||
v.mutex.Lock()
|
||||
defer v.mutex.Unlock()
|
||||
|
||||
_, ok := v.registryRouter.Exist(name, location)
|
||||
if ok {
|
||||
return nil, fmt.Errorf("hostname [%s] location [%s] is already registered", name, location)
|
||||
}
|
||||
|
||||
l = &Listener{
|
||||
name: name,
|
||||
rewriteHost: rewriteHost,
|
||||
|
Loading…
Reference in New Issue
Block a user