Enable device.Host to be a hostname or IP address

Change-Id: Ice4e1f497d6754e95c5c0c0d6095a9039567150c
diff --git a/handlers.go b/handlers.go
index b82b6fc..d030fa7 100644
--- a/handlers.go
+++ b/handlers.go
@@ -16,6 +16,7 @@
 import (
 	"encoding/json"
 	"fmt"
+	"net"
 	"net/http"
 	"strconv"
 
@@ -83,12 +84,22 @@
 		devID := device.Host + ":" + strconv.Itoa(device.Port)
 		if devID == sadisRequestID {
 			log.Infof("Found OLT device with ID %s", devID)
-			log.Debugf("ID: %s, Uplink: %s, IPAddress: %s, NasID: %s", devID, toInt(device.Uplink), device.Host, device.NasID)
+
+			ipaddr := device.Host
+			addr, err := net.ResolveIPAddr("ip", device.Host)
+			if err != nil {
+				log.Errorf("Resolution error: %s", err.Error())
+				http.Error(w, err.Error(), http.StatusInternalServerError)
+				return
+			} else {
+				ipaddr = addr.String()
+			}
+			log.Debugf("ID: %s, Uplink: %s, IPAddress: %s, NasID: %s", devID, toInt(device.Uplink), ipaddr, device.NasID)
 			sadisDevice := sadisDevice{
 				ID:         devID,
 				Uplink:     toInt(device.Uplink),
 				HardwareID: "de:ad:be:ef:ba:11", // TODO do we really need to configure this?
-				IPAddress:  device.Host,
+				IPAddress:  ipaddr,
 				NasID:      device.NasID,
 			}