summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorus_arch2015-03-30 00:04:46 +0200
committerhorus_arch2015-03-30 00:04:46 +0200
commit4fc5294bf43583f3b42768a07c13f40913f92623 (patch)
tree5d3a4388d88fbd4a776c2ba656e4203540725713
parent37b6995afa83fcf32dfd24be406112491c8d6451 (diff)
downloadfreemail-4fc5294bf43583f3b42768a07c13f40913f92623.tar.gz
Add vagrant target to Makefile for better use in build pipeline.
-rw-r--r--Makefile30
-rw-r--r--utilities.go6
2 files changed, 35 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 7a1be85..ea6cb20 100644
--- a/Makefile
+++ b/Makefile
@@ -33,6 +33,11 @@ else
FREEMAIL_DB_DIR:=
endif
+ifndef VAGRANT_DIR
+ VAGRANT_DIR:=/vagrant
+endif
+
+
# Start targets
all: kill build run
@@ -132,3 +137,28 @@ gen_config: _test_build
@chmod +x _env.sh
restart: kill build run
+
+go_get:
+ go get github.com/jinzhu/gorm
+ go get github.com/mattn/go-sqlite3
+ go get github.com/gorilla/mux
+ go get github.com/gorilla/schema
+ go get github.com/gorilla/sessions
+
+_test_archiv:
+ @if [ ! -f ./$(APP).tar.gz ] || [ ! -x ./$(APP).tar.gz ]; then \
+ echo "No archive found." 1>&2; \
+ echo "Run \"make pack\" first." 1>&2; \
+ echo ""; \
+ exit 1; \
+ fi
+
+_test_vagrant_env:
+ @if [ ! -d $(VAGRANT_DIR) ]; then \
+ echo "Directory $(VAGRANT_DIR) not found."; \
+ echo ""; \
+ exit 1; \
+ fi
+
+vagrant: _test_archiv _test_vagrant_env
+ mv $(APP).tar.gz $(VAGRANT_DIR)
diff --git a/utilities.go b/utilities.go
index 3ce3e1d..602d4fe 100644
--- a/utilities.go
+++ b/utilities.go
@@ -63,7 +63,11 @@ func GetIP(r *http.Request) string {
return r.Header["X-Real-Ip"][0]
}
if r.RemoteAddr != "" {
- ip, _, _ := net.SplitHostPort(r.RemoteAddr)
+ ip, _, err := net.SplitHostPort(r.RemoteAddr)
+ if err != nil {
+ log.Println("Info: ", err)
+ return "0.0.0.0"
+ }
return ip
}
log.Println("Info: No remote IP detectable.")