我这边接触到的短信服务,有类似情况,实在不理解,那些不断变更请求源 IP,变更电话号码刷短信资源的,他们动机是什么?
我唯一能想到的就是经济利益,还是有点不可思议啊
不知道有没有遇到同样情况的?
目前我这边解决方法也非常简单实用:OpenResty + Redis 解决
local redis = require "resty.redis"
local cache = redis.new()
cache.connect(cache,'127.0.0.1','6379')
local resp_body = ngx.req.get_body_data() or "-"
local headers=ngx.req.get_headers()
local ip=headers["X-REAL-IP"] or headers["X_FORWARDED_FOR"] or ngx.var.remote_addr or "-"
function split( _str, seperator)
local pos, arr = 0, {}
for st, sp in function() return string.find( _str, seperator, pos, true ) end do
table.insert(arr, string.sub(_str, pos, st-1 ))
pos = sp + 1
end
table.insert(arr, string.sub( _str, pos))
return arr
end
if string.find(resp_body,"phone") then
cache:incr(resp_body)
cache:expire(resp_body,17200)
if tonumber(cache:get(resp_body)) > 4 then
ngx.exit(403)
end
end
local sip = split(ip,",")[1]
if split(sip,".")[1] == "10" then
return
end
cache:incr(sip)
cache:expire(sip,86400)
if tonumber(cache:get(sip)) > 128 then
ngx.exit(403)
end
return