Skip to content

Commit

Permalink
Rework IP set
Browse files Browse the repository at this point in the history
  • Loading branch information
sham789 committed Oct 8, 2020
1 parent 5c5d6d4 commit 483c4c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cmd/gravity/commands/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,26 +185,32 @@ var (
},
}
)

func getPublicIP() (string, error) {
ifaces, _ := net.Interfaces()

for _, i := range ifaces {
addrs, _ := i.Addrs()
for _, addr := range addrs {

var ip net.IP
switch v := addr.(type) {
case *net.IPNet:
ip = v.IP
case *net.IPAddr:
if strings.Contains(fmt.Sprintf("%v", v), "/24") {
return fmt.Sprintf("%v", v), nil
}
ip = v.IP
}

if strings.Contains(fmt.Sprintf("%v", addr), "/24") {
return fmt.Sprintf("%v", ip), nil
}

}
}

return "", fmt.Errorf("not found valid ip")
}


func initLedgerConfig(ctx *cli.Context) error {
var err error

Expand Down
Binary file modified cmd/gravity/gravity
Binary file not shown.

0 comments on commit 483c4c1

Please sign in to comment.