ids) {
- this.ids = ids;
- }
}
diff --git a/foreign-server/src/main/java/com/proxyip/select/bean/params/AddProxyIpToDbParams.java b/foreign-server/src/main/java/com/proxyip/select/bean/params/AddProxyIpToDbParams.java
new file mode 100644
index 0000000..996b539
--- /dev/null
+++ b/foreign-server/src/main/java/com/proxyip/select/bean/params/AddProxyIpToDbParams.java
@@ -0,0 +1,19 @@
+package com.proxyip.select.bean.params;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ *
+ * AddProxyIpToDbParams
+ *
+ *
+ * @author yuhui.fan
+ * @since 2024/4/1 16:51
+ */
+@Data
+public class AddProxyIpToDbParams {
+
+ List ipList;
+}
diff --git a/foreign-server/src/main/java/com/proxyip/select/bean/params/AddSingleDnsRecordParams.java b/foreign-server/src/main/java/com/proxyip/select/bean/params/AddSingleDnsRecordParams.java
index 51b5fd8..a7faf1b 100644
--- a/foreign-server/src/main/java/com/proxyip/select/bean/params/AddSingleDnsRecordParams.java
+++ b/foreign-server/src/main/java/com/proxyip/select/bean/params/AddSingleDnsRecordParams.java
@@ -1,5 +1,7 @@
package com.proxyip.select.bean.params;
+import lombok.Data;
+
/**
* @projectName: scan-proxyip
* @package: com.proxyip.select.bean.params
@@ -7,15 +9,8 @@
* @author: Yohann
* @date: 2024/3/30 17:54
*/
+@Data
public class AddSingleDnsRecordParams {
private String id;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
}
diff --git a/foreign-server/src/main/java/com/proxyip/select/bean/params/ProxyIpPageParams.java b/foreign-server/src/main/java/com/proxyip/select/bean/params/ProxyIpPageParams.java
index 43313cc..1c2515b 100644
--- a/foreign-server/src/main/java/com/proxyip/select/bean/params/ProxyIpPageParams.java
+++ b/foreign-server/src/main/java/com/proxyip/select/bean/params/ProxyIpPageParams.java
@@ -1,5 +1,7 @@
package com.proxyip.select.bean.params;
+import lombok.Data;
+
/**
* @projectName: scan-proxyip
* @package: com.proxyip.select.bean.params
@@ -7,51 +9,10 @@
* @author: Yohann
* @date: 2024/3/30 14:37
*/
+@Data
public class ProxyIpPageParams {
private String keyword;
private long currentPage;
private long pageSize;
-
- public ProxyIpPageParams() {
- }
-
- public ProxyIpPageParams(String keyword, long currentPage, long pageSize) {
- this.keyword = keyword;
- this.currentPage = currentPage;
- this.pageSize = pageSize;
- }
-
- public String getKeyword() {
- return keyword;
- }
-
- public void setKeyword(String keyword) {
- this.keyword = keyword;
- }
-
- public long getCurrentPage() {
- return currentPage;
- }
-
- public void setCurrentPage(long currentPage) {
- this.currentPage = currentPage;
- }
-
- public long getPageSize() {
- return pageSize;
- }
-
- public void setPageSize(long pageSize) {
- this.pageSize = pageSize;
- }
-
- @Override
- public String toString() {
- return "ProxyIpPageParams{" +
- "keyword='" + keyword + '\'' +
- ", currentPage=" + currentPage +
- ", pageSize=" + pageSize +
- '}';
- }
}
diff --git a/foreign-server/src/main/java/com/proxyip/select/bean/params/RmFromDbParams.java b/foreign-server/src/main/java/com/proxyip/select/bean/params/RmFromDbParams.java
index f7b9d2b..6edba12 100644
--- a/foreign-server/src/main/java/com/proxyip/select/bean/params/RmFromDbParams.java
+++ b/foreign-server/src/main/java/com/proxyip/select/bean/params/RmFromDbParams.java
@@ -1,5 +1,7 @@
package com.proxyip.select.bean.params;
+import lombok.Data;
+
import java.util.List;
/**
@@ -9,15 +11,8 @@
* @author: Yohann
* @date: 2024/3/30 18:01
*/
+@Data
public class RmFromDbParams {
List ids;
-
- public List getIds() {
- return ids;
- }
-
- public void setIds(List ids) {
- this.ids = ids;
- }
}
diff --git a/foreign-server/src/main/java/com/proxyip/select/bean/params/RmSingleDnsRecordParams.java b/foreign-server/src/main/java/com/proxyip/select/bean/params/RmSingleDnsRecordParams.java
index b7f1dfc..be8fa24 100644
--- a/foreign-server/src/main/java/com/proxyip/select/bean/params/RmSingleDnsRecordParams.java
+++ b/foreign-server/src/main/java/com/proxyip/select/bean/params/RmSingleDnsRecordParams.java
@@ -1,5 +1,7 @@
package com.proxyip.select.bean.params;
+import lombok.Data;
+
/**
* @projectName: scan-proxyip
* @package: com.proxyip.select.bean.params
@@ -7,15 +9,8 @@
* @author: Yohann
* @date: 2024/3/30 17:59
*/
+@Data
public class RmSingleDnsRecordParams {
private String proxyDomain;
-
- public String getProxyDomain() {
- return proxyDomain;
- }
-
- public void setProxyDomain(String proxyDomain) {
- this.proxyDomain = proxyDomain;
- }
}
diff --git a/foreign-server/src/main/java/com/proxyip/select/bean/params/RmSingleIpDnsRecordParams.java b/foreign-server/src/main/java/com/proxyip/select/bean/params/RmSingleIpDnsRecordParams.java
new file mode 100644
index 0000000..67c1917
--- /dev/null
+++ b/foreign-server/src/main/java/com/proxyip/select/bean/params/RmSingleIpDnsRecordParams.java
@@ -0,0 +1,17 @@
+package com.proxyip.select.bean.params;
+
+import lombok.Data;
+
+/**
+ * @projectName: scan-proxyip
+ * @package: com.proxyip.select.bean.params
+ * @className: RmSingleDnsRecordParams
+ * @author: Yohann
+ * @date: 2024/3/30 17:59
+ */
+@Data
+public class RmSingleIpDnsRecordParams {
+
+ private String proxyDomain;
+ private String ip;
+}
diff --git a/foreign-server/src/main/java/com/proxyip/select/business/IProxyIpBusiness.java b/foreign-server/src/main/java/com/proxyip/select/business/IProxyIpBusiness.java
index c83cdc2..8eeac7d 100644
--- a/foreign-server/src/main/java/com/proxyip/select/business/IProxyIpBusiness.java
+++ b/foreign-server/src/main/java/com/proxyip/select/business/IProxyIpBusiness.java
@@ -13,11 +13,15 @@ public interface IProxyIpBusiness {
void rmAllDnsRecords();
- void rmSingleDnsRecord(RmSingleDnsRecordParams params);
+ void rmSingleIpDnsRecord(RmSingleIpDnsRecordParams params);
- void addSingleDnsRecord(AddSingleDnsRecordParams params);
+ void rmSingleDnsRecord(RmSingleDnsRecordParams params);
void rmMoveFromDb(RmFromDbParams params);
+ void addSingleDnsRecord(AddSingleDnsRecordParams params);
+
void addDnsRecordsBatch(AddDnsRecordsBatchParams params);
+
+ void addProxyIpToDbBatch(AddProxyIpToDbParams params);
}
diff --git a/foreign-server/src/main/java/com/proxyip/select/business/impl/DnsRecordBusinessImpl.java b/foreign-server/src/main/java/com/proxyip/select/business/impl/DnsRecordBusinessImpl.java
index e4848ff..4e312ca 100644
--- a/foreign-server/src/main/java/com/proxyip/select/business/impl/DnsRecordBusinessImpl.java
+++ b/foreign-server/src/main/java/com/proxyip/select/business/impl/DnsRecordBusinessImpl.java
@@ -12,6 +12,7 @@
import com.proxyip.select.config.CloudflareCfg;
import com.proxyip.select.config.DnsCfg;
import com.proxyip.select.business.IDnsRecordBusiness;
+import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@@ -34,6 +35,7 @@
* @since 2024/3/21 14:26
*/
@Service
+@Slf4j
public class DnsRecordBusinessImpl implements IDnsRecordBusiness {
@Resource
@@ -47,8 +49,6 @@ public class DnsRecordBusinessImpl implements IDnsRecordBusiness {
@Resource
private IdGen idGen;
- private static final Logger logger = LoggerFactory.getLogger(DnsRecordBusinessImpl.class);
-
@Override
public void addLimitDnsRecordAndWriteToFile(List ipAddresses, String outputFile) {
List countryCodeList = Arrays.stream(CountryEnum.values()).map(CountryEnum::getCode).collect(Collectors.toList());
@@ -75,15 +75,13 @@ public void addLimitDnsRecordAndWriteToFile(List ipAddresses, String out
proxyIp.setIp(ip);
Integer pingValue = NetUtils.getPingValue(ip);
proxyIp.setPingValue(pingValue == null ? 999999 : pingValue);
+ proxyIp.setCreateTime(LocalDateTime.now());
return proxyIp;
}).collect(Collectors.toList());
// 持久化到数据库
- List ipInDbList = proxyIpService.listObjs(new LambdaQueryWrapper()
- .select(ProxyIp::getIp), String::valueOf);
- if (CommonUtils.isNotEmpty(ipInDbList)) {
- list.removeIf(x -> ipInDbList.contains(x.getIp()));
- }
+ list.removeIf(x -> Optional.ofNullable(proxyIpService.getOne(new LambdaQueryWrapper()
+ .eq(ProxyIp::getIp, x.getIp()))).isPresent());
proxyIpService.saveBatch(list);
// 分组并保留五条记录
@@ -123,7 +121,7 @@ public void addLimitDnsRecordAndWriteToFile(List ipAddresses, String out
apiService.addCfDnsRecords(prefix, x.getIp(), cloudflareCfg.getZoneId(), cloudflareCfg.getApiToken());
}
});
- logger.info("√√√ 所有DNS记录添加完成!!! √√√");
+ log.info("√√√ 所有DNS记录添加完成!!! √√√");
// 写入文件
CompletableFuture.runAsync(() -> {
@@ -140,7 +138,7 @@ public void addLimitDnsRecordAndWriteToFile(List ipAddresses, String out
} catch (Exception e) {
throw new RuntimeException("写入文件:" + outputFile + "失败");
}
- logger.info("√√√ 获取proxyIps任务完成,文件位置:{} √√√", outputFile);
+ log.info("√√√ 获取proxyIps任务完成,文件位置:{} √√√", outputFile);
// 发送到网盘api
if (!"".equals(dnsCfg.getUploadApi())) {
@@ -180,12 +178,12 @@ public void addDnsRecordAndWriteToFile(List ipAddresses, String outputFi
e.printStackTrace();
}
} else {
- logger.info("IP:{} 无法ping通,已跳过", ipAddress);
+ log.info("IP:{} 无法ping通,已跳过", ipAddress);
}
});
- logger.info("√√√ 所有DNS记录添加完成!!! √√√");
- logger.info("√√√ 获取proxyIps任务完成,文件位置:{} √√√", outputFile);
+ log.info("√√√ 所有DNS记录添加完成!!! √√√");
+ log.info("√√√ 获取proxyIps任务完成,文件位置:{} √√√", outputFile);
// 发送到网盘api
if (!"".equals(dnsCfg.getUploadApi())) {
@@ -203,12 +201,12 @@ public void rmCfDnsRecords() {
.map(x -> x.getLowCode() + "." + cloudflareCfg.getProxyDomainPrefix() + "." + cloudflareCfg.getRootDomain())
.collect(Collectors.toList());
apiService.removeCfDnsRecords(proxyDomainList, cloudflareCfg.getZoneId(), cloudflareCfg.getApiToken());
- logger.info("√√√ 所有DNS记录已清除成功,开始添加DNS记录... √√√");
+ log.info("√√√ 所有DNS记录已清除成功,开始添加DNS记录... √√√");
}
@Override
public void rmIpInDb() {
- logger.info("当前时间:{},开始清除数据库中无效的ip...", getNowDateTime());
+ log.info("当前时间:{},开始清除数据库中无效的ip...", getNowDateTime());
List voidIdList = Optional.ofNullable(proxyIpService.list())
.filter(CommonUtils::isNotEmpty).orElseGet(Collections::emptyList).parallelStream()
.filter(x -> !dnsCfg.getReleaseIps().contains(x.getIp()))
@@ -218,12 +216,12 @@ public void rmIpInDb() {
if (CommonUtils.isNotEmpty(voidIdList)) {
proxyIpService.removeByIds(voidIdList);
}
- logger.info("√√√ 清除数据库中无效ip任务已完成 √√√");
+ log.info("√√√ 清除数据库中无效ip任务已完成 √√√");
}
@Override
public void updateProxyIpTask() {
- logger.info("当前时间:{},开始更新DNS记录...", getNowDateTime());
+ log.info("当前时间:{},开始更新DNS记录...", getNowDateTime());
long begin = System.currentTimeMillis();
// 获取proxyIps
List ipAddresses = apiService.resolveDomain(dnsCfg.getProxyDomain(), dnsCfg.getDnsServer());
@@ -238,7 +236,7 @@ public void updateProxyIpTask() {
long end = System.currentTimeMillis();
- logger.info("√√√ 更新DNS记录任务完成!!!总耗时:{} ms √√√", (end - begin));
+ log.info("√√√ 更新DNS记录任务完成!!!总耗时:{} ms √√√", (end - begin));
}
@Override
@@ -249,7 +247,7 @@ public void updateDbTask() {
@Override
public void updateIpPingValueInDb() {
- logger.info("当前时间:{},开始更新数据库中ip的ping值...", getNowDateTime());
+ log.info("当前时间:{},开始更新数据库中ip的ping值...", getNowDateTime());
List proxyIpList = Optional.ofNullable(proxyIpService.list())
.filter(CommonUtils::isNotEmpty).orElseGet(Collections::emptyList).parallelStream()
.peek(x -> {
@@ -260,7 +258,7 @@ public void updateIpPingValueInDb() {
if (CommonUtils.isNotEmpty(proxyIpList)) {
proxyIpService.updateBatchById(proxyIpList);
}
- logger.info("√√√ 更新数据库中ip的ping值任务已完成 √√√");
+ log.info("√√√ 更新数据库中ip的ping值任务已完成 √√√");
}
/**
diff --git a/foreign-server/src/main/java/com/proxyip/select/business/impl/ProxyIpBusinessImpl.java b/foreign-server/src/main/java/com/proxyip/select/business/impl/ProxyIpBusinessImpl.java
index 135f31b..ca59a6a 100644
--- a/foreign-server/src/main/java/com/proxyip/select/business/impl/ProxyIpBusinessImpl.java
+++ b/foreign-server/src/main/java/com/proxyip/select/business/impl/ProxyIpBusinessImpl.java
@@ -12,12 +12,19 @@
import com.proxyip.select.common.service.IApiService;
import com.proxyip.select.common.service.IProxyIpService;
import com.proxyip.select.common.utils.CommonUtils;
+import com.proxyip.select.common.utils.IdGen;
+import com.proxyip.select.common.utils.NetUtils;
import com.proxyip.select.config.CloudflareCfg;
+import com.proxyip.select.config.DnsCfg;
+import org.springframework.cglib.core.Local;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
+import java.time.LocalDateTime;
import java.util.Collections;
+import java.util.List;
import java.util.Optional;
+import java.util.stream.Collectors;
/**
* @projectName: scan-proxyip
@@ -29,6 +36,8 @@
@Service
public class ProxyIpBusinessImpl implements IProxyIpBusiness {
+ @Resource
+ private DnsCfg dnsCfg;
@Resource
private CloudflareCfg cloudflareCfg;
@Resource
@@ -37,6 +46,8 @@ public class ProxyIpBusinessImpl implements IProxyIpBusiness {
private IDnsRecordBusiness dnsRecordService;
@Resource
private IApiService apiService;
+ @Resource
+ private IdGen idGen;
@Override
public IPage pageList(ProxyIpPageParams params) {
@@ -44,7 +55,7 @@ public IPage pageList(ProxyIpPageParams params) {
new LambdaQueryWrapper()
.likeRight(ProxyIp::getCountry, params.getKeyword()).or()
.likeRight(ProxyIp::getIp, params.getKeyword())
- .orderByAsc(ProxyIp::getPingValue));
+ .orderByDesc(ProxyIp::getCreateTime));
}
@Override
@@ -52,6 +63,15 @@ public void rmAllDnsRecords() {
dnsRecordService.rmCfDnsRecords();
}
+ @Override
+ public void rmSingleIpDnsRecord(RmSingleIpDnsRecordParams params) {
+ apiService.removeCfSingleDnsRecords(
+ params.getProxyDomain() + "." + cloudflareCfg.getProxyDomainPrefix() + "." + cloudflareCfg.getRootDomain(),
+ params.getIp(),
+ cloudflareCfg.getZoneId(),
+ cloudflareCfg.getApiToken());
+ }
+
@Override
public void rmSingleDnsRecord(RmSingleDnsRecordParams params) {
apiService.removeCfDnsRecords(
@@ -82,15 +102,43 @@ public void rmMoveFromDb(RmFromDbParams params) {
public void addDnsRecordsBatch(AddDnsRecordsBatchParams params) {
Optional.ofNullable(proxyIpService.listByIds(params.getIds()))
.filter(CommonUtils::isNotEmpty).ifPresent(list -> {
- list.parallelStream().forEach(proxyIp -> {
- String prefix = EnumUtils.getEnumByCode(CountryEnum.class, proxyIp.getCountry()).getLowCode() + "."
- + cloudflareCfg.getProxyDomainPrefix();
- apiService.addCfDnsRecords(
- prefix,
- proxyIp.getIp(),
- cloudflareCfg.getZoneId(),
- cloudflareCfg.getApiToken());
- });
- });
+ list.parallelStream().forEach(proxyIp -> {
+ String prefix = EnumUtils.getEnumByCode(CountryEnum.class, proxyIp.getCountry()).getLowCode() + "."
+ + cloudflareCfg.getProxyDomainPrefix();
+ apiService.addCfDnsRecords(
+ prefix,
+ proxyIp.getIp(),
+ cloudflareCfg.getZoneId(),
+ cloudflareCfg.getApiToken());
+ });
+ });
+ }
+
+ @Override
+ public void addProxyIpToDbBatch(AddProxyIpToDbParams params) {
+ Optional.ofNullable(params.getIpList())
+ .filter(CommonUtils::isNotEmpty).ifPresent(ipList -> {
+ List list = ipList.parallelStream()
+ .map(String::trim)
+ .map(ip -> {
+ // 获取国家代码
+ String countryCode = apiService.getIpCountry(ip, dnsCfg.getGeoipAuth());
+ if (countryCode == null || EnumUtils.getEnumByCode(CountryEnum.class, countryCode) == null) {
+ countryCode = apiService.getIpCountry(ip);
+ }
+
+ ProxyIp proxyIp = new ProxyIp();
+ proxyIp.setId(String.valueOf(idGen.nextId()));
+ proxyIp.setCountry(countryCode);
+ proxyIp.setIp(ip);
+ Integer pingValue = NetUtils.getPingValue(ip);
+ proxyIp.setPingValue(pingValue == null ? 999999 : pingValue);
+ proxyIp.setCreateTime(LocalDateTime.now());
+ return proxyIp;
+ }).collect(Collectors.toList());
+ list.removeIf(x -> Optional.ofNullable(proxyIpService.getOne(new LambdaQueryWrapper()
+ .eq(ProxyIp::getIp, x.getIp()))).isPresent());
+ proxyIpService.saveBatch(list);
+ });
}
}
diff --git a/foreign-server/src/main/java/com/proxyip/select/config/LocalDateTimeHandler.java b/foreign-server/src/main/java/com/proxyip/select/config/LocalDateTimeHandler.java
new file mode 100644
index 0000000..95a206c
--- /dev/null
+++ b/foreign-server/src/main/java/com/proxyip/select/config/LocalDateTimeHandler.java
@@ -0,0 +1,67 @@
+package com.proxyip.select.config;
+
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.springframework.stereotype.Component;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+
+/**
+ * sqlite localDateTime 处理
+ * @author libo
+ */
+@Component
+public class LocalDateTimeHandler extends BaseTypeHandler {
+
+ private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+ private static final DateTimeFormatter[] FORMATTERS = new DateTimeFormatter[]{
+ DateTimeFormatter.ofPattern("yyyy-MM-dd"),
+ DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"),
+ DEFAULT_FORMATTER,
+ DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"),
+ DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm"),
+ DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"),
+ DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS")};
+
+ @Override
+ public void setNonNullParameter(PreparedStatement ps, int i, LocalDateTime parameter, JdbcType jdbcType) throws SQLException {
+ ps.setObject(i, parameter.format(DEFAULT_FORMATTER));
+ }
+
+ @Override
+ public LocalDateTime getNullableResult(ResultSet rs, String columnName) throws SQLException {
+ return ts2LocalDateTime(rs.getString(columnName));
+ }
+
+ @Override
+ public LocalDateTime getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
+ return ts2LocalDateTime(rs.getString(columnIndex));
+ }
+
+ @Override
+ public LocalDateTime getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
+ return ts2LocalDateTime(cs.getString(columnIndex));
+ }
+
+ private LocalDateTime ts2LocalDateTime(String timeStr) {
+ if (timeStr == null || "".equals(timeStr) || "null".equals(timeStr)){
+ return null;
+ }
+
+ for (DateTimeFormatter df:FORMATTERS) {
+ try{
+ return LocalDateTime.parse(timeStr, df);
+ }catch (DateTimeParseException e){
+ }
+ }
+ throw new RuntimeException("not supported time str:"+timeStr);
+ }
+
+}
diff --git a/foreign-server/src/main/java/com/proxyip/select/controller/ProxyIpController.java b/foreign-server/src/main/java/com/proxyip/select/controller/ProxyIpController.java
index a35df4e..7c22a01 100644
--- a/foreign-server/src/main/java/com/proxyip/select/controller/ProxyIpController.java
+++ b/foreign-server/src/main/java/com/proxyip/select/controller/ProxyIpController.java
@@ -40,10 +40,16 @@ public ResponseData rmAllDnsRecords() {
return ResponseData.successData("删除所有dns记录成功");
}
+ @PostMapping(path = "/rmSingleIpDnsRecord")
+ public ResponseData rmSingleIpDnsRecord(@RequestBody RmSingleIpDnsRecordParams params) {
+ proxyIpBusiness.rmSingleIpDnsRecord(params);
+ return ResponseData.successData("删除该代理域名的某个ip地址的dns记录成功");
+ }
+
@PostMapping(path = "/rmSingleDnsRecord")
public ResponseData rmSingleDnsRecord(@RequestBody RmSingleDnsRecordParams params) {
proxyIpBusiness.rmSingleDnsRecord(params);
- return ResponseData.successData("删除改代理域名所有dns记录成功");
+ return ResponseData.successData("删除该代理域名所有dns记录成功");
}
@PostMapping(path = "/addSingleDnsRecord")
@@ -57,4 +63,10 @@ public ResponseData addDnsRecordsBatch(@RequestBody AddDnsRecordsBatchPara
proxyIpBusiness.addDnsRecordsBatch(params);
return ResponseData.successData("添加多条dns记录成功");
}
+
+ @PostMapping(path = "/addProxyIpToDbBatch")
+ public ResponseData addProxyIpToDbBatch(@RequestBody AddProxyIpToDbParams params) {
+ proxyIpBusiness.addProxyIpToDbBatch(params);
+ return ResponseData.successData("添加多个proxyIp到数据库成功");
+ }
}
diff --git a/foreign-server/src/main/resources/static/proxyIp.html b/foreign-server/src/main/resources/static/proxyIp.html
index 7e80ec9..441b67a 100644
--- a/foreign-server/src/main/resources/static/proxyIp.html
+++ b/foreign-server/src/main/resources/static/proxyIp.html
@@ -87,6 +87,24 @@
.git-contact-float:hover {
background-color: #0056b3; /* 鼠标悬停时的背景颜色 */
}
+
+ .el-tag + .el-tag {
+ margin-left: 10px;
+ }
+
+ .button-new-tag {
+ margin-left: 10px;
+ height: 32px;
+ line-height: 30px;
+ padding-top: 0;
+ padding-bottom: 0;
+ }
+
+ .input-new-tag {
+ width: 200px;
+ margin-left: 10px;
+ vertical-align: bottom;
+ }
@@ -100,28 +118,70 @@ 代理IP列表
@input="search">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 批量删除数据库中数据
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 批量删除数据库中数据
删除所有代理域名DNS记录
+
+
批量解析所选ip地址到CF的DNS记录
+
+
+ {{ tag }}
+
+
+
+ + New ProxyIp
+ 添加proxyIp到数据库
+
+
@@ -148,11 +208,16 @@
代理IP列表
{{ scope.row.ip }}
-
+
{{ scope.row.pingValue }}
+
+
+ {{ scope.row.createTime }}
+
+
解析到CF
@@ -195,19 +260,15 @@ 代理IP列表
proxyDomain: '',
tableData: [],
selectedRows: [], // 保存选中的行数据
- loading: true
+ loading: true,
+ dynamicTags: [],
+ inputVisible: false,
+ inputValue: '',
+ rmRecordIp: '',
+ rmRecordIpProxyDomain:''
};
},
methods: {
- handleCurrentChange(page) {
- this.pageParams.currentPage = page;
- this.search();
- },
- //改变当前记录条数
- handleSizeChange(val) {
- this.pageParams.pageSize = val;
- this.search();
- },
search() {
// 发送搜索请求到后端
// 替换为实际的后端接口地址
@@ -221,6 +282,23 @@ 代理IP列表
})
.catch(error => console.error('Error searching data:', error));
},
+ async addProxyIpToDbBatch() {
+ if (this.dynamicTags.length === 0) {
+ alert('请先添加多个proxyIp!');
+ return;
+ }
+ if (confirm(`确定要添加proxyIp: ${this.dynamicTags} 到数据库吗?`)) {
+ await axios.post(`${this.apiUrl}/proxyIp/addProxyIpToDbBatch`, {ipList: this.dynamicTags})
+ .then(response => {
+ if (response.data.success) {
+ alert(`成功添加到数据库`);
+ this.search();
+ this.dynamicTags = [];
+ }
+ })
+ .catch(error => console.error('Error deleting data:', error));
+ }
+ },
async addSingleDnsRecord(id) {
if (confirm(`确定要添加id: ${id} 这条记录的ip地址到dns记录中吗?`)) {
await axios.post(`${this.apiUrl}/proxyIp/addSingleDnsRecord`, {id: id})
@@ -233,6 +311,28 @@ 代理IP列表
.catch(error => console.error('Error deleting data:', error));
}
},
+ async rmSingleIpDnsRecord() {
+ if (this.rmRecordIp === '' || this.rmRecordIpProxyDomain === '') {
+ alert('请选择代理域名并输入ip地址!');
+ return;
+ }
+ if (confirm('确定要删除这条记录吗?')) {
+ const ids = this.selectedRows.map(row => row.id);
+ await axios.post(`${this.apiUrl}/proxyIp/rmSingleIpDnsRecord`, {
+ proxyDomain: this.rmRecordIpProxyDomain,
+ ip: this.rmRecordIp
+ })
+ .then(response => {
+ if (response.data.success) {
+ alert('成功删除该记录');
+ this.search();
+ this.rmRecordIpProxyDomain = '';
+ this.rmRecordIp = '';
+ }
+ })
+ .catch(error => console.error('Error deleting data:', error));
+ }
+ },
async deleteBatch() {
if (this.selectedRows.length === 0) {
alert('请先选择从数据库中要删除的记录!');
@@ -300,6 +400,34 @@ 代理IP列表
},
handleSelectAll(selection) {
this.selectedRows = selection;
+ },
+ handleClose(tag) {
+ this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
+ },
+
+ showInput() {
+ this.inputVisible = true;
+ this.$nextTick(_ => {
+ this.$refs.saveTagInput.$refs.input.focus();
+ });
+ },
+
+ handleInputConfirm() {
+ let inputValue = this.inputValue;
+ if (inputValue) {
+ this.dynamicTags.push(inputValue);
+ }
+ this.inputVisible = false;
+ this.inputValue = '';
+ },
+ handleCurrentChange(page) {
+ this.pageParams.currentPage = page;
+ this.search();
+ },
+ //改变当前记录条数
+ handleSizeChange(val) {
+ this.pageParams.pageSize = val;
+ this.search();
}
},
mounted() {
diff --git a/foreign-server/src/test/java/DbTest.java b/foreign-server/src/test/java/DbTest.java
index bb67737..5d95dc3 100644
--- a/foreign-server/src/test/java/DbTest.java
+++ b/foreign-server/src/test/java/DbTest.java
@@ -1,5 +1,5 @@
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.proxyip.select.SelectApplication;
-import com.proxyip.select.bean.params.ProxyIpPageParams;
import com.proxyip.select.business.IProxyIpBusiness;
import com.proxyip.select.common.bean.ProxyIp;
import com.proxyip.select.common.service.IProxyIpService;
@@ -25,12 +25,8 @@ public class DbTest {
@Test
void contextLoads() {
-// ProxyIpPageParams params = new ProxyIpPageParams("", 1, 5);
-// Page page = proxyIpBusiness.pageList(params);
-// page.getRecords().forEach(System.out::println);
-
- com.baomidou.mybatisplus.extension.plugins.pagination.Page page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(1, 5);
- com.baomidou.mybatisplus.extension.plugins.pagination.Page proxyIpPage = proxyIpService.page(page);
+ Page page = new Page<>(1, 5);
+ Page proxyIpPage = proxyIpService.page(page);
proxyIpPage.getRecords().forEach(System.out::println);
}
}