mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
commit
3f9749488a
@ -497,3 +497,4 @@ Donate money by [paypal](https://www.paypal.me/fatedier) to my account **fatedie
|
|||||||
* [Manfred Touron](https://github.com/moul)
|
* [Manfred Touron](https://github.com/moul)
|
||||||
* [xuebing1110](https://github.com/xuebing1110)
|
* [xuebing1110](https://github.com/xuebing1110)
|
||||||
* [Anbitioner](https://github.com/bingtianbaihua)
|
* [Anbitioner](https://github.com/bingtianbaihua)
|
||||||
|
* [LitleCarl](https://github.com/LitleCarl)
|
||||||
|
@ -516,3 +516,4 @@ frp 交流群:606194980 (QQ 群号)
|
|||||||
* [Manfred Touron](https://github.com/moul)
|
* [Manfred Touron](https://github.com/moul)
|
||||||
* [xuebing1110](https://github.com/xuebing1110)
|
* [xuebing1110](https://github.com/xuebing1110)
|
||||||
* [Anbitioner](https://github.com/bingtianbaihua)
|
* [Anbitioner](https://github.com/bingtianbaihua)
|
||||||
|
* [LitleCarl](https://github.com/LitleCarl)
|
||||||
|
@ -268,6 +268,20 @@ func doLogin(req *msg.ControlReq, c *conn.Conn) (ret int64, info string, s *serv
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.SubDomain != "" {
|
||||||
|
if strings.Contains(s.SubDomain, ".") || strings.Contains(s.SubDomain, "*") {
|
||||||
|
info = fmt.Sprintf("ProxyName [%s], '.' and '*' is not supported in subdomain", req.ProxyName)
|
||||||
|
log.Warn(info)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if server.SubDomainHost == "" {
|
||||||
|
info = fmt.Sprintf("ProxyName [%s], subdomain is not supported because this feature is not enabled by remote server", req.ProxyName)
|
||||||
|
log.Warn(info)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s.SubDomain = s.SubDomain + "." + server.SubDomainHost
|
||||||
|
}
|
||||||
}
|
}
|
||||||
err := server.CreateProxy(s)
|
err := server.CreateProxy(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -297,20 +311,6 @@ func doLogin(req *msg.ControlReq, c *conn.Conn) (ret int64, info string, s *serv
|
|||||||
s.HttpUserName = req.HttpUserName
|
s.HttpUserName = req.HttpUserName
|
||||||
s.HttpPassWord = req.HttpPassWord
|
s.HttpPassWord = req.HttpPassWord
|
||||||
|
|
||||||
// package URL
|
|
||||||
if req.SubDomain != "" {
|
|
||||||
if strings.Contains(req.SubDomain, ".") || strings.Contains(req.SubDomain, "*") {
|
|
||||||
info = fmt.Sprintf("ProxyName [%s], '.' or '*' is not supported in subdomain", req.ProxyName)
|
|
||||||
log.Warn(info)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if server.SubDomainHost == "" {
|
|
||||||
info = fmt.Sprintf("ProxyName [%s], subdomain in not supported because this feature is not enabled by remote server", req.ProxyName)
|
|
||||||
log.Warn(info)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.SubDomain = req.SubDomain + "." + server.SubDomainHost
|
|
||||||
}
|
|
||||||
if req.PoolCount > server.MaxPoolCount {
|
if req.PoolCount > server.MaxPoolCount {
|
||||||
s.PoolCount = server.MaxPoolCount
|
s.PoolCount = server.MaxPoolCount
|
||||||
} else if req.PoolCount < 0 {
|
} else if req.PoolCount < 0 {
|
||||||
|
@ -243,44 +243,48 @@ func LoadConf(confFile string) (err error) {
|
|||||||
}
|
}
|
||||||
} else if proxyClient.Type == "http" {
|
} else if proxyClient.Type == "http" {
|
||||||
// custom_domains
|
// custom_domains
|
||||||
domainStr, ok := section["custom_domains"]
|
tmpStr, ok = section["custom_domains"]
|
||||||
if ok {
|
if ok {
|
||||||
proxyClient.CustomDomains = strings.Split(domainStr, ",")
|
proxyClient.CustomDomains = strings.Split(tmpStr, ",")
|
||||||
if len(proxyClient.CustomDomains) == 0 {
|
for i, domain := range proxyClient.CustomDomains {
|
||||||
ok = false
|
proxyClient.CustomDomains[i] = strings.ToLower(strings.TrimSpace(domain))
|
||||||
} else {
|
|
||||||
for i, domain := range proxyClient.CustomDomains {
|
|
||||||
proxyClient.CustomDomains[i] = strings.ToLower(strings.TrimSpace(domain))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ok && proxyClient.SubDomain == "" {
|
// subdomain
|
||||||
|
tmpStr, ok = section["subdomain"]
|
||||||
|
if ok {
|
||||||
|
proxyClient.SubDomain = tmpStr
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(proxyClient.CustomDomains) == 0 && proxyClient.SubDomain == "" {
|
||||||
return fmt.Errorf("Parse conf error: proxy [%s] custom_domains and subdomain should set at least one of them when type is http", proxyClient.Name)
|
return fmt.Errorf("Parse conf error: proxy [%s] custom_domains and subdomain should set at least one of them when type is http", proxyClient.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// locations
|
// locations
|
||||||
locations, ok := section["locations"]
|
tmpStr, ok = section["locations"]
|
||||||
if ok {
|
if ok {
|
||||||
proxyClient.Locations = strings.Split(locations, ",")
|
proxyClient.Locations = strings.Split(tmpStr, ",")
|
||||||
} else {
|
} else {
|
||||||
proxyClient.Locations = []string{""}
|
proxyClient.Locations = []string{""}
|
||||||
}
|
}
|
||||||
} else if proxyClient.Type == "https" {
|
} else if proxyClient.Type == "https" {
|
||||||
// custom_domains
|
// custom_domains
|
||||||
domainStr, ok := section["custom_domains"]
|
tmpStr, ok = section["custom_domains"]
|
||||||
if ok {
|
if ok {
|
||||||
proxyClient.CustomDomains = strings.Split(domainStr, ",")
|
proxyClient.CustomDomains = strings.Split(tmpStr, ",")
|
||||||
if len(proxyClient.CustomDomains) == 0 {
|
for i, domain := range proxyClient.CustomDomains {
|
||||||
ok = false
|
proxyClient.CustomDomains[i] = strings.ToLower(strings.TrimSpace(domain))
|
||||||
} else {
|
|
||||||
for i, domain := range proxyClient.CustomDomains {
|
|
||||||
proxyClient.CustomDomains[i] = strings.ToLower(strings.TrimSpace(domain))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ok && proxyClient.SubDomain == "" {
|
// subdomain
|
||||||
|
tmpStr, ok = section["subdomain"]
|
||||||
|
if ok {
|
||||||
|
proxyClient.SubDomain = tmpStr
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(proxyClient.CustomDomains) == 0 && proxyClient.SubDomain == "" {
|
||||||
return fmt.Errorf("Parse conf error: proxy [%s] custom_domains and subdomain should set at least one of them when type is https", proxyClient.Name)
|
return fmt.Errorf("Parse conf error: proxy [%s] custom_domains and subdomain should set at least one of them when type is https", proxyClient.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,9 +300,6 @@ func loadProxyConf(confFile string) (proxyServers map[string]*ProxyServer, err e
|
|||||||
domainStr, ok := section["custom_domains"]
|
domainStr, ok := section["custom_domains"]
|
||||||
if ok {
|
if ok {
|
||||||
proxyServer.CustomDomains = strings.Split(domainStr, ",")
|
proxyServer.CustomDomains = strings.Split(domainStr, ",")
|
||||||
if len(proxyServer.CustomDomains) == 0 {
|
|
||||||
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] custom_domains must be set when type is http", proxyServer.Name)
|
|
||||||
}
|
|
||||||
for i, domain := range proxyServer.CustomDomains {
|
for i, domain := range proxyServer.CustomDomains {
|
||||||
domain = strings.ToLower(strings.TrimSpace(domain))
|
domain = strings.ToLower(strings.TrimSpace(domain))
|
||||||
// custom domain should not belong to subdomain_host
|
// custom domain should not belong to subdomain_host
|
||||||
@ -311,8 +308,23 @@ func loadProxyConf(confFile string) (proxyServers map[string]*ProxyServer, err e
|
|||||||
}
|
}
|
||||||
proxyServer.CustomDomains[i] = domain
|
proxyServer.CustomDomains[i] = domain
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] custom_domains must be set when type is http", proxyServer.Name)
|
|
||||||
|
// subdomain
|
||||||
|
subdomainStr, ok := section["subdomain"]
|
||||||
|
if ok {
|
||||||
|
if strings.Contains(subdomainStr, ".") || strings.Contains(subdomainStr, "*") {
|
||||||
|
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] '.' and '*' is not supported in subdomain", proxyServer.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if SubDomainHost == "" {
|
||||||
|
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] subdomain is not supported because subdomain_host is empty", proxyServer.Name)
|
||||||
|
}
|
||||||
|
proxyServer.SubDomain = subdomainStr + "." + SubDomainHost
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(proxyServer.CustomDomains) == 0 && proxyServer.SubDomain == "" {
|
||||||
|
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] custom_domains and subdomain should set at least one of them when type is http", proxyServer.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// locations
|
// locations
|
||||||
@ -329,9 +341,6 @@ func loadProxyConf(confFile string) (proxyServers map[string]*ProxyServer, err e
|
|||||||
domainStr, ok := section["custom_domains"]
|
domainStr, ok := section["custom_domains"]
|
||||||
if ok {
|
if ok {
|
||||||
proxyServer.CustomDomains = strings.Split(domainStr, ",")
|
proxyServer.CustomDomains = strings.Split(domainStr, ",")
|
||||||
if len(proxyServer.CustomDomains) == 0 {
|
|
||||||
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] custom_domains must be set when type is https", proxyServer.Name)
|
|
||||||
}
|
|
||||||
for i, domain := range proxyServer.CustomDomains {
|
for i, domain := range proxyServer.CustomDomains {
|
||||||
domain = strings.ToLower(strings.TrimSpace(domain))
|
domain = strings.ToLower(strings.TrimSpace(domain))
|
||||||
if SubDomainHost != "" && strings.Contains(domain, SubDomainHost) {
|
if SubDomainHost != "" && strings.Contains(domain, SubDomainHost) {
|
||||||
@ -339,8 +348,23 @@ func loadProxyConf(confFile string) (proxyServers map[string]*ProxyServer, err e
|
|||||||
}
|
}
|
||||||
proxyServer.CustomDomains[i] = domain
|
proxyServer.CustomDomains[i] = domain
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] custom_domains must be set when type is https", proxyServer.Name)
|
|
||||||
|
// subdomain
|
||||||
|
subdomainStr, ok := section["subdomain"]
|
||||||
|
if ok {
|
||||||
|
if strings.Contains(subdomainStr, ".") || strings.Contains(subdomainStr, "*") {
|
||||||
|
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] '.' and '*' is not supported in subdomain", proxyServer.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if SubDomainHost == "" {
|
||||||
|
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] subdomain is not supported because subdomain_host is empty", proxyServer.Name)
|
||||||
|
}
|
||||||
|
proxyServer.SubDomain = subdomainStr + "." + SubDomainHost
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(proxyServer.CustomDomains) == 0 && proxyServer.SubDomain == "" {
|
||||||
|
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] custom_domains and subdomain should set at least one of them when type is https", proxyServer.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
proxyServers[proxyServer.Name] = proxyServer
|
proxyServers[proxyServer.Name] = proxyServer
|
||||||
|
@ -79,6 +79,7 @@ func NewProxyServerFromCtlMsg(req *msg.ControlReq) (p *ProxyServer) {
|
|||||||
p.ListenPort = VhostHttpsPort
|
p.ListenPort = VhostHttpsPort
|
||||||
}
|
}
|
||||||
p.CustomDomains = req.CustomDomains
|
p.CustomDomains = req.CustomDomains
|
||||||
|
p.SubDomain = req.SubDomain
|
||||||
p.Locations = req.Locations
|
p.Locations = req.Locations
|
||||||
p.HostHeaderRewrite = req.HostHeaderRewrite
|
p.HostHeaderRewrite = req.HostHeaderRewrite
|
||||||
p.HttpUserName = req.HttpUserName
|
p.HttpUserName = req.HttpUserName
|
||||||
@ -285,7 +286,7 @@ func (p *ProxyServer) Close() {
|
|||||||
p.Release()
|
p.Release()
|
||||||
|
|
||||||
// if the proxy created by PrivilegeMode, delete it when closed
|
// if the proxy created by PrivilegeMode, delete it when closed
|
||||||
if p.PrivilegeMode && oldStatus != consts.Closed {
|
if p.PrivilegeMode && oldStatus == consts.Working {
|
||||||
// NOTE: this will take the global ProxyServerMap's lock
|
// NOTE: this will take the global ProxyServerMap's lock
|
||||||
// if we only want to release resources, use Release() instead
|
// if we only want to release resources, use Release() instead
|
||||||
DeleteProxy(p.Name)
|
DeleteProxy(p.Name)
|
||||||
@ -444,6 +445,12 @@ func (p *ProxyServer) getWorkConn() (workConn *conn.Conn, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProxyServer) connectionPoolManager(closeCh <-chan struct{}) {
|
func (p *ProxyServer) connectionPoolManager(closeCh <-chan struct{}) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
log.Warn("ProxyName [%s], connectionPoolManager panic %v", p.Name, r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
// check if we need more work connections and send messages to frpc to get more
|
// check if we need more work connections and send messages to frpc to get more
|
||||||
time.Sleep(time.Duration(2) * time.Second)
|
time.Sleep(time.Duration(2) * time.Second)
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version string = "0.9.2"
|
var version string = "0.9.3"
|
||||||
|
|
||||||
func Full() string {
|
func Full() string {
|
||||||
return version
|
return version
|
||||||
|
Loading…
Reference in New Issue
Block a user