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
22bbad9e
Commit
22bbad9e
authored
May 13, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'staging' into 'master'
Staging See merge request
!96
parents
6ed3ae61
84604b29
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
27 deletions
+29
-27
AuthenticationFailureEventListener.java
.../service/security/AuthenticationFailureEventListener.java
+0
-2
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+1
-0
BrowserTask.java
...va/com/edgec/browserbackend/browser/task/BrowserTask.java
+4
-4
Trans.java
...ain/java/com/edgec/browserbackend/common/utils/Trans.java
+24
-21
No files found.
src/main/java/com/edgec/browserbackend/auth/service/security/AuthenticationFailureEventListener.java
View file @
22bbad9e
...
...
@@ -34,10 +34,8 @@ public class AuthenticationFailureEventListener implements ApplicationListener<A
if
(
user
!=
null
)
{
UserAttemptsLogin
userAttempts
=
userAttemptsLoginRepository
.
findById
(
username
).
orElse
(
null
);
if
(
userAttempts
!=
null
)
{
log
.
error
(
userAttempts
.
getAttempts
()
+
"!!!"
);
if
(
userAttempts
.
getDate
().
getTime
()
>=
(
new
Date
().
getTime
()
-
600000
))
{
int
fails
=
userAttempts
.
getAttempts
();
log
.
error
(
"faile"
+
fails
);
if
(
fails
<
20
)
saveUserAttemptsLogin
(
username
,
fails
+
1
);
else
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
22bbad9e
...
...
@@ -295,6 +295,7 @@ public class IpResourceServiceImpl implements IpResourceService {
ipResource
.
setProxyUsername
(
ipResource
.
getAddr
());
ipResource
.
setProxyPassword
(
genRandom
(
3
,
12
));
ipResource
.
setSpecialLine
(
true
);
ipResource
.
setHealthLockTimestamp
(
Instant
.
now
().
minusSeconds
(
60
*
20
).
toEpochMilli
());
}
ipResource
.
setRegionCn
(
ipResourceRequestDto
.
getRegionCn
());
ipResource
.
setProtocol
(
protocol
);
...
...
src/main/java/com/edgec/browserbackend/browser/task/BrowserTask.java
View file @
22bbad9e
...
...
@@ -229,7 +229,7 @@ public class BrowserTask {
QueryIpUrlList
queryIpUrlList
=
queryIpUrlListRepository
.
findAll
().
get
(
0
);
if
(
ipResource
.
isSpecialLine
())
{
Trans
trans
=
new
Trans
(
ipResource
.
getProxyUsername
(),
ipResource
.
getProxyPassword
());
String
sp_result
=
trans
.
get
(
queryIpUrlList
.
getUrl
()
,
true
);
String
sp_result
=
trans
.
get
(
queryIpUrlList
.
getUrl
());
int
failTime
=
0
;
while
(!
sp_result
.
contains
(
ipResource
.
getAddr
()))
{
if
(
failTime
>
5
)
{
...
...
@@ -239,12 +239,12 @@ public class BrowserTask {
}
failTime
++;
Thread
.
sleep
(
2000
);
sp_result
=
trans
.
get
(
queryIpUrlList
.
getUrl
()
,
true
);
sp_result
=
trans
.
get
(
queryIpUrlList
.
getUrl
());
}
}
String
result
;
Trans
trans
=
new
Trans
(
ipResource
.
getAddr
(),
Integer
.
valueOf
(
ipResource
.
getPort
().
size
()
>
1
?
ipResource
.
getPort
().
get
(
1
):
ipResource
.
getPort
().
get
(
0
)),
ipResource
.
getUsername
(),
ipResource
.
getPassword
());
result
=
trans
.
get
(
queryIpUrlList
.
getUrl
()
,
false
);
result
=
trans
.
get
(
queryIpUrlList
.
getUrl
());
if
(!
result
.
contains
(
ipResource
.
getAddr
()))
{
int
failTime
=
0
;
while
(!
result
.
contains
(
ipResource
.
getAddr
()))
{
...
...
@@ -255,7 +255,7 @@ public class BrowserTask {
}
failTime
++;
Thread
.
sleep
(
2000
);
result
=
trans
.
get
(
queryIpUrlList
.
getUrl
()
,
true
);
result
=
trans
.
get
(
queryIpUrlList
.
getUrl
());
}
}
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/edgec/browserbackend/common/utils/Trans.java
View file @
22bbad9e
...
...
@@ -7,10 +7,12 @@ import org.apache.http.HttpResponse;
import
org.apache.http.auth.AuthScope
;
import
org.apache.http.auth.UsernamePasswordCredentials
;
import
org.apache.http.client.ClientProtocolException
;
import
org.apache.http.client.CredentialsProvider
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.conn.params.ConnRouteParams
;
import
org.apache.http.impl.client.
DefaultHttpClient
;
import
org.apache.http.impl.client.
*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -44,34 +46,37 @@ public class Trans {
/**
* 主入口方法
*
* @param args
*/
public
static
void
main
(
String
[]
args
)
{
String
url
=
"http://pv.sohu.com/cityjson"
;
Trans
trans
=
new
Trans
(
"120.76.135.212"
,
20001
,
"fangguanlianbrowser"
,
"2rbvtg9GQ1JraA1"
);
String
result
=
trans
.
get
(
url
,
false
);
}
public
HttpClient
getHttpClient
()
{
DefaultHttpClient
httpClient
=
new
DefaultHttpClient
();
httpClient
.
getCredentialsProvider
().
setCredentials
(
new
AuthScope
(
host
,
port
),
new
UsernamePasswordCredentials
(
username
,
password
));
HttpHost
proxy
=
new
HttpHost
(
host
,
port
);
httpClient
.
getParams
().
setParameter
(
ConnRouteParams
.
DEFAULT_PROXY
,
proxy
);
return
httpClient
;
}
/**
* 向指定URL发送GET方法的请求
*/
public
String
get
(
String
url
,
boolean
special
)
{
public
String
get
(
String
url
)
{
StringBuffer
sb
=
new
StringBuffer
();
//创建HttpClient实例
HttpClient
client
=
this
.
getHttpClient
();
//创建httpGet
HttpGet
httpGet
=
new
HttpGet
(
"http://pv.sohu.com/cityjson"
);
HttpHost
proxy
=
new
HttpHost
(
host
,
port
);
// 设置认证
CredentialsProvider
provider
=
new
BasicCredentialsProvider
();
provider
.
setCredentials
(
new
AuthScope
(
proxy
),
new
UsernamePasswordCredentials
(
username
,
password
));
//创建httpClient实例
CloseableHttpClient
client
=
HttpClients
.
custom
().
setDefaultCredentialsProvider
(
provider
).
build
();
//创建httpGet实例
HttpGet
httpGet
=
new
HttpGet
(
url
);
//设置代理IP,设置连接超时时间 、 设置 请求读取数据的超时时间 、 设置从connect Manager获取Connection超时时间、
RequestConfig
requestConfig
=
RequestConfig
.
custom
()
.
setProxy
(
proxy
)
.
setConnectTimeout
(
2000
)
.
setSocketTimeout
(
2000
)
.
setConnectionRequestTimeout
(
2000
)
.
build
();
httpGet
.
setConfig
(
requestConfig
);
//执行
try
{
HttpResponse
response
=
client
.
execute
(
httpGet
);
...
...
@@ -87,7 +92,7 @@ public class Trans {
}
br
.
close
();
}
return
sb
.
toString
();
}
catch
(
ClientProtocolException
e
)
{
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
host
+
" 代理异常"
,
e
,
NotifyUtils
.
MsgType
.
WEBHOOK
);
logger
.
error
(
e
.
getMessage
(),
e
);
...
...
@@ -99,6 +104,5 @@ public class Trans {
}
finally
{
httpGet
.
releaseConnection
();
}
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