From 3e72619ad28878c3b3b18ac6b05e97daef847b8c Mon Sep 17 00:00:00 2001 From: Christopher Young Date: Mon, 31 Aug 2015 13:02:20 -0400 Subject: [PATCH] Use Go web server implementation for whole management iface. --- main/gen_gdl90.go | 4 +++- main/managementinterface.go | 3 ++- web/js/stratux.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index bdad778c..f80b48ed 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -16,7 +16,7 @@ import ( const ( stratuxVersion = "v0.2" configLocation = "/etc/stratux.conf" - managementAddr = ":9110" + managementAddr = ":80" maxDatagramSize = 8192 UPLINK_BLOCK_DATA_BITS = 576 UPLINK_BLOCK_BITS = (UPLINK_BLOCK_DATA_BITS + 160) @@ -430,6 +430,8 @@ func saveSettings() { log.Printf("can't save settings %s: %s\n", configLocation, err.Error()) return } + jsonSettings, _ := json.Marshal(&globalSettings) + fd.Write(jsonSettings) log.Printf("wrote settings.\n") } diff --git a/main/managementinterface.go b/main/managementinterface.go index 85cd3210..237c62ec 100644 --- a/main/managementinterface.go +++ b/main/managementinterface.go @@ -62,7 +62,8 @@ func handleManagementConnection(conn *websocket.Conn) { } func managementInterface() { - http.HandleFunc("/", + http.Handle("/", http.FileServer(http.Dir("/var/www"))) + http.HandleFunc("/control", func(w http.ResponseWriter, req *http.Request) { s := websocket.Server{ Handler: websocket.Handler(handleManagementConnection)} diff --git a/web/js/stratux.js b/web/js/stratux.js index 910ae0fb..932c0a04 100644 --- a/web/js/stratux.js +++ b/web/js/stratux.js @@ -24,7 +24,7 @@ function setConnectedClass (cssClass) { } function connect() { - socket = new WebSocket('ws://' + window.location.hostname + ':9110/'); + socket = new WebSocket('ws://' + window.location.hostname + '/control'); socket.onopen = function(msg) { setConnectedClass('label-success');