fix real IPv4 display
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
807b3be94f
commit
7343cbfa57
|
@ -3,7 +3,6 @@
|
||||||
package linuxstatus
|
package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
|
@ -65,12 +64,6 @@ func (ls *LinuxStatus) setHostShort() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) GetIPv6() []string {
|
|
||||||
if ! me.Ready() {return nil}
|
|
||||||
tmp := me.workingIPv6.Get()
|
|
||||||
return strings.Split(tmp, "\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
func lookupHostname() {
|
func lookupHostname() {
|
||||||
if ! me.Ready() {return}
|
if ! me.Ready() {return}
|
||||||
var err error
|
var err error
|
||||||
|
|
|
@ -270,9 +270,15 @@ func deleteChanges() bool {
|
||||||
return changed
|
return changed
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) GetIPv4() []string {
|
func (ls *LinuxStatus) GetIPv6() []string {
|
||||||
if ! me.Ready() {return nil}
|
if ! me.Ready() {return nil}
|
||||||
tmp := "(none) fixme"
|
tmp := me.workingIPv6.Get()
|
||||||
|
return strings.Split(tmp, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *LinuxStatus) GetIPv4() []string {
|
||||||
|
if ! me.Ready() {return nil}
|
||||||
|
tmp := me.workingIPv4.Get()
|
||||||
return strings.Split(tmp, "\n")
|
return strings.Split(tmp, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
main.go
19
main.go
|
@ -6,8 +6,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"sort"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
"embed"
|
"embed"
|
||||||
|
@ -182,20 +180,3 @@ func timeFunction(f func()) time.Duration {
|
||||||
f() // Execute the function
|
f() // Execute the function
|
||||||
return time.Since(startTime) // Calculate the elapsed time
|
return time.Since(startTime) // Calculate the elapsed time
|
||||||
}
|
}
|
||||||
|
|
||||||
// sortLines takes a string, splits it on newlines, sorts the lines,
|
|
||||||
// and rejoins them with newlines.
|
|
||||||
func sortLines(input string) string {
|
|
||||||
lines := strings.Split(input, "\n")
|
|
||||||
|
|
||||||
// Trim leading and trailing whitespace from each line
|
|
||||||
for i, line := range lines {
|
|
||||||
lines[i] = strings.TrimSpace(line)
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Strings(lines)
|
|
||||||
tmp := strings.Join(lines, "\n")
|
|
||||||
tmp = strings.TrimLeft(tmp, "\n")
|
|
||||||
tmp = strings.TrimRight(tmp, "\n")
|
|
||||||
return tmp
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue