Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈文顺
discovery
Commits
3ffe0b78
Commit
3ffe0b78
authored
Jun 23, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构类结构
parent
d15dc3a3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
discovery-plugin-core/src/main/java/com/nepxion/discovery/plugin/core/strategy/RegisterStrategy.java
+11
-11
No files found.
discovery-plugin-core/src/main/java/com/nepxion/discovery/plugin/core/strategy/RegisterStrategy.java
View file @
3ffe0b78
...
@@ -51,29 +51,29 @@ public class RegisterStrategy {
...
@@ -51,29 +51,29 @@ public class RegisterStrategy {
Map
<
String
,
String
>
filterMap
=
registerEntity
.
getFilterMap
();
Map
<
String
,
String
>
filterMap
=
registerEntity
.
getFilterMap
();
String
filterValue
=
filterMap
.
get
(
serviceId
);
String
filterValue
=
filterMap
.
get
(
serviceId
);
String
allFilter
Value
=
""
;
String
allFilter
IpAddress
=
""
;
if
(
StringUtils
.
isNotEmpty
(
globalFilterValue
))
{
if
(
StringUtils
.
isNotEmpty
(
globalFilterValue
))
{
allFilter
Value
+=
globalFilterValue
;
allFilter
IpAddress
+=
globalFilterValue
;
}
}
if
(
StringUtils
.
isNotEmpty
(
filterValue
))
{
if
(
StringUtils
.
isNotEmpty
(
filterValue
))
{
allFilter
Value
+=
StringUtils
.
isEmpty
(
allFilterValue
)
?
filterValue
:
PluginConstant
.
SEPARATE
+
filterValue
;
allFilter
IpAddress
+=
StringUtils
.
isEmpty
(
allFilterIpAddress
)
?
filterValue
:
PluginConstant
.
SEPARATE
+
filterValue
;
}
}
switch
(
filterType
)
{
switch
(
filterType
)
{
case
BLACKLIST:
case
BLACKLIST:
validateBlacklist
(
allFilter
Value
,
ipAddress
);
validateBlacklist
(
allFilter
IpAddress
,
ipAddress
);
break
;
break
;
case
WHITELIST:
case
WHITELIST:
validateWhitelist
(
allFilter
Value
,
ipAddress
);
validateWhitelist
(
allFilter
IpAddress
,
ipAddress
);
break
;
break
;
}
}
}
}
private
void
validateBlacklist
(
String
filter
Value
,
String
ipAddress
)
{
private
void
validateBlacklist
(
String
filter
IpAddress
,
String
ipAddress
)
{
LOG
.
info
(
"********** IP address blacklist={}, current ip address={} **********"
,
filter
Value
,
ipAddress
);
LOG
.
info
(
"********** IP address blacklist={}, current ip address={} **********"
,
filter
IpAddress
,
ipAddress
);
String
[]
filterArray
=
StringUtils
.
split
(
filter
Value
,
PluginConstant
.
SEPARATE
);
String
[]
filterArray
=
StringUtils
.
split
(
filter
IpAddress
,
PluginConstant
.
SEPARATE
);
for
(
String
filter
:
filterArray
)
{
for
(
String
filter
:
filterArray
)
{
if
(
ipAddress
.
startsWith
(
filter
))
{
if
(
ipAddress
.
startsWith
(
filter
))
{
throw
new
PluginException
(
ipAddress
+
" isn't allowed to register to Eureka server, because it is in blacklist"
);
throw
new
PluginException
(
ipAddress
+
" isn't allowed to register to Eureka server, because it is in blacklist"
);
...
@@ -81,11 +81,11 @@ public class RegisterStrategy {
...
@@ -81,11 +81,11 @@ public class RegisterStrategy {
}
}
}
}
private
void
validateWhitelist
(
String
filter
Value
,
String
ipAddress
)
{
private
void
validateWhitelist
(
String
filter
IpAddress
,
String
ipAddress
)
{
LOG
.
info
(
"********** IP address whitelist={}, current ip address={} **********"
,
filter
Value
,
ipAddress
);
LOG
.
info
(
"********** IP address whitelist={}, current ip address={} **********"
,
filter
IpAddress
,
ipAddress
);
boolean
valid
=
false
;
boolean
valid
=
false
;
String
[]
filterArray
=
StringUtils
.
split
(
filter
Value
,
PluginConstant
.
SEPARATE
);
String
[]
filterArray
=
StringUtils
.
split
(
filter
IpAddress
,
PluginConstant
.
SEPARATE
);
for
(
String
filter
:
filterArray
)
{
for
(
String
filter
:
filterArray
)
{
if
(
ipAddress
.
startsWith
(
filter
))
{
if
(
ipAddress
.
startsWith
(
filter
))
{
valid
=
true
;
valid
=
true
;
...
...
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