jiantaoli 4 years ago
parent
commit
447b331a3f
4 changed files with 15 additions and 8 deletions
  1. 6 4
      ads_handler.go
  2. 1 1
      adslib/ip2region/ip2region.go
  3. 0 0
      conf/ip2region_20200113.db
  4. 8 3
      main_test.go

+ 6 - 4
ads_handler.go

@@ -131,10 +131,11 @@ func adsHandler(c *gin.Context) {
131 131
 		// 频率控制
132 132
 		freqControlConf, err := redis_data.GetFreqCrontolConf(request.ReqSource)
133 133
 		if err != nil {
134
-			c.String(404, "get freq control conf failed")
134
+			c.String(404, "get freq control conf failed: %s", err)
135 135
 			return
136 136
 		}
137 137
 
138
+		fmt.Printf("freq control conf: %+v\n", freqControlConf)
138 139
 		hour, _ := strconv.Atoi(time.Now().Format("01"))
139 140
 		tmpControlInterval, ok := freqControlConf.GetControlTime(hour)
140 141
 		if ok {
@@ -144,7 +145,8 @@ func adsHandler(c *gin.Context) {
144 145
 
145 146
 	lastReqTime, err := device.GetIpReqTime(ip)
146 147
 	if err != nil {
147
-		c.String(404, "get last req time failed")
148
+		fmt.Println(err)
149
+		c.String(404, "get last req time failed: %s", err)
148 150
 		return
149 151
 	}
150 152
 
@@ -161,7 +163,7 @@ func adsHandler(c *gin.Context) {
161 163
 	//### 检查是否是ip黑名单
162 164
 	isIpBlack, err := ads_checker.CheckBlackIp(ip)
163 165
 	if err != nil {
164
-		c.String(404, "get city code failed")
166
+		c.String(404, "check black ip failed: %s", err)
165 167
 		return
166 168
 	}
167 169
 	if isIpBlack {
@@ -172,7 +174,7 @@ func adsHandler(c *gin.Context) {
172 174
 	// 获取渠道的黑白性
173 175
 	reqChannelFlag, err := redis_data.GetChannelFlag(request.ReqSource, "ads_req")
174 176
 	if err != nil {
175
-		c.String(404, "get req channel flag failed")
177
+		c.String(404, "get req channel flag failed: %s", err)
176 178
 		return
177 179
 	}
178 180
 	flowWeight := reqChannelFlag.Weigth

+ 1 - 1
adslib/ip2region/ip2region.go

@@ -6,7 +6,7 @@ import (
6 6
 )
7 7
 
8 8
 func Ip2Region(ip string) (*ip2region.IpInfo, error) {
9
-	region, err := ip2region.New("./conf/ip2region.db")
9
+	region, err := ip2region.New("./conf/ip2region_20200113.db")
10 10
 	if region != nil {
11 11
 		defer region.Close()
12 12
 	}

ip2region_20200113.db → conf/ip2region_20200113.db


File diff suppressed because it is too large
+ 8 - 3
main_test.go