Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
browser-backend
Commits
2e8f067e
Commit
2e8f067e
authored
Sep 29, 2024
by
jinliang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/V1.1' of
http://120.77.149.83/root/browser-backend
into feat/V1.1
parents
4e65e333
caab0d7d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
55 deletions
+94
-55
AdministratorController.java
...erbackend/account/controller/AdministratorController.java
+1
-1
WebSecurityConfig.java
...m/edgec/browserbackend/auth/config/WebSecurityConfig.java
+1
-1
CloudPlatformOrder.java
...gec/browserbackend/browser/domain/CloudPlatformOrder.java
+2
-0
BrowserTask.java
...va/com/edgec/browserbackend/browser/task/BrowserTask.java
+11
-0
IpvClient.java
...gec/browserbackend/common/client/ipvClient/IpvClient.java
+32
-15
RegionMappingEnum.java
.../edgec/browserbackend/common/enums/RegionMappingEnum.java
+42
-32
IpvCliestTest.java
src/test/java/com/edgec/browserbackend/IpvCliestTest.java
+5
-6
No files found.
src/main/java/com/edgec/browserbackend/account/controller/AdministratorController.java
View file @
2e8f067e
...
...
@@ -408,7 +408,7 @@ public class AdministratorController {
}
//添加白名单
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
//
@PreAuthorize(Securitys.ADMIN_EL)
@RequestMapping
(
path
=
"/0xadministrator/whitelist/add"
,
method
=
RequestMethod
.
PUT
)
public
ResultDto
addWhiteList
(
Principal
principal
,
@RequestParam
(
"website"
)
String
website
)
{
ResultDto
resultDto
=
new
ResultDto
();
...
...
src/main/java/com/edgec/browserbackend/auth/config/WebSecurityConfig.java
View file @
2e8f067e
...
...
@@ -34,7 +34,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
public
void
configure
(
WebSecurity
web
)
throws
Exception
{
web
.
ignoring
()
.
antMatchers
(
"/user/authCode"
,
"/user/signUp"
,
"/user/forgot**"
,
"/0xadministrator/getconfig**"
,
"/payCallBack/*"
);
"/user/forgot**"
,
"/0xadministrator/getconfig**"
,
"/payCallBack/*"
,
"/config/receptionPlatformOptions"
);
}
@Override
...
...
src/main/java/com/edgec/browserbackend/browser/domain/CloudPlatformOrder.java
View file @
2e8f067e
...
...
@@ -35,4 +35,6 @@ public class CloudPlatformOrder {
private
Integer
retryCount
;
//重试次数
private
String
orderNo
;
//订单id
}
src/main/java/com/edgec/browserbackend/browser/task/BrowserTask.java
View file @
2e8f067e
...
...
@@ -32,13 +32,19 @@ import com.edgec.browserbackend.browser.repository.IpResourceRepository;
import
com.edgec.browserbackend.browser.service.IpAndShopService
;
import
com.edgec.browserbackend.common.client.AliEcsClient
;
import
com.edgec.browserbackend.common.client.TenCentEcsClient
;
import
com.edgec.browserbackend.common.client.ipvClient.IpvClient
;
import
com.edgec.browserbackend.common.client.ipvClient.dto.AppInstanceOpenReq
;
import
com.edgec.browserbackend.common.client.ipvClient.dto.AppOrderResp
;
import
com.edgec.browserbackend.common.client.ipvClient.dto.OpenParam
;
import
com.edgec.browserbackend.common.commons.utils.NotifyUtils
;
import
com.edgec.browserbackend.common.commons.utils.SmsUtils
;
import
com.edgec.browserbackend.common.enums.RegionMappingEnum
;
import
com.edgec.browserbackend.common.utils.ThreadPoolUtils
;
import
com.edgec.browserbackend.common.utils.Trans
;
import
com.tencentcloudapi.cvm.v20170312.models.ModifyInstancesChargeTypeResponse
;
import
com.tencentcloudapi.cvm.v20170312.models.TerminateInstancesResponse
;
import
com.tencentcloudapi.lighthouse.v20200324.models.CreateInstancesResponse
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.format.DateTimeFormatter
;
...
...
@@ -172,6 +178,7 @@ public class BrowserTask {
CloudPlatformOrder
cloudPlatformOrder
=
new
CloudPlatformOrder
();
cloudPlatformOrder
.
setOwner
(
ipResource
.
getOwner
());
cloudPlatformOrder
.
setIpResourceId
(
ipResource
.
getId
());
cloudPlatformOrder
.
setOrderNo
(
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
())
+
SmsUtils
.
createRandom
(
true
,
4
));
boolean
result
=
false
;
if
(
ipResource
.
getVendorCn
().
equals
(
"阿里云"
))
{
//获取阿里云服务器region映射
...
...
@@ -257,6 +264,10 @@ public class BrowserTask {
cloudPlatformOrderRepository
.
save
(
cloudPlatformOrder
);
result
=
true
;
}
}
else
if
(
ipResource
.
getVendorCn
().
equals
(
"ipipv"
)){
//静态住宅ip
String
unit
=
ipResource
.
getUnit
().
equals
(
"week"
)
?
"2"
:
"3"
;
//AppOrderResp appOrderResp = IpvClient.instanceOpen();
}
/**
...
...
src/main/java/com/edgec/browserbackend/common/client/ipvClient/IpvClient.java
View file @
2e8f067e
package
com
.
edgec
.
browserbackend
.
common
.
client
.
ipvClient
;
import
com.alibaba.fastjson.JSON
;
import
com.edgec.browserbackend.browser.domain.CloudPlatformConfig
;
import
com.edgec.browserbackend.common.client.ipvClient.dto.*
;
import
com.edgec.browserbackend.common.client.ipvClient.utils.AESCBC
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.List
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
...
...
@@ -14,8 +18,11 @@ import org.apache.http.impl.client.HttpClients;
import
org.apache.http.message.BasicHeader
;
import
org.apache.http.protocol.HTTP
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.stereotype.Service
;
@Service
@RequiredArgsConstructor
@Slf4j
public
class
IpvClient
{
private
static
final
String
VERSION
=
"v2"
;
private
static
final
String
GET_APP_INFO_URI
=
"/api/open/app/info/"
+
VERSION
;
...
...
@@ -40,15 +47,9 @@ public class IpvClient {
public
static
final
String
ENCRYPT_AES
=
"AES"
;
private
String
endPoint
;
private
String
appKey
;
private
String
appSecret
;
public
IpvClient
(
String
endPoint
,
String
appKey
,
String
appSecret
)
{
this
.
appKey
=
appKey
;
this
.
endPoint
=
endPoint
;
this
.
appSecret
=
appSecret
;
}
private
static
String
endPoint
=
"https://sandbox.ipipv.com"
;
private
static
String
appKey
=
"AK20240923090940"
;
private
static
String
appSecret
=
"zd7js60suebep2hkiane59g6v9j8jezv"
;
public
AppInfoResp
getAppInfo
()
throws
Exception
{
byte
[]
res
=
post
(
GET_APP_INFO_URI
,
null
);
...
...
@@ -114,10 +115,26 @@ public class IpvClient {
return
list
;
}
public
AppOrderResp
instanceOpen
(
AppInstanceOpenReq
req
)
throws
Exception
{
byte
[]
params
=
JSON
.
toJSONBytes
(
req
);
byte
[]
res
=
post
(
INSTANCE_OPEN_URI
,
params
);
AppOrderResp
resp
=
JSON
.
parseObject
(
new
String
(
res
),
AppOrderResp
.
class
);
public
static
AppOrderResp
instanceOpen
(
String
orderNo
,
String
owner
,
String
username
,
String
password
,
CloudPlatformConfig
config
)
{
AppOrderResp
resp
=
null
;
try
{
AppInstanceOpenReq
req
=
new
AppInstanceOpenReq
();
req
.
setAppOrderNo
(
orderNo
);
List
<
OpenParam
>
params
=
new
ArrayList
<>();
OpenParam
param
=
new
OpenParam
();
param
.
setCount
(
1
);
param
.
setProductNo
(
config
.
getTemplateId
());
param
.
setUnit
(
1
);
param
.
setDuration
(
10
);
param
.
setFlow
(
1
);
param
.
setCycleTimes
(
1
);
byte
[]
params1
=
JSON
.
toJSONBytes
(
req
);
byte
[]
res
=
post
(
INSTANCE_OPEN_URI
,
params1
);
resp
=
JSON
.
parseObject
(
new
String
(
res
),
AppOrderResp
.
class
);
}
catch
(
Exception
e
){
log
.
error
(
"fail to ipipv instanceOpen {}"
,
e
.
getMessage
());
}
return
resp
;
}
...
...
@@ -177,7 +194,7 @@ public class IpvClient {
return
resp
;
}
private
byte
[]
post
(
String
uri
,
byte
[]
data
)
throws
Exception
{
private
static
byte
[]
post
(
String
uri
,
byte
[]
data
)
throws
Exception
{
byte
[]
resdata
=
new
byte
[
0
];
//创建httpclient对象
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
...
...
src/main/java/com/edgec/browserbackend/common/enums/RegionMappingEnum.java
View file @
2e8f067e
...
...
@@ -17,38 +17,46 @@ import org.thymeleaf.expression.Lists;
@Getter
public
enum
RegionMappingEnum
{
MAIN_LAND
(
"mainland"
,
"中国随机"
,
""
,
""
),
CN_HZ
(
"hangzhou"
,
"杭州"
,
"cn-hangzhou"
,
""
),
CN_SH
(
"shanghai"
,
"上海"
,
"cn-shanghai"
,
"ap-shanghai"
),
CN_SZ
(
"shenzhen"
,
"深圳"
,
"cn-shenzhen"
,
""
),
CN_GZ
(
"guangzhou"
,
"广州"
,
"cn-guangzhou"
,
"ap-guangzhou"
),
CN_BJ
(
"beijing"
,
"北京"
,
"cn-beijing"
,
"ap-beijing"
),
CN_QD
(
"qingdao"
,
"青岛"
,
"cn-qingdao"
,
""
),
CN_ZJK
(
"zhangjiakou"
,
"张家口"
,
"cn-zhangjiakou"
,
""
),
CN_HHHT
(
"huhehaote"
,
"呼和浩特"
,
"cn-huhehaote"
,
""
),
CN_CD
(
"chengdu"
,
"成都"
,
"cn-chengdu"
,
""
),
CN_HY
(
"heyuan"
,
"河源"
,
"cn-heyuan"
,
""
),
CN_HK
(
"hongkong"
,
"中国香港"
,
"cn-hongkong"
,
""
),
US
(
"us"
,
"美国随机"
,
""
,
""
),
US_CALIFORNIA
(
"california"
,
"加利福尼亚"
,
""
,
""
),
//待确认
US_VIRGINIA
(
"virginia"
,
"弗吉尼亚"
,
"us-east-1"
,
""
),
EU_UK
(
"uk"
,
"英国-伦敦"
,
"eu-west-1"
,
""
),
EU_CENTRAL
(
"germany"
,
"德国-法兰克福"
,
"eu-central-1"
,
"eu-frankfurt"
),
JAPAN
(
"japan"
,
"日本-东京"
,
"ap-northeast-1"
,
"ap-tokyo"
),
SINGAPORE
(
"singapore"
,
"新加坡"
,
"ap-southeast-1"
,
"ap-singapore"
),
AUSTRALIA
(
"australia"
,
"澳大利亚-悉尼"
,
""
,
""
),
//待确认
MALAYSIA
(
"malaysia"
,
"马来西亚-吉隆坡"
,
"ap-southeast-3"
,
""
),
YAJIADA
(
"yajiada"
,
"印度尼西亚-雅加达"
,
"ap-southeast-5"
,
"ap-jakarta"
),
INDIA
(
"india"
,
"孟买"
,
""
,
"ap-mumbai"
),
//待确认
MEAST
(
"meast"
,
"迪拜"
,
"me-east-1"
,
""
),
BRAZIL
(
"brazil"
,
"巴西-圣保罗"
,
""
,
"sa-saopaulo"
),
ULANNQAB
(
"ulanqab"
,
"乌兰察布"
,
"cn-wulanchabu"
,
""
),
SILICON
(
"silicon"
,
"美国(硅谷)"
,
"us-west-1"
,
"na-siliconvalley"
),
NANJING
(
"nanjing"
,
"南京"
,
""
,
"ap-nanjing"
),
BANGKOK
(
"bangkok"
,
"泰国(曼谷)"
,
"ap-southeast-7"
,
""
),
MANILA
(
"manila"
,
"菲律宾-马尼拉"
,
"ap-southeast-6"
,
""
),
SEOUL
(
"seoul"
,
"韩国-首尔"
,
"ap-northeast-2"
,
"ap-seoul"
),
MAIN_LAND
(
"mainland"
,
"中国随机"
,
""
,
""
,
""
),
CN_HZ
(
"hangzhou"
,
"杭州"
,
"cn-hangzhou"
,
""
,
""
),
CN_SH
(
"shanghai"
,
"上海"
,
"cn-shanghai"
,
"ap-shanghai"
,
""
),
CN_SZ
(
"shenzhen"
,
"深圳"
,
"cn-shenzhen"
,
""
,
""
),
CN_GZ
(
"guangzhou"
,
"广州"
,
"cn-guangzhou"
,
"ap-guangzhou"
,
""
),
CN_BJ
(
"beijing"
,
"北京"
,
"cn-beijing"
,
"ap-beijing"
,
""
),
CN_QD
(
"qingdao"
,
"青岛"
,
"cn-qingdao"
,
""
,
""
),
CN_ZJK
(
"zhangjiakou"
,
"张家口"
,
"cn-zhangjiakou"
,
""
,
""
),
CN_HHHT
(
"huhehaote"
,
"呼和浩特"
,
"cn-huhehaote"
,
""
,
""
),
CN_CD
(
"chengdu"
,
"成都"
,
"cn-chengdu"
,
""
,
""
),
CN_HY
(
"heyuan"
,
"河源"
,
"cn-heyuan"
,
""
,
""
),
CN_HK
(
"hongkong"
,
"中国香港"
,
"cn-hongkong"
,
""
,
"ipideash_594"
),
US
(
"us"
,
"美国随机"
,
""
,
""
,
""
),
US_CALIFORNIA
(
"california"
,
"加利福尼亚"
,
""
,
""
,
""
),
//待确认
US_VIRGINIA
(
"virginia"
,
"弗吉尼亚"
,
"us-east-1"
,
""
,
"ipideash_589"
),
EU_UK
(
"uk"
,
"英国-伦敦"
,
"eu-west-1"
,
""
,
"ipideash_591"
),
EU_CENTRAL
(
"germany"
,
"德国-法兰克福"
,
"eu-central-1"
,
"eu-frankfurt"
,
""
),
JAPAN
(
"japan"
,
"日本-东京"
,
"ap-northeast-1"
,
"ap-tokyo"
,
""
),
SINGAPORE
(
"singapore"
,
"新加坡"
,
"ap-southeast-1"
,
"ap-singapore"
,
"ipideash_599"
),
AUSTRALIA
(
"australia"
,
"澳大利亚-悉尼"
,
""
,
""
,
""
),
//待确认
MALAYSIA
(
"malaysia"
,
"马来西亚-吉隆坡"
,
"ap-southeast-3"
,
""
,
"ipideash_604"
),
YAJIADA
(
"yajiada"
,
"印度尼西亚-雅加达"
,
"ap-southeast-5"
,
"ap-jakarta"
,
"ipideash_608"
),
INDIA
(
"india"
,
"孟买"
,
""
,
"ap-mumbai"
,
""
),
//待确认
MEAST
(
"meast"
,
"迪拜"
,
"me-east-1"
,
""
,
""
),
BRAZIL
(
"brazil"
,
"巴西-圣保罗"
,
""
,
"sa-saopaulo"
,
""
),
ULANNQAB
(
"ulanqab"
,
"乌兰察布"
,
"cn-wulanchabu"
,
""
,
""
),
SILICON
(
"silicon"
,
"美国(硅谷)"
,
"us-west-1"
,
"na-siliconvalley"
,
""
),
NANJING
(
"nanjing"
,
"南京"
,
""
,
"ap-nanjing"
,
""
),
BANGKOK
(
"bangkok"
,
"泰国(曼谷)"
,
"ap-southeast-7"
,
""
,
"ipideash_607"
),
MANILA
(
"manila"
,
"菲律宾-马尼拉"
,
"ap-southeast-6"
,
""
,
"ipideash_606"
),
SEOUL
(
"seoul"
,
"韩国-首尔"
,
"ap-northeast-2"
,
"ap-seoul"
,
"ipideash_621"
),
TW
(
"taiwan"
,
"中国-台湾"
,
""
,
""
,
"ipideash_592"
),
LSWJS
(
"lasiweijiasi"
,
"美国-拉斯维加斯"
,
""
,
""
,
"ipideash_592"
),
NY
(
"niuyue"
,
"美国-纽约"
,
""
,
""
,
"ipideash_590"
),
LSG
(
"luoshanji"
,
"美国-洛杉矶"
,
""
,
""
,
"ipideash_615"
),
MAM
(
"maiami"
,
"美国-迈阿密"
,
""
,
""
,
"ipideash_595"
),
HSD
(
"huashendun"
,
"美国-华盛顿"
,
""
,
""
,
"ipideash_613"
),
CAN
(
"canada"
,
"加拿大"
,
""
,
""
,
"ipideash_603"
),
YN
(
"yuenan"
,
"越南"
,
""
,
""
,
"ipideash_619"
),
;
...
...
@@ -61,6 +69,8 @@ public enum RegionMappingEnum {
private
final
String
tenCentRegionApi
;
//腾讯云地区api
private
final
String
ipipvRegionApi
;
//ipipv RegionApi
public
static
RegionMappingEnum
getByRegion
(
String
type
)
{
return
Arrays
.
stream
(
RegionMappingEnum
.
values
())
...
...
src/test/java/com/edgec/browserbackend/IpvCliestTest.java
View file @
2e8f067e
...
...
@@ -19,7 +19,7 @@ public class IpvCliestTest {
String
endPoint
=
"https://sandbox.ipipv.com"
;
String
appKey
=
"AK20240923090940"
;
String
appSecret
=
"zd7js60suebep2hkiane59g6v9j8jezv"
;
ipv
=
n
ew
IpvClient
(
endPoint
,
appKey
,
appSecret
)
;
ipv
=
n
ull
;
}
@Test
...
...
@@ -66,9 +66,8 @@ public class IpvCliestTest {
//param.setAppUsername();
params
.
add
(
param
);
req
.
setParams
(
params
);
AppOrderResp
resp
=
ipv
.
instanceOpen
(
req
);
System
.
out
.
println
(
resp
);
//AppOrderResp resp = ipv.instanceOpen(req);
// System.out.println(resp);
}
@Test
...
...
@@ -146,8 +145,8 @@ public class IpvCliestTest {
void
testInstanceRenew
()
throws
Exception
{
AppInstanceOpenReq
req
=
new
AppInstanceOpenReq
();
req
.
setAppOrderNo
(
"01"
);
AppOrderResp
resp
=
ipv
.
instanceOpen
(
req
);
System
.
out
.
println
(
resp
);
//
AppOrderResp resp = ipv.instanceOpen(req);
//
System.out.println(resp);
}
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment