package ads_checker

import (
	"miads/adslib/ads_redis"

	"github.com/gomodule/redigo/redis"
)

func CheckReqSource(source string) (bool, error) {
	conn := ads_redis.RedisConn.Get()
	defer conn.Close()

	key := "arsi"
	reply, err := redis.Bool(conn.Do("SISMEMBER", key, source))
	return reply, err
}

// 检查该ip是否是黑名单
func CheckBlackIp(ip string) (bool, error) {
	conn := ads_redis.RedisConn.Get()
	defer conn.Close()

	redisKey := "ads_black_ip"
	isInBlackList, err := redis.Bool(conn.Do("SISMEMBER", redisKey, ip))
	if err != nil {
		return false, err
	}
	return isInBlackList, err
}
