|
@@ -1,91 +1,91 @@
|
|
package filter
|
|
package filter
|
|
|
|
|
|
import (
|
|
import (
|
|
- "crypto/rsa"
|
|
|
|
- "github.com/bwmarrin/snowflake"
|
|
|
|
- . "jy/src/jfw/config"
|
|
|
|
- "jy/src/jfw/jyutil"
|
|
|
|
- "net/http"
|
|
|
|
- "regexp"
|
|
|
|
- "time"
|
|
|
|
|
|
+ "crypto/rsa"
|
|
|
|
+ "github.com/bwmarrin/snowflake"
|
|
|
|
+ . "jy/src/jfw/config"
|
|
|
|
+ "jy/src/jfw/jyutil"
|
|
|
|
+ "net/http"
|
|
|
|
+ "regexp"
|
|
|
|
+ "time"
|
|
|
|
|
|
- util "app.yhyue.com/moapp/jybase/common"
|
|
|
|
- fs "app.yhyue.com/moapp/jybase/fsnotify"
|
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
|
- fx "app.yhyue.com/moapp/jypkg/filter/xweb"
|
|
|
|
- "app.yhyue.com/moapp/jypkg/identity"
|
|
|
|
- "app.yhyue.com/moapp/jypkg/public"
|
|
|
|
|
|
+ util "app.yhyue.com/moapp/jybase/common"
|
|
|
|
+ fs "app.yhyue.com/moapp/jybase/fsnotify"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
|
+ fx "app.yhyue.com/moapp/jypkg/filter/xweb"
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/identity"
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/public"
|
|
)
|
|
)
|
|
|
|
|
|
var RouteConf struct {
|
|
var RouteConf struct {
|
|
- ExcludeRoute []string
|
|
|
|
|
|
+ ExcludeRoute []string
|
|
}
|
|
}
|
|
var (
|
|
var (
|
|
- ExcludeUrl []*regexp.Regexp
|
|
|
|
- PrivateKey *rsa.PrivateKey
|
|
|
|
- PublicKey *rsa.PublicKey
|
|
|
|
|
|
+ ExcludeUrl []*regexp.Regexp
|
|
|
|
+ PrivateKey *rsa.PrivateKey
|
|
|
|
+ PublicKey *rsa.PublicKey
|
|
)
|
|
)
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
- xweb.AddFilter(&Filter{})
|
|
|
|
- go initPrivatePublicKey()
|
|
|
|
- go ChanMonitor()
|
|
|
|
- Node, _ = snowflake.NewNode(util.Int64All(Seoconfig["node"]))
|
|
|
|
- //日志过滤 路由集合
|
|
|
|
- go fs.FSNotifyFUNC("sword->%s", "./route.json", true, func() {
|
|
|
|
- util.ReadConfig("./route.json", &RouteConf)
|
|
|
|
- if len(RouteConf.ExcludeRoute) > 0 {
|
|
|
|
- ExcludeUrl = []*regexp.Regexp{}
|
|
|
|
- for _, v := range RouteConf.ExcludeRoute {
|
|
|
|
- ExcludeUrl = append(ExcludeUrl, regexp.MustCompile(util.ObjToString(v)))
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- time.AfterFunc(1*time.Minute, SaveLogTask)
|
|
|
|
|
|
+ xweb.AddFilter(&Filter{})
|
|
|
|
+ go initPrivatePublicKey()
|
|
|
|
+ go ChanMonitor()
|
|
|
|
+ Node, _ = snowflake.NewNode(util.Int64All(Seoconfig["node"]))
|
|
|
|
+ //日志过滤 路由集合
|
|
|
|
+ go fs.FSNotifyFUNC("sword->%s", "./route.json", true, func() {
|
|
|
|
+ util.ReadConfig("./route.json", &RouteConf)
|
|
|
|
+ if len(RouteConf.ExcludeRoute) > 0 {
|
|
|
|
+ ExcludeUrl = []*regexp.Regexp{}
|
|
|
|
+ for _, v := range RouteConf.ExcludeRoute {
|
|
|
|
+ ExcludeUrl = append(ExcludeUrl, regexp.MustCompile(util.ObjToString(v)))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ time.AfterFunc(1*time.Minute, SaveLogTask)
|
|
}
|
|
}
|
|
|
|
|
|
type Filter struct {
|
|
type Filter struct {
|
|
}
|
|
}
|
|
|
|
|
|
func (f *Filter) Do(w http.ResponseWriter, r *http.Request) bool {
|
|
func (f *Filter) Do(w http.ResponseWriter, r *http.Request) bool {
|
|
- session := xweb.RootApp().SessionManager.Session(r, w)
|
|
|
|
- getSession := session.GetMultiple()
|
|
|
|
- if getSession["userId"] != nil && getSession["mgoUserId"] == nil && util.Int64All(getSession["positionType"]) == 0 {
|
|
|
|
- session.Set("mgoUserId", getSession["userId"])
|
|
|
|
- }
|
|
|
|
- if getSession["base_user_id"] != nil && getSession["positionId"] == nil {
|
|
|
|
- identity.SwitchToBest(util.Int64All(getSession["base_user_id"]), session, Middleground, &public.MQFW, false)
|
|
|
|
- }
|
|
|
|
- if !(&AnonymousAuth{w, r, session, getSession, make(map[string]interface{})}).Do() {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- (&CookieInfo{w, r, getSession["userId"] != nil, session}).Do()
|
|
|
|
- (&fx.VisitFilter{W: w, R: r, Session: session, SessVal: getSession, MgoLog: public.MQFW, Ms: public.Mysql}).Do()
|
|
|
|
- if !(&logFilter{w, r, session, getSession, make(map[string]interface{})}).Do() {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- //新版登录时间延长
|
|
|
|
- if !(&SessionKeep{w, r, session, getSession, make(map[string]interface{})}).Do() {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- if !(&jyutil.SessionKeep{w, r, session, getSession, make(map[string]interface{})}).Do() {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
|
|
+ session := xweb.RootApp().SessionManager.Session(r, w)
|
|
|
|
+ getSession := session.GetMultiple()
|
|
|
|
+ if getSession["userId"] != nil && getSession["mgoUserId"] == nil && util.Int64All(getSession["positionType"]) == 0 {
|
|
|
|
+ session.Set("mgoUserId", getSession["userId"])
|
|
|
|
+ }
|
|
|
|
+ if getSession["base_user_id"] != nil && getSession["positionId"] == nil {
|
|
|
|
+ identity.SwitchToBest(util.Int64All(getSession["base_user_id"]), session, Middleground, &public.MQFW, false)
|
|
|
|
+ }
|
|
|
|
+ if !(&AnonymousAuth{w, r, session, getSession, make(map[string]interface{})}).Do() {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ (&CookieInfo{w, r, getSession["userId"] != nil, session}).Do()
|
|
|
|
+ (&fx.VisitFilter{W: w, R: r, Session: session, SessVal: getSession, MgoLog: public.MQFW, Ms: public.Mysql}).Do()
|
|
|
|
+ if !(&logFilter{w, r, session, getSession, make(map[string]interface{})}).Do() {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ //新版登录时间延长
|
|
|
|
+ if !(&SessionKeep{w, r, session, getSession, make(map[string]interface{})}).Do() {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if !(&jyutil.SessionKeep{w, r, session, getSession, make(map[string]interface{})}).Do() {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
|
|
- if !(&mergeFilter{w, r, session, getSession}).Do() {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- if !(&phoneFilter{w, r, session, getSession}).Do() {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- if !(&pcFilter{w, r, session, getSession}).Do() {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- if !(&salesFilter{w, r, session, getSession}).Do() {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- if !(&pcSalesFilter{w, r, session, getSession}).Do() {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
|
|
+ if !(&mergeFilter{w, r, session, getSession}).Do() {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if !(&phoneFilter{w, r, session, getSession}).Do() {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if !(&pcFilter{w, r, session, getSession}).Do() {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if !(&salesFilter{w, r, session, getSession}).Do() {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if !(&pcSalesFilter{w, r, session, getSession}).Do() {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
}
|
|
}
|