aboutsummaryrefslogtreecommitdiff
path: root/weed/util
diff options
context:
space:
mode:
Diffstat (limited to 'weed/util')
-rw-r--r--weed/util/config.go1
-rw-r--r--weed/util/constants.go2
-rw-r--r--weed/util/network.go22
3 files changed, 18 insertions, 7 deletions
diff --git a/weed/util/config.go b/weed/util/config.go
index 6acf21c12..47f433028 100644
--- a/weed/util/config.go
+++ b/weed/util/config.go
@@ -22,6 +22,7 @@ func LoadConfiguration(configFileName string, required bool) (loaded bool) {
viper.SetConfigName(configFileName) // name of config file (without extension)
viper.AddConfigPath(".") // optionally look for config in the working directory
viper.AddConfigPath("$HOME/.seaweedfs") // call multiple times to add many search paths
+ viper.AddConfigPath("/usr/local/etc/seaweedfs/") // search path for bsd-style config directory in
viper.AddConfigPath("/etc/seaweedfs/") // path to look for the config file in
glog.V(1).Infof("Reading %s.toml from %s", configFileName, viper.ConfigFileUsed())
diff --git a/weed/util/constants.go b/weed/util/constants.go
index 254f3cb59..52ba08494 100644
--- a/weed/util/constants.go
+++ b/weed/util/constants.go
@@ -5,7 +5,7 @@ import (
)
var (
- VERSION = fmt.Sprintf("%s %d.%02d", sizeLimit, 2, 13)
+ VERSION = fmt.Sprintf("%s %d.%02d", sizeLimit, 2, 15)
COMMIT = ""
)
diff --git a/weed/util/network.go b/weed/util/network.go
index 7108cfea6..55a123667 100644
--- a/weed/util/network.go
+++ b/weed/util/network.go
@@ -7,16 +7,26 @@ import (
)
func DetectedHostAddress() string {
- addrs, err := net.InterfaceAddrs()
+ netInterfaces, err := net.Interfaces()
if err != nil {
- glog.V(0).Infof("failed to detect ip address: %v", err)
+ glog.V(0).Infof("failed to detect net interfaces: %v", err)
return ""
}
- for _, a := range addrs {
- if ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
- if ipnet.IP.To4() != nil {
- return ipnet.IP.String()
+ for _, netInterface := range netInterfaces {
+ if (netInterface.Flags & net.FlagUp) == 0 {
+ continue
+ }
+ addrs, err := netInterface.Addrs()
+ if err != nil {
+ glog.V(0).Infof("get interface addresses: %v", err)
+ }
+
+ for _, a := range addrs {
+ if ipNet, ok := a.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {
+ if ipNet.IP.To4() != nil {
+ return ipNet.IP.String()
+ }
}
}
}