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
2bc91d1d
Commit
2bc91d1d
authored
Jun 22, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉黑名单配置
parent
ef1a2177
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
29 deletions
+30
-29
discovery-plugin/src/main/java/com/nepxion/discovery/plugin/constant/DiscoveryPluginConstant.java
+0
-1
discovery-plugin/src/main/java/com/nepxion/discovery/plugin/decorator/DiscoveryClientDecorator.java
+5
-0
discovery-plugin/src/main/java/com/nepxion/discovery/plugin/decorator/EurekaServiceRegistryDecorator.java
+7
-10
discovery-springcloud-example-a/src/main/resources/discovery1.xml
+6
-6
discovery-springcloud-example-a/src/main/resources/discovery2.xml
+6
-6
discovery-springcloud-example-a/src/main/resources/discovery3.xml
+6
-6
No files found.
discovery-plugin/src/main/java/com/nepxion/discovery/plugin/constant/DiscoveryPluginConstant.java
View file @
2bc91d1d
...
@@ -10,7 +10,6 @@ package com.nepxion.discovery.plugin.constant;
...
@@ -10,7 +10,6 @@ package com.nepxion.discovery.plugin.constant;
*/
*/
public
class
DiscoveryPluginConstant
{
public
class
DiscoveryPluginConstant
{
public
static
final
String
SPRING_APPLICATION_DISCOVERY_FILTER_ENABLED
=
"spring.application.discovery.filter.enabled"
;
public
static
final
String
SPRING_APPLICATION_DISCOVERY_VERSION_ENABLED
=
"spring.application.discovery.version.enabled"
;
public
static
final
String
SPRING_APPLICATION_DISCOVERY_VERSION_ENABLED
=
"spring.application.discovery.version.enabled"
;
public
static
final
String
SPRING_APPLICATION_DISCOVERY_REMOTE_CONFIG_ENABLED
=
"spring.application.discovery.remote.config.enabled"
;
public
static
final
String
SPRING_APPLICATION_DISCOVERY_REMOTE_CONFIG_ENABLED
=
"spring.application.discovery.remote.config.enabled"
;
...
...
discovery-plugin/src/main/java/com/nepxion/discovery/plugin/decorator/DiscoveryClientDecorator.java
View file @
2bc91d1d
...
@@ -60,4 +60,8 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
...
@@ -60,4 +60,8 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
public
List
<
String
>
getServices
()
{
public
List
<
String
>
getServices
()
{
return
discoveryClient
.
getServices
();
return
discoveryClient
.
getServices
();
}
}
public
ConfigurableEnvironment
getEnvironment
()
{
return
environment
;
}
}
}
\ No newline at end of file
discovery-plugin/src/main/java/com/nepxion/discovery/plugin/decorator/EurekaServiceRegistryDecorator.java
View file @
2bc91d1d
...
@@ -15,7 +15,6 @@ import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceReg
...
@@ -15,7 +15,6 @@ import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceReg
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
com.nepxion.discovery.plugin.constant.DiscoveryPluginConstant
;
import
com.nepxion.discovery.plugin.strategy.FilterStrategy
;
import
com.nepxion.discovery.plugin.strategy.FilterStrategy
;
public
class
EurekaServiceRegistryDecorator
extends
EurekaServiceRegistry
{
public
class
EurekaServiceRegistryDecorator
extends
EurekaServiceRegistry
{
...
@@ -31,20 +30,13 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
...
@@ -31,20 +30,13 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
@Override
@Override
public
void
register
(
EurekaRegistration
registration
)
{
public
void
register
(
EurekaRegistration
registration
)
{
boolean
discoveryFilterEnabled
=
Boolean
.
valueOf
(
environment
.
getProperty
(
DiscoveryPluginConstant
.
SPRING_APPLICATION_DISCOVERY_FILTER_ENABLED
));
if
(
discoveryFilterEnabled
)
{
discoveryFilterEnabled
(
registration
);
}
serviceRegistry
.
register
(
registration
);
}
private
void
discoveryFilterEnabled
(
EurekaRegistration
registration
)
{
String
serviceId
=
registration
.
getServiceId
();
String
serviceId
=
registration
.
getServiceId
();
String
ipAddress
=
registration
.
getInstanceConfig
().
getIpAddress
();
String
ipAddress
=
registration
.
getInstanceConfig
().
getIpAddress
();
FilterStrategy
filterStrategy
=
applicationContext
.
getBean
(
FilterStrategy
.
class
);
FilterStrategy
filterStrategy
=
applicationContext
.
getBean
(
FilterStrategy
.
class
);
filterStrategy
.
apply
(
serviceId
,
ipAddress
);
filterStrategy
.
apply
(
serviceId
,
ipAddress
);
serviceRegistry
.
register
(
registration
);
}
}
@Override
@Override
...
@@ -66,4 +58,8 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
...
@@ -66,4 +58,8 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
public
Object
getStatus
(
EurekaRegistration
registration
)
{
public
Object
getStatus
(
EurekaRegistration
registration
)
{
return
serviceRegistry
.
getStatus
(
registration
);
return
serviceRegistry
.
getStatus
(
registration
);
}
}
public
ConfigurableEnvironment
getEnvironment
()
{
return
environment
;
}
}
}
\ No newline at end of file
discovery-springcloud-example-a/src/main/resources/discovery1.xml
View file @
2bc91d1d
...
@@ -4,12 +4,12 @@
...
@@ -4,12 +4,12 @@
<!-- filter-type,可选值BLACKLIST/WHITELIST,表示白名单或者黑名单 -->
<!-- filter-type,可选值BLACKLIST/WHITELIST,表示白名单或者黑名单 -->
<!-- service-name,表示服务名 -->
<!-- service-name,表示服务名 -->
<!-- filter-value,表示黑/白名单的IP地址列表。IP地址一般用前缀来表示,如果多个用“;”分隔 -->
<!-- filter-value,表示黑/白名单的IP地址列表。IP地址一般用前缀来表示,如果多个用“;”分隔 -->
<!-- 表示下面所有服务,不允许1
92.168和192.168
为前缀的IP地址注册(全局过滤) -->
<!-- 表示下面所有服务,不允许1
0.10和11.11
为前缀的IP地址注册(全局过滤) -->
<filter
filter-type=
"BLACKLIST"
filter-value=
"1
92.168;172.16
"
>
<filter
filter-type=
"BLACKLIST"
filter-value=
"1
0.10;11.11
"
>
<!-- 表示下面服务,不允许1
0.10和192.168和172.16
为前缀的IP地址注册 -->
<!-- 表示下面服务,不允许1
72.16和10.10和11.11
为前缀的IP地址注册 -->
<service
service-name=
"discovery-springcloud-example"
filter-value=
"1
0.10
"
/>
<service
service-name=
"discovery-springcloud-example"
filter-value=
"1
72.16
"
/>
<!-- 表示下面服务,不允许1
1.11和192.168和172.16
为前缀的IP地址注册 -->
<!-- 表示下面服务,不允许1
73.16和10.10和11.11
为前缀的IP地址注册 -->
<service
service-name=
"my-springcloud-example"
filter-value=
"1
1.11
"
/>
<service
service-name=
"my-springcloud-example"
filter-value=
"1
73.16
"
/>
</filter>
</filter>
<!-- 服务注册下,服务多版本调用的控制 -->
<!-- 服务注册下,服务多版本调用的控制 -->
...
...
discovery-springcloud-example-a/src/main/resources/discovery2.xml
View file @
2bc91d1d
...
@@ -4,12 +4,12 @@
...
@@ -4,12 +4,12 @@
<!-- filter-type,可选值BLACKLIST/WHITELIST,表示白名单或者黑名单 -->
<!-- filter-type,可选值BLACKLIST/WHITELIST,表示白名单或者黑名单 -->
<!-- service-name,表示服务名 -->
<!-- service-name,表示服务名 -->
<!-- filter-value,表示黑/白名单的IP地址列表。IP地址一般用前缀来表示,如果多个用“;”分隔 -->
<!-- filter-value,表示黑/白名单的IP地址列表。IP地址一般用前缀来表示,如果多个用“;”分隔 -->
<!-- 表示下面所有服务,不允许1
92.168和192.168
为前缀的IP地址注册(全局过滤) -->
<!-- 表示下面所有服务,不允许1
0.10和11.11
为前缀的IP地址注册(全局过滤) -->
<filter
filter-type=
"BLACKLIST"
filter-value=
"1
92.168;172.16
"
>
<filter
filter-type=
"BLACKLIST"
filter-value=
"1
0.10;11.11
"
>
<!-- 表示下面服务,不允许1
0.10和192.168和172.16
为前缀的IP地址注册 -->
<!-- 表示下面服务,不允许1
72.16和10.10和11.11
为前缀的IP地址注册 -->
<service
service-name=
"discovery-springcloud-example"
filter-value=
"1
0.10
"
/>
<service
service-name=
"discovery-springcloud-example"
filter-value=
"1
72.16
"
/>
<!-- 表示下面服务,不允许1
1.11和192.168和172.16
为前缀的IP地址注册 -->
<!-- 表示下面服务,不允许1
73.16和10.10和11.11
为前缀的IP地址注册 -->
<service
service-name=
"my-springcloud-example"
filter-value=
"1
1.11
"
/>
<service
service-name=
"my-springcloud-example"
filter-value=
"1
73.16
"
/>
</filter>
</filter>
<!-- 服务注册下,服务多版本调用的控制 -->
<!-- 服务注册下,服务多版本调用的控制 -->
...
...
discovery-springcloud-example-a/src/main/resources/discovery3.xml
View file @
2bc91d1d
...
@@ -4,12 +4,12 @@
...
@@ -4,12 +4,12 @@
<!-- filter-type,可选值BLACKLIST/WHITELIST,表示白名单或者黑名单 -->
<!-- filter-type,可选值BLACKLIST/WHITELIST,表示白名单或者黑名单 -->
<!-- service-name,表示服务名 -->
<!-- service-name,表示服务名 -->
<!-- filter-value,表示黑/白名单的IP地址列表。IP地址一般用前缀来表示,如果多个用“;”分隔 -->
<!-- filter-value,表示黑/白名单的IP地址列表。IP地址一般用前缀来表示,如果多个用“;”分隔 -->
<!-- 表示下面所有服务,不允许1
92.168和192.168
为前缀的IP地址注册(全局过滤) -->
<!-- 表示下面所有服务,不允许1
0.10和11.11
为前缀的IP地址注册(全局过滤) -->
<filter
filter-type=
"BLACKLIST"
filter-value=
"1
92.168;172.16
"
>
<filter
filter-type=
"BLACKLIST"
filter-value=
"1
0.10;11.11
"
>
<!-- 表示下面服务,不允许1
0.10和192.168和172.16
为前缀的IP地址注册 -->
<!-- 表示下面服务,不允许1
72.16和10.10和11.11
为前缀的IP地址注册 -->
<service
service-name=
"discovery-springcloud-example"
filter-value=
"1
0.10
"
/>
<service
service-name=
"discovery-springcloud-example"
filter-value=
"1
72.16
"
/>
<!-- 表示下面服务,不允许1
1.11和192.168和172.16
为前缀的IP地址注册 -->
<!-- 表示下面服务,不允许1
73.16和10.10和11.11
为前缀的IP地址注册 -->
<service
service-name=
"my-springcloud-example"
filter-value=
"1
1.11
"
/>
<service
service-name=
"my-springcloud-example"
filter-value=
"1
73.16
"
/>
</filter>
</filter>
<!-- 服务注册下,服务多版本调用的控制 -->
<!-- 服务注册下,服务多版本调用的控制 -->
...
...
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