dengbiao 5 dias atrás
pai
commit
a4b41b04cf
2 arquivos alterados com 4 adições e 4 exclusões
  1. +3
    -3
      app/mw/mw_limiter.go
  2. +1
    -1
      app/router/router.go

+ 3
- 3
app/mw/mw_limiter.go Ver arquivo

@@ -16,7 +16,7 @@ func Limiter(c *gin.Context) {
limit := 500 // 限流次数
ttl := 2 // 限流过期时间
ip := utils.GetIP(c.Request)
if ip != "221.4.210.167" {
if ip != "221.4.210.167" && c.Request.Host != "127.0.0.1:4000" {
e.OutErr(c, e.ERR, "系统维护中~")
return
}
@@ -34,8 +34,8 @@ func Limiter(c *gin.Context) {
// Write body back
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(body))
utils.FilePutContents("Limiter", utils.SerializeStr(map[string]interface{}{
"uri": c.Request.URL,
"body": c.Request.Body,
"uri": c.Request.URL.Path,
"body": string(bytes.NewBuffer(body).Bytes()),
}))
//queryValue := utils.SerializeStr(c.Request.URL.Query()) //不建议开启,失去限流的意义



+ 1
- 1
app/router/router.go Ver arquivo

@@ -63,8 +63,8 @@ func route(r *gin.RouterGroup) {
rCallback.Any("/alipay/face", hdl.CallbackAlipayFace) //支付宝实名回调
}

r.Use(mw.Limiter) //进行限流
r.Use(mw.CheckSign)
r.Use(mw.Limiter) //进行限流
r.Any("/testCreateSign", hdl.TestCreateSign)
r.GET("/openApp/start", hdl.Start) //打开app调用
r.GET("/config", hdl.Config) //基本配置


Carregando…
Cancelar
Salvar