|
|
@@ -11,6 +11,7 @@ import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.cyksj.dto.RedisKey;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.ProxysMapper;
|
|
|
@@ -19,6 +20,7 @@ import com.cyksj.model.entity.Proxys;
|
|
|
import com.cyksj.model.entity.RegisterOrderDon;
|
|
|
import com.cyksj.model.entity.SpotifyRegister;
|
|
|
import com.cyksj.model.response.ProxyInfo;
|
|
|
+import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.register.SpotifyService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -43,6 +45,8 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
|
|
|
private final RegisterOrderDonMapper registerOrderDonMapper;
|
|
|
|
|
|
+ private final RedisService redisService;
|
|
|
+
|
|
|
private static final List<String> User_Agent_LIST = List.of(
|
|
|
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
|
|
|
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)",
|
|
|
@@ -114,9 +118,6 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
request.form(jsonObject);
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
int start = 1;
|
|
|
int limit = 20;
|
|
|
boolean regFlag = false;
|
|
|
@@ -125,7 +126,39 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
List<ProxyInfo> proxyInfos = new ArrayList<>();
|
|
|
List<Proxys> records = proxysMapper.selectPage(new Page<>(start, limit), Wrappers.lambdaQuery(Proxys.class).orderByDesc(Proxys::getId)).getRecords();
|
|
|
if (records.isEmpty()) {
|
|
|
- break;
|
|
|
+ log.info("----------代理池内无可用ip 获取付费IP地址----------");
|
|
|
+ ProxyInfo proxyInfo = (ProxyInfo)redisService.get(RedisKey.DOVEIP);
|
|
|
+ if (proxyInfo == null) {
|
|
|
+
|
|
|
+ String result = HttpUtil.get("https://dvapi.doveip.com/cmapi.php?rq=distribute&user=1031494735&token=ckc1MUFURnk3bi80MXVxeUFTZUh0Zz09&auth=0&geo=ph&agreement=0&timeout=10&num=1&type_ip=1");
|
|
|
+ log.info("付费ip 请求返回 res:{}",result);
|
|
|
+ /*
|
|
|
+ * {
|
|
|
+ * "errno": 200,
|
|
|
+ * "msg": "Success",
|
|
|
+ * "data": {
|
|
|
+ * "geo": "mx", //国家
|
|
|
+ * "ip": "47.253.12.97", //代理ip
|
|
|
+ * "port": 40076, //代理端口
|
|
|
+ * "d_ip": "201.162.169.86" //目标ip
|
|
|
+ * "timeout": 600 //有效时间(秒)
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ JSONObject resObj = JSONUtil.parseObj(result);
|
|
|
+ if (200 == resObj.getInt("errno")) {
|
|
|
+ JSONObject data = resObj.getJSONObject("data");
|
|
|
+ ProxyInfo proxy = new ProxyInfo();
|
|
|
+ proxy.setPort(data.getInt("port"));
|
|
|
+ proxy.setIp(data.getStr("ip"));
|
|
|
+ log.info("----------付费IP地址----------\n ip:{}",proxy);
|
|
|
+ proxyInfos.add(proxy);
|
|
|
+ redisService.set(RedisKey.DOVEIP,proxy,data.getLong("timeout"));
|
|
|
+ }else {
|
|
|
+ log.error("----------获取 付费IP 错误 停止循环----------");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
proxyInfos = records.stream().map((proxy) -> {
|
|
|
ProxyInfo proxyInfo = new ProxyInfo();
|