summaryrefslogtreecommitdiffstats
path: root/model/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/utils.go')
-rw-r--r--model/utils.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/model/utils.go b/model/utils.go
index d24540683..e7d8bfdac 100644
--- a/model/utils.go
+++ b/model/utils.go
@@ -17,6 +17,8 @@ import (
"strings"
"time"
+ "net"
+
goi18n "github.com/nicksnyder/go-i18n/i18n"
"github.com/pborman/uuid"
)
@@ -264,6 +266,23 @@ func StringFromJson(data io.Reader) string {
}
}
+func GetServerIpAddress() string {
+ if addrs, err := net.InterfaceAddrs(); err != nil {
+ return ""
+ } else {
+ for _, addr := range addrs {
+
+ if ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() {
+ if ip.IP.To4() != nil {
+ return ip.IP.String()
+ }
+ }
+ }
+ }
+
+ return ""
+}
+
func IsLower(s string) bool {
if strings.ToLower(s) == s {
return true