|
|
|
@ -29,19 +29,19 @@ public class IpSendCheckServiceImpl implements SendCheckService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void check(StandardSubmit submit) {
|
|
|
|
|
log.info("【接口模块-校验ip】 校验ing…………");
|
|
|
|
|
log.info("【接口模块-校验ip】校验ing…………");
|
|
|
|
|
//1. 根据CacheClient根据客户的apikey以及ipAddress去查询客户的IP白名单
|
|
|
|
|
String ip = cacheClient.hgetString(CacheConstant.CLIENT_BUSINESS + submit.getApikey(), IP_ADDRESS);
|
|
|
|
|
submit.setIpAddress(ip);
|
|
|
|
|
|
|
|
|
|
//2. 如果IP白名单为null,直接放行
|
|
|
|
|
if (StringUtils.isEmpty(ip) || ip.contains(submit.getRealIp())) {
|
|
|
|
|
log.info("【接口模块-校验ip】 客户端请求IP合法!");
|
|
|
|
|
log.info("【接口模块-校验ip】客户端请求IP合法!{}", submit.getIpAddress());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//3. IP白名单不为空,并且客户端请求不在IP报名单内
|
|
|
|
|
log.info("【接口模块-校验ip】 请求的ip不在白名单内");
|
|
|
|
|
log.info("【接口模块-校验ip】请求的ip不在白名单内!{}", submit.getIpAddress());
|
|
|
|
|
throw new ApiException(ExceptionEnums.IP_NOT_WHITE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|