ip.go 602 B

123456789101112131415161718192021222324252627282930
  1. package ads_checker
  2. import (
  3. "miads/adslib/ads_redis"
  4. "github.com/gomodule/redigo/redis"
  5. )
  6. func CheckReqSource(source string) (bool, error) {
  7. conn := ads_redis.RedisConn.Get()
  8. defer conn.Close()
  9. key := "arsi"
  10. reply, err := redis.Bool(conn.Do("SISMEMBER", key, source))
  11. return reply, err
  12. }
  13. // 检查该ip是否是黑名单
  14. func CheckBlackIp(ip string) (bool, error) {
  15. conn := ads_redis.RedisConn.Get()
  16. defer conn.Close()
  17. redisKey := "ads_black_ip"
  18. isInBlackList, err := redis.Bool(conn.Do("SISMEMBER", redisKey, ip))
  19. if err != nil {
  20. return false, err
  21. }
  22. return isInBlackList, err
  23. }