From 329b1b154335995c0efff3e0fd907726e43460ef Mon Sep 17 00:00:00 2001 From: John Date: Mon, 23 Apr 2018 14:20:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E9=9D=99=E6=80=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9B=AE=E5=BD=95=E5=AE=89=E5=85=A8=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RELEASE | 2 +- g/net/ghttp/http_server_handler.go | 3 +-- g/os/grpool/grpool_api.go | 4 ++-- geg/net/ghttp/server1.go | 7 +++++-- geg/other/test.go | 10 ++++++++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/RELEASE b/RELEASE index 479a779d1..49181c4de 100644 --- a/RELEASE +++ b/RELEASE @@ -8,7 +8,7 @@ 7、 ghttp.Response去掉WriteString方法,统一使用Write方法返回数据流,是使用灵活的参数形式; 8、 模板引擎增加模板变量暴露接口LockFunc/RLockFunc,以便支持开发者灵活处理模板变量; 9、 ghttp.Server增加access & error log功能,并支持开发者自定义日志处理回调函数注册; - 10、 增加gredis包,支持对redis的客户端操作封装,并将gredis.Redis对象加入到gins单例管理器中进行统一配置管理维护; + 10、增加gredis包,支持对redis的客户端操作封装,并将gredis.Redis对象加入到gins单例管理器中进行统一配置管理维护; 11、gins单例管理器增加对单例对象配置文件的自动检测更新机制,当配置文件在外部发生变更时,自动刷新单例管理器中的单例对象; 12、gdb数据库ORM包增加And/Or条件链式方法,并改进Where/Data方法参数灵活性; 13、对于新增加的模块,同时也增加了对应的开发文档,并梳理完善了现有的其他模块开发文档; diff --git a/g/net/ghttp/http_server_handler.go b/g/net/ghttp/http_server_handler.go index 0523f3795..6c4e576c0 100644 --- a/g/net/ghttp/http_server_handler.go +++ b/g/net/ghttp/http_server_handler.go @@ -16,7 +16,6 @@ import ( "net/url" "net/http" "gitee.com/johng/gf/g/os/gfile" - "gitee.com/johng/gf/g/util/gregx" "gitee.com/johng/gf/g/encoding/ghtml" ) @@ -98,7 +97,7 @@ func (s *Server)serveFile(r *Request) { path = gfile.RealPath(path) if path != "" { // 文件/目录访问安全限制:服务的路径必须在ServerRoot下,否则会报错 - if gregx.IsMatchString("^" + s.config.ServerRoot, path) { + if len(path) >= len(s.config.ServerRoot) && strings.EqualFold(path[0 : len(s.config.ServerRoot)], s.config.ServerRoot) { s.doServeFile(r, path) } else { r.Response.WriteStatus(http.StatusForbidden) diff --git a/g/os/grpool/grpool_api.go b/g/os/grpool/grpool_api.go index e850296e6..7e7b98773 100644 --- a/g/os/grpool/grpool_api.go +++ b/g/os/grpool/grpool_api.go @@ -57,8 +57,8 @@ func New(expire int, size...int) *Pool { expire : int32(expire), queue : glist.New(), funcs : glist.New(), - freeEvents : make(chan struct{}, math.MaxUint32), - funcEvents : make(chan struct{}, math.MaxUint32), + freeEvents : make(chan struct{}, math.MaxInt32), + funcEvents : make(chan struct{}, math.MaxInt32), stopEvents : make(chan struct{}, runtime.GOMAXPROCS(-1) + 1), } p.startWorkLoop() diff --git a/geg/net/ghttp/server1.go b/geg/net/ghttp/server1.go index a8610b259..7474247b4 100644 --- a/geg/net/ghttp/server1.go +++ b/geg/net/ghttp/server1.go @@ -1,10 +1,13 @@ package main -import "gitee.com/johng/gf/g/net/ghttp" +import ( + "gitee.com/johng/gf/g/net/ghttp" +) func main() { s := ghttp.GetServer() s.SetIndexFolder(true) - s.SetServerRoot("/home/www/") + s.SetServerRoot("C:\\Documents and Settings\\Claymore\\桌面\\gf.test") + s.SetPort(8199) s.Run() } diff --git a/geg/other/test.go b/geg/other/test.go index 1ae0bf7a4..5231cdbb8 100644 --- a/geg/other/test.go +++ b/geg/other/test.go @@ -2,9 +2,15 @@ package main import ( "fmt" - "gitee.com/johng/gf/g/frame/gins" + "strings" ) func main() { - fmt.Println(gins.Config().GetString("database.default.0.host")) + s1 := `C:\Documents and Settings\Claymore\桌面\gf.test` + s2 := `C:\Documents and Settings\Claymore\桌面\gf.tes` + + + + + fmt.Println(len(s2) >= len(s1) && strings.EqualFold(s2[0 : len(s1)], s1) ) } \ No newline at end of file