Commit ab375c07 authored by Administrator's avatar Administrator

Merge branch 'staging' into 'master'

购买后将海外的IP添加KCP端口号 + own白名单

See merge request !186
parents 657320f5 f11be822
......@@ -42,7 +42,7 @@ public class AccountDto {
private List<String> whiteList = new ArrayList<>();
private List<String> userWhiteList = new ArrayList<>();
private List<String> ownWhiteList = new ArrayList<>();
private ShopSummary shopSummary;
......@@ -71,7 +71,10 @@ public class AccountDto {
this.setToken(account.getToken());
this.setPermission(account.getPermission());
this.setWhiteList(account.getWhiteList());
this.setUserWhiteList(account.getWhiteList());
List<String> ownWhiteList = new ArrayList<>(account.getWhiteList());
ownWhiteList.add("google.com/recaptcha");
ownWhiteList.add("google.com/js");
this.setOwnWhiteList(ownWhiteList);
this.setQueryIpUrlList(account.getQueryIpUrlList());
if (account.getPromotion() != null) {
this.setPromotion(account.getPromotion());
......@@ -260,11 +263,11 @@ public class AccountDto {
this.promotionCode = promotionCode;
}
public List<String> getUserWhiteList() {
return userWhiteList;
public List<String> getOwnWhiteList() {
return ownWhiteList;
}
public void setUserWhiteList(List<String> userWhiteList) {
this.userWhiteList = userWhiteList;
public void setOwnWhiteList(List<String> ownWhiteList) {
this.ownWhiteList = ownWhiteList;
}
}
......@@ -273,6 +273,7 @@ public class IpResourceServiceImpl implements IpResourceService {
// 只要 申请的 ip 地域不是在 大陆,则一定会执行下面 if 中的代码块
boolean condition1 = StringUtils.isNotBlank(ipResource.getRegion()) && region.contains(ipResource.getRegion());
boolean condition2 = ipResourceRequestDto.getVendor().equals("own") && ipResource.isSpecialLine();
if (condition1 || condition2) {
ipResource.setProxyUsername(ipResource.getAddr());
ipResource.setProxyPassword(genRandom(3, 12));
......@@ -639,9 +640,6 @@ public class IpResourceServiceImpl implements IpResourceService {
return ipOperationResultDto;
}
/**********************************************************************************
* todo - D E V E L O P M E N T *
**********************************************************************************/
@Override
public IpPageResultDto getIpList(String username, int groupType, int page, int amount, IpFilterDto ipFilterDto) {
// 获取当前用户的账户
......@@ -711,10 +709,14 @@ public class IpResourceServiceImpl implements IpResourceService {
}
// 2. 如果 ip 资源的 status 为 6(未分配) 或者 ( ip资源为专线 且 purchasedTime(购买IP的时间) 在 14 分钟内)
if (x.getStatus() == 6 || (x.isSpecialLine() && x.getPurchasedTime() > (Instant.now().minusSeconds(14 * 60).toEpochMilli()))) {
if (x.getStatus() == 6) {
x.setStatus(3);
}
if(x.isSpecialLine() && x.getStatus() == 0 && x.getPurchasedTime() > (Instant.now().minusSeconds(14 * 60).toEpochMilli())) {
x.setSpecialLine(false);
}
// 3. 如果 ip 资源的 status 为 3(正在分配)
if (x.getStatus() == 3) {
x.setAddr("");
......@@ -826,9 +828,7 @@ public class IpResourceServiceImpl implements IpResourceService {
return false;
}
/**********************************************************************************
* todo - D E V E L O P M E N T *
**********************************************************************************/
@Override
public IpResourceDto queryIp(String username, IpResourceRequestDto ipResourceRequestDto) {
Account account = accountRepository.findByName(username).orElseThrow(() -> new ClientRequestException(AccountErrorCode.NAMENOTEXIST));
......
......@@ -363,6 +363,13 @@ public class ShopServiceImpl implements ShopService {
}
}
public static List<String> region = Arrays.asList(
"asiapa", "hongkong", "japan", "s-korea", "us", "malaysia",
"yajiada", "singapore", "australia", "germany", "uk", "brazil",
"moscow", "canada", "france", "sweden", "s-korea", "india", "meast",
"brazil", "virginia", "ohio", "california", "oregon", "ireland", "london", "ireland"
);
@Override
public ShopResultDto queryShop(String username, String shopId) {
// 1. 校验 账户、商铺、IP资源、usershop 信息
......@@ -387,6 +394,10 @@ public class ShopServiceImpl implements ShopService {
ipResourceDto = new IpResourceDto(ipResource, null, false);
}
if(org.apache.commons.lang3.StringUtils.isNotBlank(ipResource.getRegion()) && region.contains(ipResource.getRegion())){
ipResourceDto.setSecondaryProxyPort("20020");
}
// 3. 封装 ShopResultDto 信息并返回
return ShopResultDto.of(shop, userShop.getGroupId(), ipResourceDto);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment