chenbiao 3 jaren geleden
bovenliggende
commit
65638fe045
1 gewijzigde bestanden met toevoegingen van 17 en 10 verwijderingen
  1. 17 10
      netflix-service/src/main/java/com/cyksj/service/register/impl/SpotifyServiceImpl.java

+ 17 - 10
netflix-service/src/main/java/com/cyksj/service/register/impl/SpotifyServiceImpl.java

@@ -148,29 +148,32 @@ public class SpotifyServiceImpl implements SpotifyService {
                     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"));
+                        proxyInfo = new ProxyInfo();
+                        proxyInfo.setPort(data.getInt("port"));
+                        proxyInfo.setIp(data.getStr("ip"));
+                        log.info("----------付费IP地址----------\n ip:{}",proxyInfo);
+                        proxyInfos.add(proxyInfo);
+                        redisService.set(RedisKey.DOVEIP,proxyInfo,data.getLong("timeout"));
                     }else {
                         log.error("----------获取 付费IP 错误 停止循环----------");
                         break;
                     }
+                }else {
+                    proxyInfos.add(proxyInfo);
                 }
             }
-            proxyInfos = records.stream().map((proxy) -> {
+
+            proxyInfos.addAll(records.stream().map((proxy) -> {
                 ProxyInfo proxyInfo = new ProxyInfo();
                 proxyInfo.setIp(proxy.getIp());
                 proxyInfo.setPort(proxy.getPort());
                 return proxyInfo;
-            }).collect(Collectors.toList());
+            }).collect(Collectors.toList()));
 
             for (ProxyInfo proxyInfo : proxyInfos) {
                 try {
                     log.info("执行:info:{}", proxyInfo);
-                    Proxy proxy = new Proxy(Proxy.Type.HTTP,
+                    Proxy proxy = new Proxy(Proxy.Type.SOCKS,
                             new InetSocketAddress(proxyInfo.getIp(), proxyInfo.getPort()));
                     request.setProxy(proxy);
                     HttpResponse response = request.execute();
@@ -185,7 +188,9 @@ public class SpotifyServiceImpl implements SpotifyService {
                         if (StringUtils.isNotBlank(errorMsg) || "你似乎正在使用代理服务。请关闭此类服务,然后再试一次。如需更多帮助,请联系客户服务。".equals(errorMsg) || errorMsg.contains("代理")) {
                             log.info("spotify 注册 被监测出代理服务 。 删除该代理 ip:{}", proxyInfo.getIp());
                             if (proxyInfo.getId() != null) {
-                                proxysMapper.deleteById(proxyInfo.getId());
+                                int count = proxysMapper.deleteById(proxyInfo.getId());
+                            }else {
+                                redisService.del(RedisKey.DOVEIP);
                             }
                             continue;
                         }
@@ -214,6 +219,8 @@ public class SpotifyServiceImpl implements SpotifyService {
                 } catch (Exception e) {
                     if (proxyInfo.getId() != null) {
                         proxysMapper.deleteById(proxyInfo.getId());
+                    }else {
+                        redisService.del(RedisKey.DOVEIP);
                     }
                     e.printStackTrace();
                     log.error("错误 ip:{}", proxyInfo.getIp());