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
184af7d7
Commit
184af7d7
authored
May 06, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'staging' into 'master'
Staging See merge request
!46
parents
a2c37855
73170831
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
431 additions
and
73 deletions
+431
-73
AccountController.java
.../browserbackend/account/controller/AccountController.java
+1
-1
AdministratorController.java
...erbackend/account/controller/AdministratorController.java
+1
-1
AccountRepository.java
.../browserbackend/account/repository/AccountRepository.java
+1
-1
AccountRepositoryCustom.java
...erbackend/account/repository/AccountRepositoryCustom.java
+0
-2
AccountRepositoryCustomImpl.java
...ckend/account/repository/AccountRepositoryCustomImpl.java
+0
-14
AdministratorService.java
.../browserbackend/account/service/AdministratorService.java
+1
-1
PaymentService.java
.../edgec/browserbackend/account/service/PaymentService.java
+1
-1
AdministratorServiceImpl.java
...ackend/account/service/impl/AdministratorServiceImpl.java
+4
-4
PaymentServiceImpl.java
...owserbackend/account/service/impl/PaymentServiceImpl.java
+4
-2
AuthenticationFailureEventListener.java
.../service/security/AuthenticationFailureEventListener.java
+1
-1
IpControlloer.java
...dgec/browserbackend/browser/controller/IpControlloer.java
+16
-0
IpResource.java
...a/com/edgec/browserbackend/browser/domain/IpResource.java
+8
-4
SpecialLine.java
.../com/edgec/browserbackend/browser/domain/SpecialLine.java
+68
-0
IpResourceDto.java
...a/com/edgec/browserbackend/browser/dto/IpResourceDto.java
+85
-0
ShopResultDto.java
...a/com/edgec/browserbackend/browser/dto/ShopResultDto.java
+4
-4
IpResourceRepository.java
...owserbackend/browser/repository/IpResourceRepository.java
+10
-5
SpecialLineRepository.java
...wserbackend/browser/repository/SpecialLineRepository.java
+7
-0
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+59
-10
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+21
-7
IpResourceService.java
...gec/browserbackend/browser/service/IpResourceService.java
+2
-0
Set3proxyTask.java
.../com/edgec/browserbackend/browser/task/Set3proxyTask.java
+83
-0
RemoteShellExecutor.java
...wserbackend/common/commons/utils/RemoteShellExecutor.java
+54
-15
No files found.
src/main/java/com/edgec/browserbackend/account/controller/AccountController.java
View file @
184af7d7
...
...
@@ -461,7 +461,7 @@ public class AccountController {
}
@RequestMapping
(
path
=
"/ali/withdraw"
,
method
=
RequestMethod
.
PUT
)
public
ResultDto
alipayWithdraw
(
Principal
principal
,
@RequestParam
(
"account"
)
String
account
,
@RequestParam
(
"realName"
)
String
realName
,
@RequestParam
(
"amount"
)
int
amount
)
{
public
ResultDto
alipayWithdraw
(
Principal
principal
,
@RequestParam
(
"account"
)
String
account
,
@RequestParam
(
"realName"
)
String
realName
,
@RequestParam
(
"amount"
)
double
amount
)
{
// //获取支付宝GET过来反馈信息
// Map<String,String> params = new HashMap<String,String>();
// Map requestParams = request.getParameterMap();
...
...
src/main/java/com/edgec/browserbackend/account/controller/AdministratorController.java
View file @
184af7d7
...
...
@@ -181,7 +181,7 @@ public class AdministratorController {
//查询某时段内增加的用户
@PreAuthorize
(
"hasRole('ADMIN')"
)
@RequestMapping
(
path
=
"/0xadministrator/searchperioduser"
,
method
=
RequestMethod
.
GET
)
public
Page
<
Account
>
searchCreateAccount
(
@RequestParam
(
value
=
"page"
)
int
page
,
@RequestParam
(
value
=
"size"
)
int
size
,
@RequestParam
(
value
=
"strDate1"
)
String
strDate1
,
@RequestParam
(
value
=
"strDate2"
)
String
strDate2
,
@RequestParam
(
"isAuthorized"
)
boolean
isAuthorized
){
public
Page
<
Account
>
searchCreateAccount
(
@RequestParam
(
value
=
"page"
)
int
page
,
@RequestParam
(
value
=
"size"
)
int
size
,
@RequestParam
(
value
=
"strDate1"
)
String
strDate1
,
@RequestParam
(
value
=
"strDate2"
)
String
strDate2
,
@RequestParam
(
value
=
"isAuthorized"
,
defaultValue
=
"5"
)
int
isAuthorized
){
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
return
administratorService
.
searchCreateAccountBetween
(
pageable
,
strDate1
,
strDate2
,
isAuthorized
);
}
...
...
src/main/java/com/edgec/browserbackend/account/repository/AccountRepository.java
View file @
184af7d7
...
...
@@ -35,7 +35,7 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
Page
<
Account
>
findAllBySignupDateBetweenAndParentIsNull
(
Pageable
pageable
,
Date
startDate
,
Date
endDate
);
Page
<
Account
>
findAllBySignupDateBetweenAndParentIsNullAndAuthorized
Not
(
Pageable
pageable
,
Date
startDate
,
Date
endDate
,
int
authorized
);
Page
<
Account
>
findAllBySignupDateBetweenAndParentIsNullAndAuthorized
(
Pageable
pageable
,
Date
startDate
,
Date
endDate
,
int
authorized
);
Page
<
Account
>
findAll
(
Pageable
pageable
);
...
...
src/main/java/com/edgec/browserbackend/account/repository/AccountRepositoryCustom.java
View file @
184af7d7
...
...
@@ -8,8 +8,6 @@ public interface AccountRepositoryCustom {
List
<
String
>
findInName
(
String
[]
name
);
List
<
String
>
findParents
(
List
<
String
>
names
);
void
updateRealNameAndIdCard
(
String
username
,
String
realName
,
String
idCard
);
Account
findByPromotion
(
String
code
);
...
...
src/main/java/com/edgec/browserbackend/account/repository/AccountRepositoryCustomImpl.java
View file @
184af7d7
...
...
@@ -9,7 +9,6 @@ import org.springframework.data.mongodb.core.aggregation.AggregationResults;
import
org.springframework.data.mongodb.core.aggregation.MatchOperation
;
import
org.springframework.data.mongodb.core.aggregation.ProjectionOperation
;
import
org.springframework.data.mongodb.core.query.BasicQuery
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Update
;
import
java.util.ArrayList
;
...
...
@@ -42,19 +41,6 @@ public class AccountRepositoryCustomImpl implements AccountRepositoryCustom {
return
accountTelephones
;
}
@Override
public
List
<
String
>
findParents
(
List
<
String
>
names
)
{
Document
query
=
new
Document
();
Document
fields
=
new
Document
();
fields
.
put
(
"name"
,
1
);
BasicQuery
basicQuery
=
new
BasicQuery
(
query
,
fields
);
Criteria
criteria
=
new
Criteria
();
basicQuery
.
addCriteria
(
criteria
.
orOperator
(
where
(
"name"
).
in
(
names
)));
return
null
;
}
@Override
public
void
updateRealNameAndIdCard
(
String
username
,
String
realName
,
String
idCard
)
{
Document
doc
=
new
Document
();
...
...
src/main/java/com/edgec/browserbackend/account/service/AdministratorService.java
View file @
184af7d7
...
...
@@ -38,7 +38,7 @@ public interface AdministratorService {
Page
<
UserPrePaidBilling
>
searchAllUserBillingPage
(
int
page
,
int
year1
,
int
month1
,
int
year2
,
int
month2
);
Page
<
Account
>
searchCreateAccountBetween
(
Pageable
pageable
,
String
strDate1
,
String
strDate2
,
boolean
isAuthorized
);
Page
<
Account
>
searchCreateAccountBetween
(
Pageable
pageable
,
String
strDate1
,
String
strDate2
,
int
isAuthorized
);
List
<
UserPrePaidBilling
>
getServiceFeeOwedUserInfo
();
...
...
src/main/java/com/edgec/browserbackend/account/service/PaymentService.java
View file @
184af7d7
...
...
@@ -22,7 +22,7 @@ public interface PaymentService {
UserPaymentDto
h5wxPayOrder
(
String
ip
,
String
username
,
int
amount
);
boolean
alipayWithdraw
(
String
username
,
String
account
,
String
realName
,
int
amount
);
boolean
alipayWithdraw
(
String
username
,
String
account
,
String
realName
,
double
amount
);
public
UserPaymentDto
wxCheckOrderStatus
(
String
tradeno
);
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AdministratorServiceImpl.java
View file @
184af7d7
...
...
@@ -225,16 +225,16 @@ public class AdministratorServiceImpl implements AdministratorService {
}
@Override
public
Page
<
Account
>
searchCreateAccountBetween
(
Pageable
pageable
,
String
strDate1
,
String
strDate2
,
boolean
isAuthorized
)
{
public
Page
<
Account
>
searchCreateAccountBetween
(
Pageable
pageable
,
String
strDate1
,
String
strDate2
,
int
isAuthorized
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Page
<
Account
>
accounts
=
null
;
try
{
Date
dateTime1
=
formatter
.
parse
(
strDate1
);
Date
dateTime2
=
formatter
.
parse
(
strDate2
);
if
(
isAuthorized
)
accounts
=
accountRepository
.
findAllBySignupDateBetweenAndParentIsNullAndAuthorizedNot
(
pageable
,
dateTime1
,
dateTime2
,
0
);
else
if
(
isAuthorized
==
5
)
accounts
=
accountRepository
.
findAllBySignupDateBetweenAndParentIsNull
(
pageable
,
dateTime1
,
dateTime2
);
else
accounts
=
accountRepository
.
findAllBySignupDateBetweenAndParentIsNullAndAuthorized
(
pageable
,
dateTime1
,
dateTime2
,
isAuthorized
);
}
catch
(
ParseException
e
){
e
.
printStackTrace
();
}
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/PaymentServiceImpl.java
View file @
184af7d7
...
...
@@ -35,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.stereotype.Service
;
import
javax.swing.text.Document
;
import
java.text.SimpleDateFormat
;
import
java.time.Instant
;
import
java.time.YearMonth
;
...
...
@@ -590,7 +591,8 @@ public class PaymentServiceImpl implements PaymentService {
}
@Override
public
boolean
alipayWithdraw
(
String
username
,
String
account
,
String
realName
,
int
amount
)
{
public
boolean
alipayWithdraw
(
String
username
,
String
account
,
String
realName
,
double
amount
)
{
java
.
text
.
DecimalFormat
df
=
new
java
.
text
.
DecimalFormat
(
"#.00"
);
Account
byName
=
accountService
.
findByName
(
username
);
if
(
byName
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
,
"account does not exist: "
+
username
);
...
...
@@ -619,7 +621,7 @@ public class PaymentServiceImpl implements PaymentService {
AlipayFundTransToaccountTransferRequest
alipayRequest
=
new
AlipayFundTransToaccountTransferRequest
();
String
out_biz_no
=
internalOrder
.
getTradeNo
();
String
trans_amount
=
""
+
amount
+
".00"
;
String
trans_amount
=
""
+
df
.
format
(
amount
)
;
String
identity_type
=
"ALIPAY_LOGONID"
;
String
subject
=
"礼金提现"
+
out_biz_no
;
...
...
src/main/java/com/edgec/browserbackend/auth/service/security/AuthenticationFailureEventListener.java
View file @
184af7d7
...
...
@@ -32,7 +32,7 @@ public class AuthenticationFailureEventListener implements ApplicationListener<A
if
(
userAttempts
!=
null
)
{
if
(
userAttempts
.
getDate
().
getTime
()
>=
(
new
Date
().
getTime
()
-
600000
))
{
int
fails
=
userAttempts
.
getAttempts
();
if
(
fails
<
5
)
if
(
fails
<
20
)
saveUserAttemptsLogin
(
username
,
fails
+
1
);
else
throw
new
ClientRequestException
(
AuthErrorCode
.
LOGINTIMESEXCEEDED
,
"Login times exceeded"
);
...
...
src/main/java/com/edgec/browserbackend/browser/controller/IpControlloer.java
View file @
184af7d7
...
...
@@ -151,4 +151,20 @@ public class IpControlloer {
}
return
resultDto
;
}
@RequestMapping
(
value
=
"/special/set"
,
method
=
RequestMethod
.
PUT
)
public
ResultDto
setSpecialLine
(
Principal
principal
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
ipResourceService
.
setSpecialLine
();
resultDto
.
setStatus
(
0
);
}
catch
(
Exception
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
80001
);
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
return
resultDto
;
}
}
src/main/java/com/edgec/browserbackend/browser/domain/IpResource.java
View file @
184af7d7
...
...
@@ -21,7 +21,7 @@ public class IpResource implements Serializable {
private
String
vendorCn
;
private
String
region
;
private
String
regionCn
;
//0:正常, 1:已过期, 2:即将过期, 3:正在分配, 4:未使用, 5:已失效, 6:未分配, 7:未缴费
//0:正常, 1:已过期, 2:即将过期, 3:正在分配, 4:未使用, 5:已失效, 6:未分配, 7:未缴费
, 8:分配成功
private
int
status
;
private
List
<
String
>
port
;
private
long
purchasedTime
;
...
...
@@ -36,8 +36,10 @@ public class IpResource implements Serializable {
private
String
password
;
private
double
price
;
private
String
proxyUsername
;
private
String
proxyPassword
;
private
boolean
specialLine
;
//是否使用专线
//专线数据
private
String
proxyUsername
;
//专线的代理用户名
private
String
proxyPassword
;
//专线的代理密码
private
String
shopId
;
private
String
shopName
;
...
...
@@ -48,7 +50,8 @@ public class IpResource implements Serializable {
private
String
unit
;
private
int
period
;
private
boolean
specialLine
;
public
IpResource
()
{
}
public
String
getDetails
()
{
return
details
;
...
...
@@ -281,4 +284,5 @@ public class IpResource implements Serializable {
public
void
setSpecialLine
(
boolean
specialLine
)
{
this
.
specialLine
=
specialLine
;
}
}
src/main/java/com/edgec/browserbackend/browser/domain/SpecialLine.java
0 → 100644
View file @
184af7d7
package
com
.
edgec
.
browserbackend
.
browser
.
domain
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
java.util.List
;
@Document
(
"specialline"
)
public
class
SpecialLine
{
@Id
private
String
Id
;
private
String
ip
;
private
List
<
String
>
proxyProtocol
;
//专线使用的协议
private
List
<
String
>
proxyPort
;
//专线使用的端口
private
String
username
;
//专线代理服务器用户名
private
String
password
;
//专线代理服务器密码
public
String
getIp
()
{
return
ip
;
}
public
void
setIp
(
String
ip
)
{
this
.
ip
=
ip
;
}
public
String
getId
()
{
return
Id
;
}
public
void
setId
(
String
id
)
{
Id
=
id
;
}
public
List
<
String
>
getProxyProtocol
()
{
return
proxyProtocol
;
}
public
void
setProxyProtocol
(
List
<
String
>
proxyProtocol
)
{
this
.
proxyProtocol
=
proxyProtocol
;
}
public
List
<
String
>
getProxyPort
()
{
return
proxyPort
;
}
public
void
setProxyPort
(
List
<
String
>
proxyPort
)
{
this
.
proxyPort
=
proxyPort
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
}
src/main/java/com/edgec/browserbackend/browser/dto/IpResourceDto.java
View file @
184af7d7
...
...
@@ -24,6 +24,15 @@ public class IpResourceDto {
ShopDto
bindShop
;
private
List
<
BindHistory
>
bindHistories
;
private
boolean
specialLine
;
//专线数据
private
String
proxyUsername
;
private
String
proxyPassword
;
private
List
<
String
>
proxyProtocol
;
private
List
<
String
>
proxyPort
;
private
String
specialLineIp
;
public
IpResourceDto
(){
}
...
...
@@ -40,7 +49,35 @@ public class IpResourceDto {
this
.
details
=
ipResource
.
getDetails
();
this
.
password
=
ipResource
.
getPassword
();
this
.
protocol
=
ipResource
.
getProtocol
();
this
.
specialLine
=
ipResource
.
isSpecialLine
();
if
(
shopDto
!=
null
)
this
.
bindShop
=
shopDto
;
if
(
useHistory
)
this
.
bindHistories
=
ipResource
.
getBindHistory
();
else
this
.
bindHistories
=
new
ArrayList
<>();
}
public
IpResourceDto
(
IpResource
ipResource
,
ShopDto
shopDto
,
boolean
useHistory
,
SpecialLine
specialLine1
){
this
.
id
=
ipResource
.
getId
();
this
.
addr
=
ipResource
.
getAddr
();
this
.
vendor
=
ipResource
.
getVendor
();
this
.
region
=
ipResource
.
getRegion
();
this
.
status
=
ipResource
.
getStatus
();
this
.
port
=
ipResource
.
getPort
();
this
.
purchasedTime
=
ipResource
.
getPurchasedTime
();
this
.
validTime
=
ipResource
.
getValidTime
();
this
.
username
=
ipResource
.
getUsername
();
this
.
details
=
ipResource
.
getDetails
();
this
.
password
=
ipResource
.
getPassword
();
this
.
protocol
=
ipResource
.
getProtocol
();
this
.
proxyUsername
=
ipResource
.
getProxyUsername
();
this
.
proxyPassword
=
ipResource
.
getProxyPassword
();
this
.
proxyPort
=
specialLine1
.
getProxyPort
();
this
.
proxyProtocol
=
specialLine1
.
getProxyProtocol
();
this
.
specialLine
=
ipResource
.
isSpecialLine
();
this
.
bindShop
=
shopDto
;
this
.
specialLineIp
=
specialLine1
.
getIp
();
if
(
useHistory
)
this
.
bindHistories
=
ipResource
.
getBindHistory
();
else
...
...
@@ -158,4 +195,52 @@ public class IpResourceDto {
public
void
setBindHistories
(
List
<
BindHistory
>
bindHistories
)
{
this
.
bindHistories
=
bindHistories
;
}
public
String
getProxyPassword
()
{
return
proxyPassword
;
}
public
void
setProxyPassword
(
String
proxyPassword
)
{
this
.
proxyPassword
=
proxyPassword
;
}
public
String
getProxyUsername
()
{
return
proxyUsername
;
}
public
void
setProxyUsername
(
String
proxyUsername
)
{
this
.
proxyUsername
=
proxyUsername
;
}
public
boolean
isSpecialLine
()
{
return
specialLine
;
}
public
void
setSpecialLine
(
boolean
specialLine
)
{
this
.
specialLine
=
specialLine
;
}
public
List
<
String
>
getProxyProtocol
()
{
return
proxyProtocol
;
}
public
void
setProxyProtocol
(
List
<
String
>
proxyProtocol
)
{
this
.
proxyProtocol
=
proxyProtocol
;
}
public
String
getSpecialLineIp
()
{
return
specialLineIp
;
}
public
void
setSpecialLineIp
(
String
specialLineIp
)
{
this
.
specialLineIp
=
specialLineIp
;
}
public
List
<
String
>
getProxyPort
()
{
return
proxyPort
;
}
public
void
setProxyPort
(
List
<
String
>
proxyPort
)
{
this
.
proxyPort
=
proxyPort
;
}
}
src/main/java/com/edgec/browserbackend/browser/dto/ShopResultDto.java
View file @
184af7d7
...
...
@@ -32,11 +32,11 @@ public class ShopResultDto {
private
String
shopCookie
;
private
IpResource
bindIp
;
private
IpResource
Dto
bindIp
;
private
long
createTime
;
public
static
ShopResultDto
of
(
Shop
shop
,
String
group
,
IpResource
ipResources
)
{
public
static
ShopResultDto
of
(
Shop
shop
,
String
group
,
IpResource
Dto
ipResources
)
{
ShopResultDto
shopResultDto
=
new
ShopResultDto
();
shopResultDto
.
setShopId
(
shop
.
getShopId
());
if
(
shop
.
getShopName
()
!=
null
)
...
...
@@ -135,11 +135,11 @@ public class ShopResultDto {
this
.
shopUrl
=
shopUrl
;
}
public
IpResource
getBindIp
()
{
public
IpResource
Dto
getBindIp
()
{
return
bindIp
;
}
public
void
setBindIp
(
IpResource
bindIp
)
{
public
void
setBindIp
(
IpResource
Dto
bindIp
)
{
this
.
bindIp
=
bindIp
;
}
...
...
src/main/java/com/edgec/browserbackend/browser/repository/IpResourceRepository.java
View file @
184af7d7
...
...
@@ -22,11 +22,16 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
List
<
IpResource
>
findByOwnerAndStatusIsNotInAndIsDeletedAndShopIdIsNull
(
String
owner
,
List
<
Integer
>
status
,
boolean
isDeleted
);
List
<
IpResource
>
findByOwnerAndStatusAndIsDeletedAndShopIdIsNull
(
String
owner
,
int
status
,
boolean
isDeleted
);
List
<
IpResource
>
findByStatusAndShopIdInAndIsDeleted
(
int
status
,
List
<
String
>
ipIds
,
boolean
isDeleted
);
Page
<
IpResource
>
findByAddrLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc
(
String
addr
,
List
<
String
>
ipIds
,
boolean
isDeleted
,
Pageable
pageable
);
Page
<
IpResource
>
findByVendorCnLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc
(
String
vendorCn
,
List
<
String
>
ipIds
,
boolean
isDeleted
,
Pageable
pageable
);
Page
<
IpResource
>
findByVendorLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc
(
String
vendor
,
List
<
String
>
ipIds
,
boolean
isDeleted
,
Pageable
pageable
);
Page
<
IpResource
>
findByRegionCnLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc
(
String
region
,
List
<
String
>
ipIds
,
boolean
isDeleted
,
Pageable
pageable
);
List
<
IpResource
>
findByRegionCnLikeAndShopIdInAndIsDeleted
(
String
regionCn
,
List
<
String
>
shopIds
,
boolean
isDeleted
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndAddrLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
addr
,
Pageable
pageable
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndVendorCnLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
vendorCn
,
Pageable
pageable
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndVendorLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
vendor
,
Pageable
pageable
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndRegionCnLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
region
,
Pageable
pageable
);
List
<
IpResource
>
findByIsDeletedAndShopIdInAndRegionCnLike
(
boolean
isDeleted
,
List
<
String
>
shopIds
,
String
regionCn
);
List
<
IpResource
>
findByOwnerInAndSpecialLine
(
List
<
String
>
owners
,
boolean
specialLine
);
List
<
IpResource
>
findBySpecialLine
(
boolean
specialLine
);
List
<
IpResource
>
findByRegionIn
(
List
<
String
>
regions
);
List
<
IpResource
>
findByStatusAndLockedAndLockTimestampLessThan
(
int
status
,
boolean
locked
,
long
timestamp
);
...
...
src/main/java/com/edgec/browserbackend/browser/repository/SpecialLineRepository.java
0 → 100644
View file @
184af7d7
package
com
.
edgec
.
browserbackend
.
browser
.
repository
;
import
com.edgec.browserbackend.browser.domain.SpecialLine
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
public
interface
SpecialLineRepository
extends
MongoRepository
<
SpecialLine
,
String
>
{
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
184af7d7
...
...
@@ -83,6 +83,9 @@ public class IpResourceServiceImpl implements IpResourceService {
@Autowired
private
IpAndShopService
ipAndShopService
;
@Autowired
private
SpecialLineRepository
specialLineRepository
;
public
HttpHeaders
buildPostHeader
()
{
HttpHeaders
header
=
new
HttpHeaders
();
header
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
...
...
@@ -150,6 +153,11 @@ public class IpResourceServiceImpl implements IpResourceService {
return
retStr
;
}
public
static
void
main
(
String
[]
args
)
{
String
password
=
genRandom
(
3
,
12
);
System
.
out
.
println
(
password
);
}
private
IpChargeRequestDto
buildIpChargeRequestDto
(
IpResourceRequestDto
request
,
int
chargeType
,
int
payMethod
)
{
IpChargeRequestDto
ipChargeRequestDto
=
new
IpChargeRequestDto
();
ipChargeRequestDto
.
setAmount
(
request
.
getAmount
());
...
...
@@ -510,13 +518,13 @@ public class IpResourceServiceImpl implements IpResourceService {
List
<
String
>
allIpIds
=
ipResources
.
stream
().
map
(
x
->
x
.
getId
()).
collect
(
Collectors
.
toList
());
Page
<
IpResource
>
ipResources1
=
null
;
if
(
ipFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
ipFilterDto
.
getRegion
()))
{
ipResources1
=
ipResourceRepository
.
findBy
RegionCnLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc
(
ipFilterDto
.
getRegion
(),
allIpIds
,
false
,
pageable
);
ipResources1
=
ipResourceRepository
.
findBy
IsDeletedAndIdInAndRegionCnLikeOrderByPurchasedTimeDesc
(
false
,
allIpIds
,
ipFilterDto
.
getRegion
()
,
pageable
);
}
else
if
(
ipFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
ipFilterDto
.
getAddr
()))
{
ipResources1
=
ipResourceRepository
.
findBy
AddrLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc
(
ipFilterDto
.
getAddr
(),
allIpIds
,
false
,
pageable
);
ipResources1
=
ipResourceRepository
.
findBy
IsDeletedAndIdInAndAddrLikeOrderByPurchasedTimeDesc
(
false
,
allIpIds
,
ipFilterDto
.
getAddr
()
,
pageable
);
}
else
if
(
ipFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
ipFilterDto
.
getVendor
()))
{
ipResources1
=
ipResourceRepository
.
findBy
VendorCnLikeAndIdInAndIsDeletedOrderByPurchasedTimeDesc
(
ipFilterDto
.
getVendor
(),
allIpIds
,
false
,
pageable
);
ipResources1
=
ipResourceRepository
.
findBy
IsDeletedAndIdInAndVendorCnLikeOrderByPurchasedTimeDesc
(
false
,
allIpIds
,
ipFilterDto
.
getVendor
()
,
pageable
);
}
else
{
ipResources1
=
ipResourceRepository
.
findByIdInAndIsDeletedOrderByPurchasedTimeDesc
(
allIpIds
,
false
,
pageable
);
}
...
...
@@ -532,7 +540,10 @@ public class IpResourceServiceImpl implements IpResourceService {
shopDto
=
new
ShopDto
(
shop
);
}
if
(
StringUtils
.
isNotBlank
(
x
.
getAddr
()))
{
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
x
.
getLockTimestamp
()
>=
Instant
.
now
().
minusSeconds
(
120
).
toEpochMilli
()
&&
x
.
getIpType
()
==
IpType
.
VENDOR
&&
(
x
.
getStatus
()
==
0
||
x
.
getStatus
()
==
2
))
{
x
.
setStatus
(
3
);
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
x
.
getStatus
()
!=
5
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
x
.
setStatus
(
2
);
ipResourceRepository
.
save
(
x
);
...
...
@@ -569,7 +580,11 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(
x
.
getStatus
()
==
3
)
{
x
.
setAddr
(
""
);
}
ipResourceDtos
.
add
(
new
IpResourceDto
(
x
,
shopDto
,
false
));
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
if
(
x
.
isSpecialLine
())
ipResourceDtos
.
add
(
new
IpResourceDto
(
x
,
shopDto
,
false
,
specialLine
));
else
ipResourceDtos
.
add
(
new
IpResourceDto
(
x
,
shopDto
,
false
));
});
}
...
...
@@ -692,11 +707,7 @@ public class IpResourceServiceImpl implements IpResourceService {
ipResource
.
setStatus
(
2
);
ipResourceRepository
.
save
(
ipResource
);
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
())
{
if
(
ipResource
.
getIpType
()
==
IpType
.
VENDOR
)
{
deleteIp
(
username
,
ipResourceRequestDto
);
}
else
{
deleteIp
(
username
,
ipResourceRequestDto
);
}
deleteIp
(
username
,
ipResourceRequestDto
);
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
())
{
ipResource
.
setStatus
(
1
);
ipResourceRepository
.
save
(
ipResource
);
...
...
@@ -711,4 +722,42 @@ public class IpResourceServiceImpl implements IpResourceService {
return
ipResourceDto
;
}
@Override
public
void
setSpecialLine
()
{
List
<
IpResource
>
ipResources
=
ipResourceRepository
.
findByRegionIn
(
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"
));
for
(
IpResource
ipResource
:
ipResources
)
{
ipResource
.
setProxyUsername
(
ipResource
.
getAddr
());
ipResource
.
setProxyPassword
(
genRandom
(
3
,
12
));
ipResource
.
setSpecialLine
(
true
);
ipResourceRepository
.
save
(
ipResource
);
}
}
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
184af7d7
...
...
@@ -7,10 +7,7 @@ import com.edgec.browserbackend.account.repository.AccountRepository;
import
com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode
;
import
com.edgec.browserbackend.browser.domain.*
;
import
com.edgec.browserbackend.browser.dto.*
;
import
com.edgec.browserbackend.browser.repository.GroupRepository
;
import
com.edgec.browserbackend.browser.repository.IpResourceRepository
;
import
com.edgec.browserbackend.browser.repository.ShopRepository
;
import
com.edgec.browserbackend.browser.repository.UserShopRepository
;
import
com.edgec.browserbackend.browser.repository.*
;
import
com.edgec.browserbackend.browser.service.IpAndShopService
;
import
com.edgec.browserbackend.browser.service.ShopService
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
...
...
@@ -25,6 +22,7 @@ import org.springframework.data.domain.PageImpl;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.security.core.parameters.P
;
import
org.springframework.security.task.DelegatingSecurityContextAsyncTaskExecutor
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -63,6 +61,9 @@ public class ShopServiceImpl implements ShopService {
@Autowired
IpAndShopService
ipAndShopService
;
@Autowired
SpecialLineRepository
specialLineRepository
;
@Override
public
String
addShop
(
String
username
,
ShopResultDto
shopResultDto
)
{
Account
account
=
accountRepository
.
findByName
(
username
);
...
...
@@ -319,7 +320,13 @@ public class ShopServiceImpl implements ShopService {
if
(
ipResource
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
String
group
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shop
.
getShopId
()).
getGroupId
();
ShopResultDto
shopResultDto
=
ShopResultDto
.
of
(
shop
,
group
,
ipResource
);
ShopResultDto
shopResultDto
=
null
;
if
(
ipResource
.
isSpecialLine
())
{
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
shopResultDto
=
ShopResultDto
.
of
(
shop
,
group
,
new
IpResourceDto
(
ipResource
,
null
,
false
,
specialLine
));
}
else
shopResultDto
=
ShopResultDto
.
of
(
shop
,
group
,
new
IpResourceDto
(
ipResource
,
null
,
false
));
return
shopResultDto
;
}
...
...
@@ -382,7 +389,7 @@ public class ShopServiceImpl implements ShopService {
}
Page
<
Shop
>
shops
;
if
(
shopFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
shopFilterDto
.
getIpRegion
()))
{
List
<
String
>
filter
=
ipResourceRepository
.
findBy
RegionCnLikeAndShopIdInAndIsDeleted
(
shopFilterDto
.
getIpRegion
(),
shopIds
,
false
)
List
<
String
>
filter
=
ipResourceRepository
.
findBy
IsDeletedAndShopIdInAndRegionCnLike
(
false
,
shopIds
,
shopFilterDto
.
getIpRegion
()
)
.
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
shops
=
shopRepository
.
findByShopIdInOrderByCreateTimeDesc
(
filter
,
pageable
);
}
...
...
@@ -400,7 +407,14 @@ public class ShopServiceImpl implements ShopService {
if
(
ipResource
==
null
)
ipResource
=
new
IpResource
();
String
group1
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
x
.
getShopId
()).
getGroupId
();
shopResultDtos
.
add
(
ShopResultDto
.
of
(
x
,
group1
,
ipResource
));
ShopResultDto
shopResultDto
=
null
;
if
(
ipResource
.
isSpecialLine
())
{
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
shopResultDto
=
ShopResultDto
.
of
(
x
,
group1
,
new
IpResourceDto
(
ipResource
,
null
,
false
,
specialLine
));
}
else
shopResultDto
=
ShopResultDto
.
of
(
x
,
group1
,
new
IpResourceDto
(
ipResource
,
null
,
false
));
shopResultDtos
.
add
(
shopResultDto
);
});
Page
<
ShopResultDto
>
shopDtoPage
=
new
PageImpl
<>(
shopResultDtos
,
pageable
,
shopIds
.
size
());
ShopPageResultDto
shopPageResultDto
=
new
ShopPageResultDto
();
...
...
src/main/java/com/edgec/browserbackend/browser/service/IpResourceService.java
View file @
184af7d7
...
...
@@ -28,4 +28,6 @@ public interface IpResourceService {
boolean
queryIpExist
(
String
username
,
IpResourceUpdateDto
ipResourceUpdateDto
);
IpResourceDto
queryIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
);
void
setSpecialLine
();
}
src/main/java/com/edgec/browserbackend/browser/task/Set3proxyTask.java
0 → 100644
View file @
184af7d7
package
com
.
edgec
.
browserbackend
.
browser
.
task
;
import
com.edgec.browserbackend.account.repository.AccountRepository
;
import
com.edgec.browserbackend.auth.domain.mongo.MongoOAuth2AccessToken
;
import
com.edgec.browserbackend.auth.repository.mongo.MongoOAuth2AccessTokenRepository
;
import
com.edgec.browserbackend.browser.domain.IpResource
;
import
com.edgec.browserbackend.browser.domain.SpecialLine
;
import
com.edgec.browserbackend.browser.repository.IpResourceRepository
;
import
com.edgec.browserbackend.browser.repository.SpecialLineRepository
;
import
com.edgec.browserbackend.browser.service.Impl.IpResourceServiceImpl
;
import
com.edgec.browserbackend.common.commons.utils.RemoteShellExecutor
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
java.io.*
;
import
java.time.Instant
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Component
public
class
Set3proxyTask
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
Set3proxyTask
.
class
);
@Autowired
private
AccountRepository
accountRepository
;
@Autowired
private
MongoOAuth2AccessTokenRepository
mongoOAuth2AccessTokenRepository
;
@Autowired
private
IpResourceRepository
ipResourceRepository
;
@Autowired
private
SpecialLineRepository
specialLineRepository
;
@Scheduled
(
cron
=
"0 0/10 * * * ?"
)
public
void
set3proxy
()
{
long
validTime
=
Instant
.
now
().
minusSeconds
(
43200
).
toEpochMilli
();
// List<String> tokenUsernames = mongoOAuth2AccessTokenRepository.findByCreatedAtGreaterThan(validTime).stream().map(MongoOAuth2AccessToken::getUsername).collect(Collectors.toList());
// List<String> accountParents = accountRepository.findByNameIn(tokenUsernames).stream().map(x -> x.getParent() == null ? x.getName() : x.getParent()).distinct().collect(Collectors.toList());
List
<
IpResource
>
ipResources
=
ipResourceRepository
.
findBySpecialLine
(
true
);
File
file
=
new
File
(
"3proxy.cfg"
);
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
try
{
file
.
delete
();
file
.
createNewFile
();
FileWriter
fileWriter
=
new
FileWriter
(
file
,
true
);
BufferedWriter
bw
=
new
BufferedWriter
(
fileWriter
);
bw
.
write
(
"daemon\nlog /var/log/3proxy.log D\nrotate 30\n"
);
bw
.
write
(
"config /root/3proxy.cfg\n"
);
bw
.
write
(
"monitor /root/3proxy.cfg\n"
);
for
(
IpResource
ipResource
:
ipResources
)
{
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
bw
.
write
(
"users \""
+
ipResource
.
getProxyUsername
()
+
":CL:"
+
ipResource
.
getProxyPassword
()
+
"\"\n"
);
}
bw
.
write
(
"\nauth strong\n"
);
for
(
IpResource
ipResource
:
ipResources
)
{
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
{
bw
.
write
(
"allow "
+
ipResource
.
getProxyUsername
()
+
"\n"
);
bw
.
write
(
"parent 1000 "
+
specialLine
.
getProxyProtocol
().
get
(
0
)
+
" "
+
ipResource
.
getAddr
()
+
" "
+
ipResource
.
getPort
().
get
(
1
)
+
" fangguanlianbrowser "
+
ipResource
.
getPassword
()
+
"\n"
);
}
}
bw
.
write
(
"\nallow none\nproxy -p20004\nsocks-p20005"
);
bw
.
flush
();
bw
.
close
();
log
.
info
(
"成功写入文件"
);
// RemoteShellExecutor remoteShellExecutor = new RemoteShellExecutor(specialLine.getIp(), specialLine.getUsername(), specialLine.getPassword());
// remoteShellExecutor.transferFile("3proxy.cfg", "/root");
// remoteShellExecutor.execCommand("cd /root && sh restart.sh");
}
catch
(
Exception
e
)
{
log
.
error
(
"出错了"
);
log
.
error
(
e
.
getMessage
());
}
}
}
src/main/java/com/edgec/browserbackend/common/commons/utils/RemoteShellExecutor.java
View file @
184af7d7
...
...
@@ -72,6 +72,7 @@ public class RemoteShellExecutor {
out
=
new
PrintWriter
(
new
OutputStreamWriter
(
session
.
getStdin
(),
"UTF-8"
));
out
.
println
(
command
);
System
.
out
.
println
(
command
);
out
.
flush
();
}
finally
{
if
(
null
!=
out
)
{
...
...
@@ -231,22 +232,59 @@ public class RemoteShellExecutor {
throw
new
RuntimeException
(
localFile
+
" is not a file"
);
}
String
fileName
=
file
.
getName
();
System
.
out
.
println
(
fileName
);
InputStream
stdOut
=
null
;
InputStream
stdErr
=
null
;
String
outStr
=
""
;
String
outErr
=
""
;
try
{
Session
session
=
conn
.
openSession
();
executeCommand
(
"mkdir -p "
+
remoteTargetDirectory
,
session
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"登录远程机器失败"
+
ip
);
}
SCPClient
sCPClient
=
conn
.
createSCPClient
();
SCPOutputStream
scpOutputStream
=
sCPClient
.
put
(
fileName
,
file
.
length
(),
remoteTargetDirectory
,
"0600"
);
if
(
login
())
{
Session
session
=
conn
.
openSession
();
session
.
startShell
();
stdOut
=
new
StreamGobbler
(
session
.
getStdout
());
stdErr
=
new
StreamGobbler
(
session
.
getStderr
());
BufferedReader
stdoutReader
=
new
BufferedReader
(
new
InputStreamReader
(
stdOut
));
BufferedReader
stderrReader
=
new
BufferedReader
(
new
InputStreamReader
(
stdErr
));
executeCommand
(
"mkdir -p "
+
remoteTargetDirectory
,
session
);
SCPClient
sCPClient
=
conn
.
createSCPClient
();
SCPOutputStream
scpOutputStream
=
sCPClient
.
put
(
fileName
,
file
.
length
(),
remoteTargetDirectory
,
"0600"
);
String
content
=
IOUtils
.
toString
(
new
FileInputStream
(
file
),
StandardCharsets
.
UTF_8
);
scpOutputStream
.
write
(
content
.
getBytes
());
scpOutputStream
.
flush
();
scpOutputStream
.
close
();
String
content
=
IOUtils
.
toString
(
new
FileInputStream
(
file
),
StandardCharsets
.
UTF_8
);
scpOutputStream
.
write
(
content
.
getBytes
());
scpOutputStream
.
flush
();
scpOutputStream
.
close
();
session
.
waitForCondition
(
ChannelCondition
.
CLOSED
|
ChannelCondition
.
EOF
|
ChannelCondition
.
EXIT_STATUS
,
30000
);
logger
.
error
(
"Here is the output from stdout:"
);
while
(
true
)
{
String
line
=
stdoutReader
.
readLine
();
if
(
line
==
null
)
break
;
System
.
out
.
println
(
line
);
}
logger
.
error
(
"Here is the output from stderr:"
);
while
(
true
)
{
String
line
=
stderrReader
.
readLine
();
if
(
line
==
null
)
break
;
System
.
out
.
println
(
line
);
}
/* Show exit status, if available (otherwise "null") */
logger
.
error
(
"ExitCode: "
+
session
.
getExitStatus
());
session
.
close
();
/* Close this session */
conn
.
close
();
/* Close the connection */
}
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
());
throw
new
Exception
(
"登录远程机器失败"
+
ip
);
}
finally
{
if
(
conn
!=
null
)
{
conn
.
close
();
}
IOUtils
.
closeQuietly
(
stdOut
);
IOUtils
.
closeQuietly
(
stdErr
);
}
}
...
...
@@ -281,8 +319,8 @@ public class RemoteShellExecutor {
}
public
static
void
main
(
String
args
[])
throws
Exception
{
RemoteShellExecutor
executor
=
new
RemoteShellExecutor
(
"
120.25.233.237"
,
"root"
,
"5t8EsTuDH00u
aA1"
);
RemoteShellExecutor
executor
=
new
RemoteShellExecutor
(
"
47.112.253.229"
,
"root"
,
"hIB4EbOcnkF5
aA1"
);
executor
.
transferFile
(
"3proxy.cfg"
,
"/root"
);
//
executor.execCommand("cd /root && sh restart.sh");
executor
.
execCommand
(
"cd /root && sh restart.sh"
);
}
}
\ No newline at end of file
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