Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
fd46b1fe
Commit
fd46b1fe
authored
Dec 06, 2017
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充注释,优化代码
parent
9b3781a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
+13
-4
LockIpv4ServiceImpl.java
...uantgroup/xyqb/service/user/impl/LockIpv4ServiceImpl.java
+11
-2
IPUtil.java
src/main/java/cn/quantgroup/xyqb/util/IPUtil.java
+1
-1
ValidationUtil.java
src/main/java/cn/quantgroup/xyqb/util/ValidationUtil.java
+1
-1
No files found.
src/main/java/cn/quantgroup/xyqb/service/user/impl/LockIpv4ServiceImpl.java
View file @
fd46b1fe
...
...
@@ -5,6 +5,7 @@ import cn.quantgroup.xyqb.Constants;
import
cn.quantgroup.xyqb.exception.PasswordErrorLimitException
;
import
cn.quantgroup.xyqb.service.user.ILockIpv4Service
;
import
cn.quantgroup.xyqb.util.DateUtils
;
import
cn.quantgroup.xyqb.util.IPUtil
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
...
...
@@ -48,13 +49,17 @@ public class LockIpv4ServiceImpl implements ILockIpv4Service {
}
}
/**
* 对白名单之外的所有公有、私有IP执行错误计数
* @param ipv4
*/
@Override
public
void
countErrorByIpv4
(
String
ipv4
)
{
// Todo -- 全天候开放监控
/*if(!ValidationUtil.isAtDangerousTime()){
return;
}*/
if
(
StringUtils
.
isNotBlank
(
ipv4
)
&&
!
ValidationUtil
.
validateLocalIpv4
(
ipv4
))
{
if
(
ValidationUtil
.
validateIpv4
(
ipv4
)
&&
!
IPUtil
.
whiteOf
(
ipv4
))
{
String
ipv4Key
=
getErrorIpKey
(
ipv4
);
if
(!
stringRedisTemplate
.
hasKey
(
ipv4Key
)){
// 计数周期1分钟
...
...
@@ -88,13 +93,17 @@ public class LockIpv4ServiceImpl implements ILockIpv4Service {
LOGGER
.
info
(
"Lock_ipv4: locked error ip access:{}, error overstep {} times in {} minutes, do lock {} minutes"
,
ip
,
counts
,
Constants
.
IPV4_FAILED_COUNT_MINUTES
,
minutes
);
}
/**
* 对白名单之外的所有公有、私有IP执行成功计数
* @param ipv4
*/
@Override
public
void
countSuccessByIpv4
(
String
ipv4
)
{
// Todo -- 全天候开放监控
/*if(!ValidationUtil.isAtDangerousTime()){
return;
}*/
if
(
StringUtils
.
isNotBlank
(
ipv4
)
&&
!
ValidationUtil
.
validateLocalIpv4
(
ipv4
))
{
if
(
ValidationUtil
.
validateIpv4
(
ipv4
)
&&
!
IPUtil
.
whiteOf
(
ipv4
))
{
String
ipv4Key
=
getSuccessIpKey
(
ipv4
);
if
(!
stringRedisTemplate
.
hasKey
(
ipv4Key
)){
// 计数周期1分钟
...
...
src/main/java/cn/quantgroup/xyqb/util/IPUtil.java
View file @
fd46b1fe
...
...
@@ -28,7 +28,7 @@ public class IPUtil {
*/
private
static
final
Set
<
String
>
whiteAddr
=
Sets
.
newHashSet
();
static
{
String
[]
ips
=
{
"1
92.168.3."
,
"192.168.4."
,
"172.16."
,
"172.20."
,
"172.30
."
};
String
[]
ips
=
{
"1
72.16."
,
"172.20."
,
"172.30."
,
"192.168.3."
,
"192.168.4
."
};
whiteAddr
.
addAll
(
Arrays
.
asList
(
ips
));
}
...
...
src/main/java/cn/quantgroup/xyqb/util/ValidationUtil.java
View file @
fd46b1fe
...
...
@@ -18,7 +18,7 @@ public class ValidationUtil {
private
static
String
phoneRegExp
=
"^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\\d{8}$"
;
private
static
String
chineseNameRegExp
=
"^[\u4e00-\u9fa5]+(\\.|·)?[\u4e00-\u9fa5]+$"
;
private
static
String
ipv4RegExp
=
"^((2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)\\.){3}(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)$"
;
private
static
String
localIpv4RegExp
=
"^
172(\\.(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)){3
}$"
;
private
static
String
localIpv4RegExp
=
"^
((172\\.(1[0-6]|2[0-9]|3[01]))|(192\\.168|169\\.254)|((127|10)\\.(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)))(\\.(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)){2
}$"
;
private
static
Pattern
phonePattern
=
Pattern
.
compile
(
phoneRegExp
);
private
static
Pattern
chinesePattern
=
Pattern
.
compile
(
chineseNameRegExp
);
...
...
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