Skip to content

Commit

Permalink
resolve name as ip
Browse files Browse the repository at this point in the history
  • Loading branch information
freedomkk-qfeng committed Feb 1, 2021
1 parent 92a9225 commit 5fc57d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ESXi 以设备相关的方式上报数据,设备资产数据会自动注册到
|--|--|
|sn|硬件序列号,如果取不到会使用 uuid 替代|
|endpoint|esxi 的 name,通常是 ip 地址|
|ip|esxi 的 name,通常是 ip 地址,如果检查不是 ip 则留空|
|ip|esxi 的 name,通常是 ip 地址,如果不是 ip 会尝试对 name 做域名解析获取 ip|
|name|esxi 的 name,通常是 ip 地址|
|cate|分类,根据配置决定,默认是 physical|
|tenant|租户,根据配置决定,默认是空|
Expand Down
7 changes: 6 additions & 1 deletion funcs/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"sort"

"net"
"time"

"github.com/toolkits/pkg/net/httplib"
Expand Down Expand Up @@ -60,7 +61,11 @@ func report(esxi mo.HostSystem) error {
if str.IsIP(esxi.Summary.Config.Name) {
ip = esxi.Summary.Config.Name
} else {
ip = ""
addr, err := net.ResolveIPAddr("ip4", esxi.Summary.Config.Name)
if err != nil {
return err
}
ip = addr.String()
}

form := hostRegisterForm{
Expand Down

0 comments on commit 5fc57d6

Please sign in to comment.