Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chain33-pai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
szh
chain33-pai
Commits
629a4038
Commit
629a4038
authored
Jul 23, 2020
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
d81a8008
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
13 deletions
+14
-13
broadcast.go
pkg/app/broadcast.go
+8
-8
process.go
pkg/app/process.go
+1
-0
util.go
pkg/util/util.go
+5
-5
No files found.
pkg/app/broadcast.go
View file @
629a4038
...
...
@@ -26,7 +26,7 @@ func Broadcast() {
panic
(
"no serial no"
)
}
}
ip
,
err
:=
GetRightI
p
()
ip
,
err
:=
GetRightI
P
()
if
err
!=
nil
{
panic
(
err
)
}
...
...
@@ -49,7 +49,7 @@ func Broadcast() {
}
for
{
//ip 会变化
ip
,
err
=
GetRightI
p
()
ip
,
err
=
GetRightI
P
()
if
err
!=
nil
{
panic
(
err
)
}
...
...
@@ -86,18 +86,18 @@ func Broadcast() {
}
func
GetRightI
p
()
(
ipv4
*
net
.
IPNet
,
err
error
)
{
func
GetRightI
P
()
(
ipv4
*
net
.
IPNet
,
err
error
)
{
//ip 会变化
ip
,
err
:=
util
.
GetLocalI
p
ByName
(
"wlan0"
)
ip
,
err
:=
util
.
GetLocalI
P
ByName
(
"wlan0"
)
if
err
!=
nil
||
ip
==
nil
{
//tlog.Error("broadcast","wlan0", err)
ip
,
err
=
util
.
GetLocalI
p
ByName
(
"eth0"
)
ip
,
err
=
util
.
GetLocalI
P
ByName
(
"eth0"
)
if
err
!=
nil
{
//tlog.Error("broadcast","eth0", err)
ip
,
err
=
util
.
GetLocalI
p
ByName
(
"wlp3s0"
)
ip
,
err
=
util
.
GetLocalI
P
ByName
(
"wlp3s0"
)
if
err
!=
nil
||
ip
==
nil
{
//tlog.Error("broadcast","wlp3s0", err)
ip
,
err
=
util
.
GetLocalI
p
ByName
(
"enp2s0"
)
ip
,
err
=
util
.
GetLocalI
P
ByName
(
"enp2s0"
)
if
err
!=
nil
{
//tlog.Error("broadcast", "enp2s0",err)
panic
(
err
)
...
...
@@ -115,7 +115,7 @@ func GetRightIps() (ipv4s []*net.IPNet, err error) {
return
nil
,
err
}
for
_
,
i
:=
range
interfaces
{
ip
,
err
:=
util
.
GetLocalI
p
ByName
(
i
.
Name
)
ip
,
err
:=
util
.
GetLocalI
P
ByName
(
i
.
Name
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
pkg/app/process.go
View file @
629a4038
...
...
@@ -637,6 +637,7 @@ func uploadInfo() error {
tlog
.
Error
(
"uploadInfo"
,
"NewRequest do"
,
err
)
return
err
}
defer
resp
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
tlog
.
Error
(
"uploadInfo"
,
"read"
,
err
)
...
...
pkg/util/util.go
View file @
629a4038
...
...
@@ -21,7 +21,7 @@ func GetLocalIP() (ipv4 *net.IPNet, err error) {
addrs
[]
net
.
Addr
addr
net
.
Addr
ipNet
*
net
.
IPNet
// IP地址
isI
p
Net
bool
isI
P
Net
bool
)
// 获取所有网卡
...
...
@@ -31,7 +31,7 @@ func GetLocalIP() (ipv4 *net.IPNet, err error) {
// 取第一个非lo的网卡IP
for
_
,
addr
=
range
addrs
{
// 这个网络地址是IP地址: ipv4, ipv6
if
ipNet
,
isI
pNet
=
addr
.
(
*
net
.
IPNet
);
isIp
Net
&&
!
ipNet
.
IP
.
IsLoopback
()
{
if
ipNet
,
isI
PNet
=
addr
.
(
*
net
.
IPNet
);
isIP
Net
&&
!
ipNet
.
IP
.
IsLoopback
()
{
// 跳过IPV6
if
ipNet
.
IP
.
To4
()
!=
nil
{
ipv4
=
ipNet
// 192.168.1.1
...
...
@@ -44,7 +44,7 @@ func GetLocalIP() (ipv4 *net.IPNet, err error) {
return
}
func
GetLocalI
p
ByName
(
name
string
)
(
ipv4
*
net
.
IPNet
,
err
error
)
{
func
GetLocalI
P
ByName
(
name
string
)
(
ipv4
*
net
.
IPNet
,
err
error
)
{
if
name
==
""
{
return
nil
,
errors
.
New
(
"name not empty"
)
}
...
...
@@ -56,13 +56,13 @@ func GetLocalIpByName(name string) (ipv4 *net.IPNet, err error) {
var
(
addrs
[]
net
.
Addr
ipNet
*
net
.
IPNet
// IP地址
isI
p
Net
bool
isI
P
Net
bool
)
if
addrs
,
err
=
inter
.
Addrs
();
err
!=
nil
{
return
nil
,
err
}
for
_
,
addr
:=
range
addrs
{
if
ipNet
,
isI
pNet
=
addr
.
(
*
net
.
IPNet
);
isIp
Net
&&
!
ipNet
.
IP
.
IsLoopback
()
{
if
ipNet
,
isI
PNet
=
addr
.
(
*
net
.
IPNet
);
isIP
Net
&&
!
ipNet
.
IP
.
IsLoopback
()
{
// 跳过IPV6
if
ipNet
.
IP
.
To4
()
!=
nil
{
ipv4
=
ipNet
// 192.168.1.1
...
...
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