8 changed files with 43 additions and 29 deletions
@ -1,36 +1,32 @@ |
|||
package com.epmet.openapi.scan.controller; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import com.epmet.openapi.scan.common.redis.RedisKeys; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.data.redis.core.SetOperations; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* @author jianjun liu |
|||
* @date 2020-06-04 20:39 |
|||
**/ |
|||
@RestController |
|||
@RequestMapping("test") |
|||
@RequestMapping("opback") |
|||
public class BackDoorController { |
|||
@Value("${aliyun.green.accessKeyId}") |
|||
private String accessKeyId; |
|||
@Autowired |
|||
private RedisTemplate redisTemplate; |
|||
|
|||
@Value("${aliyun.green.accessKeySecret}") |
|||
private String accessKeySecret; |
|||
|
|||
@Value("${aliyun.green.regionId}") |
|||
private String regionId; |
|||
@GetMapping("api") |
|||
public Result<String> page() { |
|||
Map<String,Object> map = new HashMap<>(); |
|||
map.put(accessKeyId,accessKeyId); |
|||
map.put(accessKeySecret,accessKeySecret); |
|||
map.put(regionId, regionId); |
|||
return new Result<String>().ok(JSON.toJSONString(map)); |
|||
@RequestMapping("addWhite") |
|||
public String addWhite(@RequestParam String ip) { |
|||
SetOperations setOperations = redisTemplate.opsForSet(); |
|||
String whiteList = RedisKeys.getWhiteList(); |
|||
Long add = setOperations.add(whiteList, ip); |
|||
Set members = setOperations.members(whiteList); |
|||
return "ip:" + ip + "添加" + (add > 0 ? "成功" : "失败") + ",当前所有列表:" + JSON.toJSONString(members); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,2 @@ |
|||
#添加白名单 |
|||
sadd epmet:openapi:scan:whitelist "客户端ip地址" |
Loading…
Reference in new issue