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
17eb5a06
Commit
17eb5a06
authored
May 13, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'staging' into 'master'
Staging See merge request
!92
parents
b287570b
21eadd88
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
126 additions
and
43 deletions
+126
-43
PaymentServiceImpl.java
...owserbackend/account/service/impl/PaymentServiceImpl.java
+4
-4
IpResource.java
...a/com/edgec/browserbackend/browser/domain/IpResource.java
+17
-0
IpResourceRepositoryCustom.java
...ackend/browser/repository/IpResourceRepositoryCustom.java
+4
-0
IpResourceRepositoryCustomImpl.java
...nd/browser/repository/IpResourceRepositoryCustomImpl.java
+38
-5
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+5
-2
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+0
-2
BrowserTask.java
...va/com/edgec/browserbackend/browser/task/BrowserTask.java
+46
-22
Set3proxyTask.java
.../com/edgec/browserbackend/browser/task/Set3proxyTask.java
+2
-1
ThreadPoolUtils.java
...om/edgec/browserbackend/common/utils/ThreadPoolUtils.java
+3
-3
Trans.java
...ain/java/com/edgec/browserbackend/common/utils/Trans.java
+7
-4
No files found.
src/main/java/com/edgec/browserbackend/account/service/impl/PaymentServiceImpl.java
View file @
17eb5a06
...
@@ -367,8 +367,8 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -367,8 +367,8 @@ public class PaymentServiceImpl implements PaymentService {
Account
byName
=
accountService
.
findByName
(
username
);
Account
byName
=
accountService
.
findByName
(
username
);
if
(
byName
==
null
)
if
(
byName
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
,
"account does not exist: "
+
username
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
,
"account does not exist: "
+
username
);
// if (byName.getPermission() < 8
)
if
(
byName
.
getPermission
()
<
4
)
//
throw new ClientRequestException(AccountErrorCode.NOPERMISSION, "account does not have permission: " + username);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
,
"account does not have permission: "
+
username
);
boolean
isVpsClient
=
true
;
boolean
isVpsClient
=
true
;
UserPayment
internalOrder
=
new
UserPayment
();
UserPayment
internalOrder
=
new
UserPayment
();
...
@@ -421,8 +421,8 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -421,8 +421,8 @@ public class PaymentServiceImpl implements PaymentService {
Account
byName
=
accountService
.
findByName
(
username
);
Account
byName
=
accountService
.
findByName
(
username
);
if
(
byName
==
null
)
if
(
byName
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
,
"account does not exist: "
+
username
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
,
"account does not exist: "
+
username
);
// if (byName.getPermission() < 8
)
if
(
byName
.
getPermission
()
<
4
)
//
throw new ClientRequestException(AccountErrorCode.NOPERMISSION, "account does not have permission: " + username);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
,
"account does not have permission: "
+
username
);
boolean
isVpsClient
=
true
;
boolean
isVpsClient
=
true
;
...
...
src/main/java/com/edgec/browserbackend/browser/domain/IpResource.java
View file @
17eb5a06
...
@@ -37,6 +37,7 @@ public class IpResource implements Serializable {
...
@@ -37,6 +37,7 @@ public class IpResource implements Serializable {
private
double
price
;
private
double
price
;
private
boolean
specialLine
;
//是否使用专线
private
boolean
specialLine
;
//是否使用专线
private
boolean
usingSpecialLine
;
//是否正在使用专线
//专线数据
//专线数据
private
String
proxyUsername
;
//专线的代理用户名
private
String
proxyUsername
;
//专线的代理用户名
private
String
proxyPassword
;
//专线的代理密码
private
String
proxyPassword
;
//专线的代理密码
...
@@ -46,6 +47,7 @@ public class IpResource implements Serializable {
...
@@ -46,6 +47,7 @@ public class IpResource implements Serializable {
private
boolean
isLocked
;
private
boolean
isLocked
;
private
long
lockTimestamp
;
private
long
lockTimestamp
;
private
long
healthLockTimestamp
;
private
String
unit
;
private
String
unit
;
private
int
period
;
private
int
period
;
...
@@ -285,4 +287,19 @@ public class IpResource implements Serializable {
...
@@ -285,4 +287,19 @@ public class IpResource implements Serializable {
this
.
specialLine
=
specialLine
;
this
.
specialLine
=
specialLine
;
}
}
public
long
getHealthLockTimestamp
()
{
return
healthLockTimestamp
;
}
public
void
setHealthLockTimestamp
(
long
healthLockTimestamp
)
{
this
.
healthLockTimestamp
=
healthLockTimestamp
;
}
public
boolean
isUsingSpecialLine
()
{
return
usingSpecialLine
;
}
public
void
setUsingSpecialLine
(
boolean
usingSpecialLine
)
{
this
.
usingSpecialLine
=
usingSpecialLine
;
}
}
}
src/main/java/com/edgec/browserbackend/browser/repository/IpResourceRepositoryCustom.java
View file @
17eb5a06
...
@@ -10,6 +10,10 @@ public interface IpResourceRepositoryCustom {
...
@@ -10,6 +10,10 @@ public interface IpResourceRepositoryCustom {
boolean
unLockTask
(
String
id
);
boolean
unLockTask
(
String
id
);
boolean
healthLock
(
IpResource
ipResource
);
boolean
unLockHealth
(
String
id
);
List
<
IpResource
>
sampleTasks
(
int
status
,
long
timestamp
);
List
<
IpResource
>
sampleTasks
(
int
status
,
long
timestamp
);
List
<
IpResource
>
sampleTasks
(
List
<
Integer
>
status
);
List
<
IpResource
>
sampleTasks
(
List
<
Integer
>
status
);
...
...
src/main/java/com/edgec/browserbackend/browser/repository/IpResourceRepositoryCustomImpl.java
View file @
17eb5a06
...
@@ -34,7 +34,7 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
...
@@ -34,7 +34,7 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
BasicQuery
basicQuery
=
new
BasicQuery
(
doc
);
BasicQuery
basicQuery
=
new
BasicQuery
(
doc
);
Criteria
criteria
=
new
Criteria
();
Criteria
criteria
=
new
Criteria
();
criteria
.
orOperator
(
where
(
"id"
).
is
(
ipResource
.
getId
()).
and
(
"isLocked"
).
is
(
false
).
and
(
"status"
).
is
(
ipResource
.
getStatus
()).
and
(
"isDeleted"
).
is
(
false
),
criteria
.
orOperator
(
where
(
"id"
).
is
(
ipResource
.
getId
()).
and
(
"isLocked"
).
is
(
false
).
and
(
"status"
).
is
(
ipResource
.
getStatus
()).
and
(
"isDeleted"
).
is
(
false
),
where
(
"lockTimestamp"
).
lte
(
Instant
.
now
().
minusSeconds
(
300
).
toEpochMilli
()).
and
(
"status"
).
is
(
ipResource
.
getStatus
())
).
and
(
"isDeleted"
).
is
(
false
);
where
(
"lockTimestamp"
).
lte
(
Instant
.
now
().
minusSeconds
(
300
).
toEpochMilli
()).
and
(
"status"
).
is
(
ipResource
.
getStatus
())
.
and
(
"isDeleted"
).
is
(
false
)
);
basicQuery
.
addCriteria
(
criteria
);
basicQuery
.
addCriteria
(
criteria
);
Update
update
=
new
Update
();
Update
update
=
new
Update
();
update
.
set
(
"isLocked"
,
true
).
set
(
"lockTimestamp"
,
Instant
.
now
().
toEpochMilli
());
update
.
set
(
"isLocked"
,
true
).
set
(
"lockTimestamp"
,
Instant
.
now
().
toEpochMilli
());
...
@@ -61,11 +61,44 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
...
@@ -61,11 +61,44 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
return
true
;
return
true
;
}
}
@Override
public
boolean
healthLock
(
IpResource
ipResource
)
{
Document
doc
=
new
Document
();
BasicQuery
basicQuery
=
new
BasicQuery
(
doc
);
Criteria
criteria
=
new
Criteria
();
criteria
.
orOperator
(
where
(
"id"
).
is
(
ipResource
.
getId
()).
and
(
"isLocked"
).
is
(
false
).
and
(
"status"
).
is
(
ipResource
.
getStatus
()).
and
(
"isDeleted"
).
is
(
false
),
where
(
"healthLockTimestamp"
).
lte
(
Instant
.
now
().
minusSeconds
(
300
).
toEpochMilli
()).
and
(
"status"
).
is
(
ipResource
.
getStatus
()).
and
(
"isDeleted"
).
is
(
false
));
basicQuery
.
addCriteria
(
criteria
);
Update
update
=
new
Update
();
update
.
set
(
"isLocked"
,
true
).
set
(
"healthLockTimestamp"
,
Instant
.
now
().
toEpochMilli
());
UpdateResult
result
=
mongoTemplate
.
updateFirst
(
basicQuery
,
update
,
IpResource
.
class
);
if
(
result
.
getModifiedCount
()
<
1
)
return
false
;
else
return
true
;
}
@Override
public
boolean
unLockHealth
(
String
id
)
{
Document
doc
=
new
Document
();
BasicQuery
basicQuery
=
new
BasicQuery
(
doc
);
basicQuery
.
addCriteria
(
where
(
"id"
).
is
(
id
));
Update
update
=
new
Update
();
update
.
set
(
"isLocked"
,
false
).
set
(
"healthLockTimestamp"
,
Instant
.
now
().
toEpochMilli
());
UpdateResult
result
=
mongoTemplate
.
updateFirst
(
basicQuery
,
update
,
IpResource
.
class
);
if
(
result
.
getModifiedCount
()
<
1
)
return
false
;
else
return
true
;
}
@Override
@Override
public
List
<
IpResource
>
sampleTasks
(
int
status
,
long
timestamp
)
{
public
List
<
IpResource
>
sampleTasks
(
int
status
,
long
timestamp
)
{
Criteria
matchCriteria
=
new
Criteria
();
Criteria
matchCriteria
=
new
Criteria
();
matchCriteria
.
orOperator
(
where
(
"status"
).
is
(
status
).
and
(
"isLocked"
).
is
(
false
).
and
(
"isDeleted"
).
is
(
false
),
matchCriteria
.
orOperator
(
where
(
"status"
).
is
(
status
).
and
(
"isLocked"
).
is
(
false
).
and
(
"isDeleted"
).
is
(
false
),
where
(
"status"
).
is
(
status
).
and
(
"isLocked"
).
is
(
true
).
and
(
"lockTimestamp"
).
lte
(
timestamp
)
).
and
(
"isDeleted"
).
is
(
false
);
where
(
"status"
).
is
(
status
).
and
(
"isLocked"
).
is
(
true
).
and
(
"lockTimestamp"
).
lte
(
timestamp
)
.
and
(
"isDeleted"
).
is
(
false
)
);
MatchOperation
match
=
Aggregation
.
match
(
matchCriteria
);
MatchOperation
match
=
Aggregation
.
match
(
matchCriteria
);
...
@@ -79,12 +112,12 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
...
@@ -79,12 +112,12 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
@Override
@Override
public
List
<
IpResource
>
sampleTasks
(
List
<
Integer
>
status
)
{
public
List
<
IpResource
>
sampleTasks
(
List
<
Integer
>
status
)
{
Criteria
matchCriteria
=
new
Criteria
();
Criteria
matchCriteria
=
new
Criteria
();
matchCriteria
.
orOperator
(
where
(
"status"
).
in
(
status
).
and
(
"isLocked"
).
is
(
false
).
and
(
"isDeleted"
).
is
(
false
).
and
(
"
lockTimestamp"
).
lte
(
Instant
.
now
(
).
toEpochMilli
()),
matchCriteria
.
orOperator
(
where
(
"status"
).
in
(
status
).
and
(
"isLocked"
).
is
(
false
).
and
(
"isDeleted"
).
is
(
false
).
and
(
"
healthLockTimestamp"
).
lte
(
Instant
.
now
().
minusSeconds
(
60
*
30
).
toEpochMilli
()),
where
(
"status"
).
in
(
status
).
and
(
"isLocked"
).
is
(
true
).
and
(
"
lockTimestamp"
).
lte
((
Instant
.
now
().
toEpochMilli
())
-
60
*
1000
*
30
)).
and
(
"isDeleted"
).
is
(
false
);
where
(
"status"
).
in
(
status
).
and
(
"isLocked"
).
is
(
true
).
and
(
"
healthLockTimestamp"
).
lte
(
Instant
.
now
().
minusSeconds
(
300
).
toEpochMilli
()).
and
(
"isDeleted"
).
is
(
false
)
);
MatchOperation
match
=
Aggregation
.
match
(
matchCriteria
);
MatchOperation
match
=
Aggregation
.
match
(
matchCriteria
);
SampleOperation
sample
=
Aggregation
.
sample
(
2
0
);
SampleOperation
sample
=
Aggregation
.
sample
(
10
0
);
AggregationResults
<
IpResource
>
results
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
match
,
sample
),
IpResource
.
class
,
IpResource
.
class
);
AggregationResults
<
IpResource
>
results
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
match
,
sample
),
IpResource
.
class
,
IpResource
.
class
);
List
<
IpResource
>
mappedResults
=
results
.
getMappedResults
();
List
<
IpResource
>
mappedResults
=
results
.
getMappedResults
();
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
17eb5a06
...
@@ -198,7 +198,7 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -198,7 +198,7 @@ public class IpResourceServiceImpl implements IpResourceService {
Account
account
=
accountRepository
.
findByName
(
username
);
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
if
(
account
.
getPermission
()
<
8
)
if
(
account
.
getPermission
()
<
4
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
Map
<
String
,
List
<
String
>>
priceList
=
ipOptionsRepository
.
findAll
().
get
(
0
).
getIpPlatForm
();
Map
<
String
,
List
<
String
>>
priceList
=
ipOptionsRepository
.
findAll
().
get
(
0
).
getIpPlatForm
();
...
@@ -279,7 +279,10 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -279,7 +279,10 @@ public class IpResourceServiceImpl implements IpResourceService {
break
;
break
;
}
}
ipResource
.
setStatus
(
6
);
ipResource
.
setStatus
(
6
);
ipResource
.
setValidTime
(
Instant
.
now
().
plusSeconds
(
3600
*
24
*
30
).
toEpochMilli
());
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
))
ipResource
.
setValidTime
(
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
plusWeeks
(
ipResource
.
getPeriod
()).
toInstant
().
toEpochMilli
());
else
ipResource
.
setValidTime
(
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
plusMonths
(
ipResource
.
getPeriod
()).
toInstant
().
toEpochMilli
());
ipResource
.
setUsername
(
USERNAME
);
ipResource
.
setUsername
(
USERNAME
);
ipResource
.
setPort
(
port
);
ipResource
.
setPort
(
port
);
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
17eb5a06
...
@@ -416,8 +416,6 @@ public class ShopServiceImpl implements ShopService {
...
@@ -416,8 +416,6 @@ public class ShopServiceImpl implements ShopService {
if
(
shops
==
null
||
shops
.
getNumberOfElements
()
<
1
)
if
(
shops
==
null
||
shops
.
getNumberOfElements
()
<
1
)
return
new
ShopPageResultDto
();
return
new
ShopPageResultDto
();
List
<
ShopResultDto
>
shopResultDtos
=
new
ArrayList
<>();
List
<
ShopResultDto
>
shopResultDtos
=
new
ArrayList
<>();
logger
.
error
(
"shops.size"
+
shops
.
getNumberOfElements
());
logger
.
error
(
"shops.content.size "
+
shops
.
getContent
().
size
());
shops
.
getContent
().
stream
().
forEach
(
x
->
{
shops
.
getContent
().
stream
().
forEach
(
x
->
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdAndIsDeleted
(
x
.
getShopId
(),
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdAndIsDeleted
(
x
.
getShopId
(),
false
);
if
(
ipResource
==
null
)
if
(
ipResource
==
null
)
...
...
src/main/java/com/edgec/browserbackend/browser/task/BrowserTask.java
View file @
17eb5a06
...
@@ -219,36 +219,60 @@ public class BrowserTask {
...
@@ -219,36 +219,60 @@ public class BrowserTask {
}
}
}
}
// @Scheduled(cron = "0 0/1
* * * ?")
@Scheduled
(
cron
=
"0 0/5
* * * ?"
)
public
void
healthCheck
()
{
public
void
healthCheck
()
{
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))
?
TESTURL
:
CLOUDAMURL
;
List
<
IpResource
>
ipResources
=
ipResourceRepository
.
sampleTasks
(
Arrays
.
asList
(
0
,
2
));
List
<
IpResource
>
ipResources
=
ipResourceRepository
.
sampleTasks
(
Arrays
.
asList
(
0
,
2
));
for
(
IpResource
ipResource
:
ipResources
)
{
for
(
IpResource
ipResource
:
ipResources
)
{
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
CompletableFuture
.
runAsync
(()
->
{
if
(
ipResourceRepository
.
healthLock
(
ipResource
))
{
if
(
ipResourceRepository
.
lockTask
(
ipResource
))
{
try
{
try
{
QueryIpUrlList
queryIpUrlList
=
queryIpUrlListRepository
.
findAll
().
get
(
0
);
QueryIpUrlList
queryIpUrlList
=
queryIpUrlListRepository
.
findAll
().
get
(
0
);
if
(
ipResource
.
isSpecialLine
())
{
Trans
trans
;
Trans
trans
=
new
Trans
(
ipResource
.
getProxyUsername
(),
ipResource
.
getProxyPassword
());
if
(
ipResource
.
isSpecialLine
())
{
String
sp_result
=
trans
.
get
(
queryIpUrlList
.
getUrl
(),
true
);
trans
=
new
Trans
();
int
failTime
=
0
;
while
(!
sp_result
.
contains
(
ipResource
.
getAddr
()))
{
if
(
failTime
>
5
)
{
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 专线代理异常"
,
NotifyUtils
.
MsgType
.
WEBHOOK
);
log
.
error
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 专线代理异常 "
+
sp_result
);
break
;
}
failTime
++;
Thread
.
sleep
(
2000
);
sp_result
=
trans
.
get
(
queryIpUrlList
.
getUrl
(),
true
);
}
}
}
}
catch
(
Exception
e
)
{
String
result
;
log
.
error
(
e
.
getMessage
(),
e
);
Trans
trans
=
new
Trans
(
ipResource
.
getAddr
(),
Integer
.
valueOf
(
ipResource
.
getPort
().
size
()
>
1
?
ipResource
.
getPort
().
get
(
1
):
ipResource
.
getPort
().
get
(
0
)),
ipResource
.
getUsername
(),
ipResource
.
getPassword
());
}
finally
{
result
=
trans
.
get
(
queryIpUrlList
.
getUrl
(),
false
);
long
end
=
System
.
currentTimeMillis
();
if
(!
result
.
contains
(
ipResource
.
getAddr
()))
{
log
.
debug
(
"queryIpTask {} execution time is: "
+
(
end
-
start
)
/
1000
+
"s"
,
ipResource
.
getId
());
int
failTime
=
0
;
try
{
while
(!
result
.
contains
(
ipResource
.
getAddr
()))
{
ipResourceRepository
.
unLockTask
(
ipResource
.
getId
());
if
(
failTime
>
5
)
{
}
catch
(
Throwable
th
)
{
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 代理异常"
,
NotifyUtils
.
MsgType
.
WEBHOOK
);
log
.
error
(
"unlock failed"
,
th
);
log
.
error
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 代理异常 "
+
result
);
//try again
break
;
ipResourceRepository
.
unLockTask
(
ipResource
.
getId
());
}
failTime
++;
Thread
.
sleep
(
2000
);
result
=
trans
.
get
(
queryIpUrlList
.
getUrl
(),
true
);
}
}
}
}
}
catch
(
Exception
e
)
{
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 代理异常"
,
e
,
NotifyUtils
.
MsgType
.
WEBHOOK
);
log
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
long
end
=
System
.
currentTimeMillis
();
log
.
debug
(
"queryIpTask {} execution time is: "
+
(
end
-
start
)
/
1000
+
"s"
,
ipResource
.
getId
());
try
{
ipResourceRepository
.
unLockHealth
(
ipResource
.
getId
());
}
catch
(
Throwable
th
)
{
log
.
error
(
"unlock failed"
,
th
);
//try again
ipResourceRepository
.
unLockHealth
(
ipResource
.
getId
());
}
}
}
}
,
ThreadPoolUtils
.
queryIpTasksPool
);
}
}
}
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/task/Set3proxyTask.java
View file @
17eb5a06
...
@@ -47,7 +47,6 @@ public class Set3proxyTask {
...
@@ -47,7 +47,6 @@ public class Set3proxyTask {
@Scheduled
(
cron
=
"0 0/10 * * * ?"
)
@Scheduled
(
cron
=
"0 0/10 * * * ?"
)
@SchedulerLock
(
name
=
"proxyTask"
,
lockAtLeastFor
=
60
*
1000
*
5
,
lockAtMostFor
=
60
*
1000
*
9
)
@SchedulerLock
(
name
=
"proxyTask"
,
lockAtLeastFor
=
60
*
1000
*
5
,
lockAtMostFor
=
60
*
1000
*
9
)
public
void
set3proxy
()
{
public
void
set3proxy
()
{
long
validTime
=
Instant
.
now
().
minusSeconds
(
43200
).
toEpochMilli
();
long
nowtime
=
Instant
.
now
().
toEpochMilli
();
long
nowtime
=
Instant
.
now
().
toEpochMilli
();
// List<String> tokenUsernames = mongoOAuth2AccessTokenRepository.findByCreatedAtGreaterThan(validTime).stream().map(MongoOAuth2AccessToken::getUsername).collect(Collectors.toList());
// 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<String> accountParents = accountRepository.findByNameIn(tokenUsernames).stream().map(x -> x.getParent() == null ? x.getName() : x.getParent()).distinct().collect(Collectors.toList());
...
@@ -71,6 +70,7 @@ public class Set3proxyTask {
...
@@ -71,6 +70,7 @@ public class Set3proxyTask {
for
(
IpResource
ipResource
:
ipResources
)
{
for
(
IpResource
ipResource
:
ipResources
)
{
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
bw
.
write
(
"users \""
+
ipResource
.
getProxyUsername
()
+
":CL:"
+
ipResource
.
getProxyPassword
()
+
"\"\n"
);
bw
.
write
(
"users \""
+
ipResource
.
getProxyUsername
()
+
":CL:"
+
ipResource
.
getProxyPassword
()
+
"\"\n"
);
ipResource
.
setUsingSpecialLine
(
true
);
}
}
bw
.
write
(
"\nauth strong\n"
);
bw
.
write
(
"\nauth strong\n"
);
...
@@ -102,6 +102,7 @@ public class Set3proxyTask {
...
@@ -102,6 +102,7 @@ public class Set3proxyTask {
proxyConfigRepository
.
updateProxy
(
file
,
nowtime
);
proxyConfigRepository
.
updateProxy
(
file
,
nowtime
);
file
.
delete
();
file
.
delete
();
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"出错了"
);
log
.
error
(
"出错了"
);
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
...
...
src/main/java/com/edgec/browserbackend/common/utils/ThreadPoolUtils.java
View file @
17eb5a06
...
@@ -38,14 +38,14 @@ public abstract class ThreadPoolUtils {
...
@@ -38,14 +38,14 @@ public abstract class ThreadPoolUtils {
});
});
private
static
final
int
IPTRANSACTION_POOL_COUNT
=
1
0
;
private
static
final
int
IPTRANSACTION_POOL_COUNT
=
2
0
;
public
static
final
ScheduledExecutorService
queryIpTransactionPool
=
Executors
.
newSchedul
edThreadPool
(
IPTRANSACTION_POOL_COUNT
,
new
ThreadFactory
()
{
public
static
final
ExecutorService
queryIpHealth
=
Executors
.
newFix
edThreadPool
(
IPTRANSACTION_POOL_COUNT
,
new
ThreadFactory
()
{
int
count
=
1
;
int
count
=
1
;
@Override
@Override
public
Thread
newThread
(
Runnable
runnable
)
{
public
Thread
newThread
(
Runnable
runnable
)
{
return
new
Thread
(
runnable
,
"browser-ip
Transaction
-task-"
+
count
++);
return
new
Thread
(
runnable
,
"browser-ip
HealthCheck
-task-"
+
count
++);
}
}
});
});
}
}
src/main/java/com/edgec/browserbackend/common/utils/Trans.java
View file @
17eb5a06
...
@@ -34,8 +34,11 @@ public class Trans {
...
@@ -34,8 +34,11 @@ public class Trans {
this
.
username
=
username
;
this
.
username
=
username
;
}
}
public
Trans
()
{
public
Trans
(
String
username
,
String
password
)
{
this
.
host
=
specialHost
;
this
.
port
=
specialPort
;
this
.
password
=
password
;
this
.
username
=
username
;
}
}
/**
/**
...
@@ -88,11 +91,12 @@ public class Trans {
...
@@ -88,11 +91,12 @@ public class Trans {
}
catch
(
ClientProtocolException
e
)
{
}
catch
(
ClientProtocolException
e
)
{
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
host
+
" 代理异常"
,
e
,
NotifyUtils
.
MsgType
.
WEBHOOK
);
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
host
+
" 代理异常"
,
e
,
NotifyUtils
.
MsgType
.
WEBHOOK
);
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
return
""
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
host
+
" 代理异常"
,
e
,
NotifyUtils
.
MsgType
.
WEBHOOK
);
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
host
+
" 代理异常"
,
e
,
NotifyUtils
.
MsgType
.
WEBHOOK
);
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
return
""
;
}
}
System
.
out
.
println
(
sb
.
toString
());
return
sb
.
toString
();
return
sb
.
toString
();
}
}
}
}
\ 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