parent
3adee57b37
commit
b53577a126
|
@ -37,8 +37,7 @@ var defaultServerPort = "80" // 8080's a good one, if you're testing and don't w
|
||||||
func main() {
|
func main() {
|
||||||
// Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows
|
// Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows
|
||||||
defer func() {
|
defer func() {
|
||||||
r := recover()
|
if r := recover(); r != nil {
|
||||||
if r != nil {
|
|
||||||
fmt.Println(r)
|
fmt.Println(r)
|
||||||
debug.PrintStack()
|
debug.PrintStack()
|
||||||
pressAnyKey()
|
pressAnyKey()
|
||||||
|
|
|
@ -322,6 +322,7 @@ func SecurityError(w http.ResponseWriter, r *http.Request, user *User) RouteErro
|
||||||
}
|
}
|
||||||
|
|
||||||
func MicroNotFound(w http.ResponseWriter, r *http.Request) RouteError {
|
func MicroNotFound(w http.ResponseWriter, r *http.Request) RouteError {
|
||||||
|
w.Header().Set("Content-Type", "text/html;charset=utf-8")
|
||||||
w.WriteHeader(404)
|
w.WriteHeader(404)
|
||||||
_, _ = w.Write([]byte("file not found"))
|
_, _ = w.Write([]byte("file not found"))
|
||||||
return HandledRouteError()
|
return HandledRouteError()
|
||||||
|
|
|
@ -2817,21 +2817,21 @@ func (r *GenRouter) routeSwitch(w http.ResponseWriter, req *http.Request, user *
|
||||||
r.RLock()
|
r.RLock()
|
||||||
h, ok := r.extraRoutes[req.URL.Path]
|
h, ok := r.extraRoutes[req.URL.Path]
|
||||||
r.RUnlock()
|
r.RUnlock()
|
||||||
|
req.URL.Path += extraData
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
req.URL.Path += extraData
|
|
||||||
// TODO: Be more specific about *which* dynamic route it is
|
// TODO: Be more specific about *which* dynamic route it is
|
||||||
co.RouteViewCounter.Bump(165)
|
co.RouteViewCounter.Bump(165)
|
||||||
return h(w,req,user)
|
return h(w,req,user)
|
||||||
}
|
}
|
||||||
|
co.RouteViewCounter.Bump3(172, cn)
|
||||||
|
|
||||||
lp := strings.ToLower(req.URL.Path)
|
lp := strings.ToLower(req.URL.Path)
|
||||||
if strings.Contains(lp,"admin") || strings.Contains(lp,"sql") || strings.Contains(lp,"manage") || strings.Contains(lp,"//") || strings.Contains(lp,"\\\\") || strings.Contains(lp,"wp") || strings.Contains(lp,"wordpress") || strings.Contains(lp,"config") || strings.Contains(lp,"setup") || strings.Contains(lp,"install") || strings.Contains(lp,"update") || strings.Contains(lp,"php") || strings.Contains(lp,"pl") || strings.Contains(lp,"wget") || strings.Contains(lp,"wp-") || strings.Contains(lp,"include") || strings.Contains(lp,"vendor") || strings.Contains(lp,"bin") || strings.Contains(lp,"system") || strings.Contains(lp,"eval") || strings.Contains(lp,"config") {
|
if strings.Contains(lp,"admin") || strings.Contains(lp,"sql") || strings.Contains(lp,"manage") || strings.Contains(lp,"//") || strings.Contains(lp,"\\\\") || strings.Contains(lp,"wp") || strings.Contains(lp,"wordpress") || strings.Contains(lp,"config") || strings.Contains(lp,"setup") || strings.Contains(lp,"install") || strings.Contains(lp,"update") || strings.Contains(lp,"php") || strings.Contains(lp,"pl") || strings.Contains(lp,"wget") || strings.Contains(lp,"wp-") || strings.Contains(lp,"include") || strings.Contains(lp,"vendor") || strings.Contains(lp,"bin") || strings.Contains(lp,"system") || strings.Contains(lp,"eval") || strings.Contains(lp,"config") {
|
||||||
r.SuspiciousRequest(req,"Bad Route")
|
r.SuspiciousRequest(req,"Bad Route")
|
||||||
} else {
|
return c.MicroNotFound(w,req)
|
||||||
r.DumpRequest(req,"Bad Route")
|
|
||||||
}
|
}
|
||||||
co.RouteViewCounter.Bump3(172, cn)
|
r.DumpRequest(req,"Bad Route")
|
||||||
return c.NotFound(w,req,nil)
|
return c.NotFound(w,req,nil)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -1007,21 +1007,21 @@ func (r *GenRouter) routeSwitch(w http.ResponseWriter, req *http.Request, user *
|
||||||
r.RLock()
|
r.RLock()
|
||||||
h, ok := r.extraRoutes[req.URL.Path]
|
h, ok := r.extraRoutes[req.URL.Path]
|
||||||
r.RUnlock()
|
r.RUnlock()
|
||||||
|
req.URL.Path += extraData
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
req.URL.Path += extraData
|
|
||||||
// TODO: Be more specific about *which* dynamic route it is
|
// TODO: Be more specific about *which* dynamic route it is
|
||||||
co.RouteViewCounter.Bump({{index .AllRouteMap "routes.DynamicRoute"}})
|
co.RouteViewCounter.Bump({{index .AllRouteMap "routes.DynamicRoute"}})
|
||||||
return h(w,req,user)
|
return h(w,req,user)
|
||||||
}
|
}
|
||||||
|
co.RouteViewCounter.Bump3({{index .AllRouteMap "routes.BadRoute"}}, cn)
|
||||||
|
|
||||||
lp := strings.ToLower(req.URL.Path)
|
lp := strings.ToLower(req.URL.Path)
|
||||||
if strings.Contains(lp,"admin") || strings.Contains(lp,"sql") || strings.Contains(lp,"manage") || strings.Contains(lp,"//") || strings.Contains(lp,"\\\\") || strings.Contains(lp,"wp") || strings.Contains(lp,"wordpress") || strings.Contains(lp,"config") || strings.Contains(lp,"setup") || strings.Contains(lp,"install") || strings.Contains(lp,"update") || strings.Contains(lp,"php") || strings.Contains(lp,"pl") || strings.Contains(lp,"wget") || strings.Contains(lp,"wp-") || strings.Contains(lp,"include") || strings.Contains(lp,"vendor") || strings.Contains(lp,"bin") || strings.Contains(lp,"system") || strings.Contains(lp,"eval") || strings.Contains(lp,"config") {
|
if strings.Contains(lp,"admin") || strings.Contains(lp,"sql") || strings.Contains(lp,"manage") || strings.Contains(lp,"//") || strings.Contains(lp,"\\\\") || strings.Contains(lp,"wp") || strings.Contains(lp,"wordpress") || strings.Contains(lp,"config") || strings.Contains(lp,"setup") || strings.Contains(lp,"install") || strings.Contains(lp,"update") || strings.Contains(lp,"php") || strings.Contains(lp,"pl") || strings.Contains(lp,"wget") || strings.Contains(lp,"wp-") || strings.Contains(lp,"include") || strings.Contains(lp,"vendor") || strings.Contains(lp,"bin") || strings.Contains(lp,"system") || strings.Contains(lp,"eval") || strings.Contains(lp,"config") {
|
||||||
r.SuspiciousRequest(req,"Bad Route")
|
r.SuspiciousRequest(req,"Bad Route")
|
||||||
} else {
|
return c.MicroNotFound(w,req)
|
||||||
r.DumpRequest(req,"Bad Route")
|
|
||||||
}
|
}
|
||||||
co.RouteViewCounter.Bump3({{index .AllRouteMap "routes.BadRoute"}}, cn)
|
r.DumpRequest(req,"Bad Route")
|
||||||
return c.NotFound(w,req,nil)
|
return c.NotFound(w,req,nil)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -32,7 +32,7 @@ func doPush(w http.ResponseWriter, header *c.Header) {
|
||||||
// TODO: Cache these in a sync.Pool?
|
// TODO: Cache these in a sync.Pool?
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
push := func(in []string) {
|
push := func(in []string) {
|
||||||
sb.Grow((slen1 + 5) * len(in))
|
sb.Grow((slen1 + 6) * len(in))
|
||||||
for _, path := range in {
|
for _, path := range in {
|
||||||
sb.WriteString("</s/")
|
sb.WriteString("</s/")
|
||||||
sb.WriteString(path)
|
sb.WriteString(path)
|
||||||
|
@ -44,7 +44,7 @@ func doPush(w http.ResponseWriter, header *c.Header) {
|
||||||
push(header.ScriptsAsync)
|
push(header.ScriptsAsync)
|
||||||
|
|
||||||
if len(header.Stylesheets) > 0 {
|
if len(header.Stylesheets) > 0 {
|
||||||
sb.Grow((slen2 + 6) * len(header.Stylesheets))
|
sb.Grow((slen2 + 7) * len(header.Stylesheets))
|
||||||
for _, path := range header.Stylesheets {
|
for _, path := range header.Stylesheets {
|
||||||
sb.WriteString("</s/")
|
sb.WriteString("</s/")
|
||||||
sb.WriteString(path)
|
sb.WriteString(path)
|
||||||
|
@ -67,6 +67,7 @@ func doPush(w http.ResponseWriter, header *c.Header) {
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
//panic("has pusher")
|
||||||
//fmt.Println("has pusher")
|
//fmt.Println("has pusher")
|
||||||
|
|
||||||
push := func(in []string) {
|
push := func(in []string) {
|
||||||
|
@ -162,11 +163,7 @@ func renderTemplate3(tmplName, hookName string, w http.ResponseWriter, r *http.R
|
||||||
if c.RunPreRenderHook("pre_render_"+hookName, w, r, h.CurrentUser, pi) {
|
if c.RunPreRenderHook("pre_render_"+hookName, w, r, h.CurrentUser, pi) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
err := h.Theme.RunTmpl(tmplName, pi, w)
|
return h.Theme.RunTmpl(tmplName, pi, w)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Rename renderTemplate to RenderTemplate instead of using this hack to avoid breaking things
|
// TODO: Rename renderTemplate to RenderTemplate instead of using this hack to avoid breaking things
|
||||||
|
|
Loading…
Reference in New Issue