Skip to content

Commit 3f97494

Browse files
authored
Merge pull request #238 from fatedier/dev
bump version to 0.9.3
2 parents edb97ab + f9a0d89 commit 3f97494

File tree

7 files changed

+83
-46
lines changed

7 files changed

+83
-46
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -497,3 +497,4 @@ Donate money by [paypal](https://www.paypal.me/fatedier) to my account **fatedie
497497
* [Manfred Touron](https://github.com/moul)
498498
* [xuebing1110](https://github.com/xuebing1110)
499499
* [Anbitioner](https://github.com/bingtianbaihua)
500+
* [LitleCarl](https://github.com/LitleCarl)

Diff for: README_zh.md

+1
Original file line numberDiff line numberDiff line change
@@ -516,3 +516,4 @@ frp 交流群:606194980 (QQ 群号)
516516
* [Manfred Touron](https://github.com/moul)
517517
* [xuebing1110](https://github.com/xuebing1110)
518518
* [Anbitioner](https://github.com/bingtianbaihua)
519+
* [LitleCarl](https://github.com/LitleCarl)

Diff for: src/cmd/frps/control.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,20 @@ func doLogin(req *msg.ControlReq, c *conn.Conn) (ret int64, info string, s *serv
268268
return
269269
}
270270
}
271+
272+
if s.SubDomain != "" {
273+
if strings.Contains(s.SubDomain, ".") || strings.Contains(s.SubDomain, "*") {
274+
info = fmt.Sprintf("ProxyName [%s], '.' and '*' is not supported in subdomain", req.ProxyName)
275+
log.Warn(info)
276+
return
277+
}
278+
if server.SubDomainHost == "" {
279+
info = fmt.Sprintf("ProxyName [%s], subdomain is not supported because this feature is not enabled by remote server", req.ProxyName)
280+
log.Warn(info)
281+
return
282+
}
283+
s.SubDomain = s.SubDomain + "." + server.SubDomainHost
284+
}
271285
}
272286
err := server.CreateProxy(s)
273287
if err != nil {
@@ -297,20 +311,6 @@ func doLogin(req *msg.ControlReq, c *conn.Conn) (ret int64, info string, s *serv
297311
s.HttpUserName = req.HttpUserName
298312
s.HttpPassWord = req.HttpPassWord
299313

300-
// package URL
301-
if req.SubDomain != "" {
302-
if strings.Contains(req.SubDomain, ".") || strings.Contains(req.SubDomain, "*") {
303-
info = fmt.Sprintf("ProxyName [%s], '.' or '*' is not supported in subdomain", req.ProxyName)
304-
log.Warn(info)
305-
return
306-
}
307-
if server.SubDomainHost == "" {
308-
info = fmt.Sprintf("ProxyName [%s], subdomain in not supported because this feature is not enabled by remote server", req.ProxyName)
309-
log.Warn(info)
310-
return
311-
}
312-
s.SubDomain = req.SubDomain + "." + server.SubDomainHost
313-
}
314314
if req.PoolCount > server.MaxPoolCount {
315315
s.PoolCount = server.MaxPoolCount
316316
} else if req.PoolCount < 0 {

Diff for: src/models/client/config.go

+24-20
Original file line numberDiff line numberDiff line change
@@ -243,44 +243,48 @@ func LoadConf(confFile string) (err error) {
243243
}
244244
} else if proxyClient.Type == "http" {
245245
// custom_domains
246-
domainStr, ok := section["custom_domains"]
246+
tmpStr, ok = section["custom_domains"]
247247
if ok {
248-
proxyClient.CustomDomains = strings.Split(domainStr, ",")
249-
if len(proxyClient.CustomDomains) == 0 {
250-
ok = false
251-
} else {
252-
for i, domain := range proxyClient.CustomDomains {
253-
proxyClient.CustomDomains[i] = strings.ToLower(strings.TrimSpace(domain))
254-
}
248+
proxyClient.CustomDomains = strings.Split(tmpStr, ",")
249+
for i, domain := range proxyClient.CustomDomains {
250+
proxyClient.CustomDomains[i] = strings.ToLower(strings.TrimSpace(domain))
255251
}
256252
}
257253

258-
if !ok && proxyClient.SubDomain == "" {
254+
// subdomain
255+
tmpStr, ok = section["subdomain"]
256+
if ok {
257+
proxyClient.SubDomain = tmpStr
258+
}
259+
260+
if len(proxyClient.CustomDomains) == 0 && proxyClient.SubDomain == "" {
259261
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)
260262
}
261263

262264
// locations
263-
locations, ok := section["locations"]
265+
tmpStr, ok = section["locations"]
264266
if ok {
265-
proxyClient.Locations = strings.Split(locations, ",")
267+
proxyClient.Locations = strings.Split(tmpStr, ",")
266268
} else {
267269
proxyClient.Locations = []string{""}
268270
}
269271
} else if proxyClient.Type == "https" {
270272
// custom_domains
271-
domainStr, ok := section["custom_domains"]
273+
tmpStr, ok = section["custom_domains"]
272274
if ok {
273-
proxyClient.CustomDomains = strings.Split(domainStr, ",")
274-
if len(proxyClient.CustomDomains) == 0 {
275-
ok = false
276-
} else {
277-
for i, domain := range proxyClient.CustomDomains {
278-
proxyClient.CustomDomains[i] = strings.ToLower(strings.TrimSpace(domain))
279-
}
275+
proxyClient.CustomDomains = strings.Split(tmpStr, ",")
276+
for i, domain := range proxyClient.CustomDomains {
277+
proxyClient.CustomDomains[i] = strings.ToLower(strings.TrimSpace(domain))
280278
}
281279
}
282280

283-
if !ok && proxyClient.SubDomain == "" {
281+
// subdomain
282+
tmpStr, ok = section["subdomain"]
283+
if ok {
284+
proxyClient.SubDomain = tmpStr
285+
}
286+
287+
if len(proxyClient.CustomDomains) == 0 && proxyClient.SubDomain == "" {
284288
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)
285289
}
286290
}

Diff for: src/models/server/config.go

+34-10
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,6 @@ func loadProxyConf(confFile string) (proxyServers map[string]*ProxyServer, err e
300300
domainStr, ok := section["custom_domains"]
301301
if ok {
302302
proxyServer.CustomDomains = strings.Split(domainStr, ",")
303-
if len(proxyServer.CustomDomains) == 0 {
304-
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] custom_domains must be set when type is http", proxyServer.Name)
305-
}
306303
for i, domain := range proxyServer.CustomDomains {
307304
domain = strings.ToLower(strings.TrimSpace(domain))
308305
// custom domain should not belong to subdomain_host
@@ -311,8 +308,23 @@ func loadProxyConf(confFile string) (proxyServers map[string]*ProxyServer, err e
311308
}
312309
proxyServer.CustomDomains[i] = domain
313310
}
314-
} else {
315-
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] custom_domains must be set when type is http", proxyServer.Name)
311+
}
312+
313+
// subdomain
314+
subdomainStr, ok := section["subdomain"]
315+
if ok {
316+
if strings.Contains(subdomainStr, ".") || strings.Contains(subdomainStr, "*") {
317+
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] '.' and '*' is not supported in subdomain", proxyServer.Name)
318+
}
319+
320+
if SubDomainHost == "" {
321+
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] subdomain is not supported because subdomain_host is empty", proxyServer.Name)
322+
}
323+
proxyServer.SubDomain = subdomainStr + "." + SubDomainHost
324+
}
325+
326+
if len(proxyServer.CustomDomains) == 0 && proxyServer.SubDomain == "" {
327+
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)
316328
}
317329

318330
// locations
@@ -329,18 +341,30 @@ func loadProxyConf(confFile string) (proxyServers map[string]*ProxyServer, err e
329341
domainStr, ok := section["custom_domains"]
330342
if ok {
331343
proxyServer.CustomDomains = strings.Split(domainStr, ",")
332-
if len(proxyServer.CustomDomains) == 0 {
333-
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] custom_domains must be set when type is https", proxyServer.Name)
334-
}
335344
for i, domain := range proxyServer.CustomDomains {
336345
domain = strings.ToLower(strings.TrimSpace(domain))
337346
if SubDomainHost != "" && strings.Contains(domain, SubDomainHost) {
338347
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] custom domain should not belong to subdomain_host", proxyServer.Name)
339348
}
340349
proxyServer.CustomDomains[i] = domain
341350
}
342-
} else {
343-
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] custom_domains must be set when type is https", proxyServer.Name)
351+
}
352+
353+
// subdomain
354+
subdomainStr, ok := section["subdomain"]
355+
if ok {
356+
if strings.Contains(subdomainStr, ".") || strings.Contains(subdomainStr, "*") {
357+
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] '.' and '*' is not supported in subdomain", proxyServer.Name)
358+
}
359+
360+
if SubDomainHost == "" {
361+
return proxyServers, fmt.Errorf("Parse conf error: proxy [%s] subdomain is not supported because subdomain_host is empty", proxyServer.Name)
362+
}
363+
proxyServer.SubDomain = subdomainStr + "." + SubDomainHost
364+
}
365+
366+
if len(proxyServer.CustomDomains) == 0 && proxyServer.SubDomain == "" {
367+
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)
344368
}
345369
}
346370
proxyServers[proxyServer.Name] = proxyServer

Diff for: src/models/server/server.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func NewProxyServerFromCtlMsg(req *msg.ControlReq) (p *ProxyServer) {
7979
p.ListenPort = VhostHttpsPort
8080
}
8181
p.CustomDomains = req.CustomDomains
82+
p.SubDomain = req.SubDomain
8283
p.Locations = req.Locations
8384
p.HostHeaderRewrite = req.HostHeaderRewrite
8485
p.HttpUserName = req.HttpUserName
@@ -285,7 +286,7 @@ func (p *ProxyServer) Close() {
285286
p.Release()
286287

287288
// if the proxy created by PrivilegeMode, delete it when closed
288-
if p.PrivilegeMode && oldStatus != consts.Closed {
289+
if p.PrivilegeMode && oldStatus == consts.Working {
289290
// NOTE: this will take the global ProxyServerMap's lock
290291
// if we only want to release resources, use Release() instead
291292
DeleteProxy(p.Name)
@@ -444,6 +445,12 @@ func (p *ProxyServer) getWorkConn() (workConn *conn.Conn, err error) {
444445
}
445446

446447
func (p *ProxyServer) connectionPoolManager(closeCh <-chan struct{}) {
448+
defer func() {
449+
if r := recover(); r != nil {
450+
log.Warn("ProxyName [%s], connectionPoolManager panic %v", p.Name, r)
451+
}
452+
}()
453+
447454
for {
448455
// check if we need more work connections and send messages to frpc to get more
449456
time.Sleep(time.Duration(2) * time.Second)

Diff for: src/utils/version/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"strings"
2020
)
2121

22-
var version string = "0.9.2"
22+
var version string = "0.9.3"
2323

2424
func Full() string {
2525
return version

0 commit comments

Comments
 (0)