Some code reorg
This commit is contained in:
@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"golang.org/x/net/route"
|
||||
"net"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var defaultRoute4 = [4]byte{0, 0, 0, 0}
|
||||
@ -103,3 +105,22 @@ func (jh *JailHost) GetDefaultGateway6() string {
|
||||
}
|
||||
return jh.default_gateway6
|
||||
}
|
||||
|
||||
func getHostInUseIPv4() ([]string, error) {
|
||||
var ips []string
|
||||
|
||||
re := regexp.MustCompile(ifconfigipv4re)
|
||||
|
||||
out, err := executeCommand("/sbin/ifconfig")
|
||||
if err != nil {
|
||||
return ips, fmt.Errorf("ERROR executing \"/sbin/ifconfig\": %s", err)
|
||||
}
|
||||
|
||||
for _, line := range strings.Split(out, "\n") {
|
||||
if re.MatchString(line) {
|
||||
ips = append(ips, re.FindStringSubmatch(line)[1])
|
||||
}
|
||||
}
|
||||
|
||||
return ips, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user