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
0983f060
Commit
0983f060
authored
May 06, 2020
by
renjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-zrj' into 'staging'
设置国外服务器为专线 See merge request
!44
parents
b58a73bb
1df4e61c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
6 deletions
+82
-6
AuthenticationFailureEventListener.java
.../service/security/AuthenticationFailureEventListener.java
+1
-1
IpControlloer.java
...dgec/browserbackend/browser/controller/IpControlloer.java
+16
-0
SpecialLine.java
.../com/edgec/browserbackend/browser/domain/SpecialLine.java
+19
-0
IpResourceRepository.java
...owserbackend/browser/repository/IpResourceRepository.java
+2
-0
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+38
-0
IpResourceService.java
...gec/browserbackend/browser/service/IpResourceService.java
+2
-0
Set3proxyTask.java
.../com/edgec/browserbackend/browser/task/Set3proxyTask.java
+4
-5
No files found.
src/main/java/com/edgec/browserbackend/auth/service/security/AuthenticationFailureEventListener.java
View file @
0983f060
...
...
@@ -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 @
0983f060
...
...
@@ -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/SpecialLine.java
View file @
0983f060
...
...
@@ -15,6 +15,9 @@ public class SpecialLine {
private
List
<
String
>
proxyProtocol
;
//专线使用的协议
private
List
<
String
>
proxyPort
;
//专线使用的端口
private
String
username
;
//专线代理服务器用户名
private
String
password
;
//专线代理服务器密码
public
String
getIp
()
{
return
ip
;
}
...
...
@@ -46,4 +49,20 @@ public class SpecialLine {
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/repository/IpResourceRepository.java
View file @
0983f060
...
...
@@ -30,6 +30,8 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
List
<
IpResource
>
findByOwnerInAndSpecialLine
(
List
<
String
>
owners
,
boolean
specialLine
);
List
<
IpResource
>
findByRegionIn
(
List
<
String
>
regions
);
List
<
IpResource
>
findByStatusAndLockedAndLockTimestampLessThan
(
int
status
,
boolean
locked
,
long
timestamp
);
List
<
IpResource
>
findByValidTimeBetweenAndIsDeleted
(
long
beginTime
,
long
endTime
,
boolean
isDeleted
);
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
0983f060
...
...
@@ -722,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/IpResourceService.java
View file @
0983f060
...
...
@@ -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
View file @
0983f060
...
...
@@ -37,14 +37,12 @@ public class Set3proxyTask {
@Autowired
private
SpecialLineRepository
specialLineRepository
;
// @Scheduled(cron = "0 0/1
* * * ?")
@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
());
log
.
error
(
accountParents
.
size
()
+
""
);
List
<
IpResource
>
ipResources
=
ipResourceRepository
.
findByOwnerInAndSpecialLine
(
accountParents
,
true
);
log
.
error
(
ipResources
.
size
()
+
""
);
File
file
=
new
File
(
"3proxy.cfg"
);
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
StringBuilder
stringBuilder
=
new
StringBuilder
();
...
...
@@ -70,8 +68,9 @@ public class Set3proxyTask {
bw
.
flush
();
bw
.
close
();
log
.
info
(
"成功写入文件"
);
// RemoteShellExecutor remoteShellExecutor = new RemoteShellExecutor(specialLine.getIp(), specialLine, "46xiLgy0xrgEaA1");
// remoteShellExecutor
// 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
());
...
...
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