Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
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
Administrator
apollo
Commits
c5eb3259
Commit
c5eb3259
authored
Feb 23, 2019
by
李卓浩
Committed by
Jason Song
Feb 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化网卡地址优先级 (#1986)
优化网卡地址优先级,index低的网卡地址优先级高
parent
f7ed4f74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
apollo-core/src/main/java/com/ctrip/framework/foundation/internals/NetworkInterfaceManager.java
...amework/foundation/internals/NetworkInterfaceManager.java
+10
-1
No files found.
apollo-core/src/main/java/com/ctrip/framework/foundation/internals/NetworkInterfaceManager.java
View file @
c5eb3259
...
...
@@ -7,6 +7,7 @@ import java.net.SocketException;
import
java.net.UnknownHostException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.Objects
;
...
...
@@ -98,7 +99,15 @@ public enum NetworkInterfaceManager {
try
{
Enumeration
<
NetworkInterface
>
interfaces
=
NetworkInterface
.
getNetworkInterfaces
();
List
<
NetworkInterface
>
nis
=
interfaces
==
null
?
Collections
.<
NetworkInterface
>
emptyList
()
:
Collections
.
list
(
interfaces
);
List
<
NetworkInterface
>
nis
=
interfaces
==
null
?
Collections
.<
NetworkInterface
>
emptyList
()
:
Collections
.
list
(
interfaces
);
//sort the network interfaces according to the index asc
Collections
.
sort
(
nis
,
new
Comparator
<
NetworkInterface
>()
{
@Override
public
int
compare
(
NetworkInterface
nis1
,
NetworkInterface
nis2
)
{
return
Integer
.
compare
(
nis1
.
getIndex
(),
nis2
.
getIndex
());
}
});
List
<
InetAddress
>
addresses
=
new
ArrayList
<>();
InetAddress
local
=
null
;
...
...
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