Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-cloud
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data-hook
gic-cloud
Commits
6b563d69
Commit
6b563d69
authored
Sep 10, 2021
by
陶光胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
取数平台调整
parent
70e937d2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
5 deletions
+30
-5
DataInitUtils.java
...n/java/com/gic/cloud/data/hook/service/DataInitUtils.java
+30
-5
No files found.
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/DataInitUtils.java
View file @
6b563d69
...
@@ -7,7 +7,10 @@ import com.gic.cloud.data.hook.api.dto.DownloadRecord;
...
@@ -7,7 +7,10 @@ import com.gic.cloud.data.hook.api.dto.DownloadRecord;
import
com.gic.cloud.data.hook.service.impl.FlatQueryResultServiceImpl
;
import
com.gic.cloud.data.hook.service.impl.FlatQueryResultServiceImpl
;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.net.SocketException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.List
;
public
class
DataInitUtils
{
public
class
DataInitUtils
{
...
@@ -35,13 +38,35 @@ public class DataInitUtils {
...
@@ -35,13 +38,35 @@ public class DataInitUtils {
}
}
private
static
String
getHost
(){
private
static
String
getHost
(){
try
{
String
localip
=
null
;
// 本地IP,如果没有配置外网IP则返回它
String
hostAddress
=
InetAddress
.
getLocalHost
().
getHostAddress
();
String
netip
=
null
;
// 外网IP
return
hostAddress
;
try
{
}
catch
(
Exception
e
){
Enumeration
netInterfaces
=
NetworkInterface
.
getNetworkInterfaces
();
InetAddress
ip
=
null
;
boolean
finded
=
false
;
// 是否找到外网IP
while
(
netInterfaces
.
hasMoreElements
()
&&
!
finded
)
{
NetworkInterface
ni
=
(
NetworkInterface
)
netInterfaces
.
nextElement
();
Enumeration
address
=
ni
.
getInetAddresses
();
while
(
address
.
hasMoreElements
())
{
ip
=
(
InetAddress
)
address
.
nextElement
();
if
(!
ip
.
isSiteLocalAddress
()
&&
!
ip
.
isLoopbackAddress
()
&&
ip
.
getHostAddress
().
indexOf
(
":"
)
==
-
1
)
{
// 外网IP
netip
=
ip
.
getHostAddress
();
finded
=
true
;
break
;
}
else
if
(
ip
.
isSiteLocalAddress
()
&&
!
ip
.
isLoopbackAddress
()
&&
ip
.
getHostAddress
().
indexOf
(
":"
)
==
-
1
)
{
// 内网IP
localip
=
ip
.
getHostAddress
();
}
}
}
}
catch
(
SocketException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
""
;
if
(
netip
!=
null
&&
!
""
.
equals
(
netip
))
{
return
netip
;
}
else
{
return
localip
;
}
}
}
public
static
void
main
(
String
[]
args
){
public
static
void
main
(
String
[]
args
){
...
...
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