Create a Configuration struct and use that to RunFrontEnd().
authorRobert Sesek <rsesek@bluestatic.org>
Fri, 12 Nov 2010 13:25:43 +0000 (08:25 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Fri, 12 Nov 2010 13:25:43 +0000 (08:25 -0500)
build.py
src/config.go [new file with mode: 0644]
src/main.go
src/server.go

index b2a3a0a825186a120a9b97436d8187e744dfbcc4..2915eb27772eeaa8afb77bc9fb64108812c7ce06 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -30,6 +30,7 @@ CLOSURE_CALCDEPS = os.path.join(CLOSURE_DEST, 'closure', 'bin', 'calcdeps.py')
 VERSION_FILE = os.path.join(FE_PATH, 'version.js.proto')
 
 SOURCES = [
+  'config.go',
   'paths.go',
   'server.go',
   'main.go'
diff --git a/src/config.go b/src/config.go
new file mode 100644 (file)
index 0000000..f16823f
--- /dev/null
@@ -0,0 +1,17 @@
+//
+// Armadillo File Manager
+// Copyright (c) 2010, Robert Sesek <http://www.bluestatic.org>
+// 
+// This program is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or any later version.
+//
+
+package config
+
+type Configuration struct {
+  JailRoot string
+  Port int
+  ProxyURLs []string
+  Users map [string] string
+}
index 0a836e17e11233d74298932169e52fa64d347d47..be5a1be837d7a6af4e266028a6729c558da6a388 100644 (file)
@@ -12,14 +12,24 @@ package main
 import (
   "flag"
   "fmt"
+  "./config"
   "./paths"
   "./server"
 )
 
 func main() {
+  var configPath *string = flag.String("config", "~/.armadillo", "Path to the configuration file")
+  var config = new(config.Configuration)
+  if len(*configPath) > 0 {
+    // Read configuration.
+  }
   flag.StringVar(&paths.JailRoot, "jail", "/", "Restrict file operations to this directory root")
   var port *int = flag.Int("port", 8080, "Port to run the server on")
   flag.Parse()
+
+  config.JailRoot = paths.JailRoot
+  config.Port = *port
+
   fmt.Printf("Starting Armadillo on port %d with root:\n  %v\n", *port, paths.JailRoot)
-  server.RunFrontEnd(*port)
+  server.RunFrontEnd(config)
 }
index 6a02f3785f849af3bc868fed52f4d8ed924acc8d..33da1ad0cc46f72e95ae77653537d64d6476a9a9 100644 (file)
@@ -17,6 +17,7 @@ import (
   "os"
   "path"
   "strings"
+  "./config"
   "./paths"
 )
 
@@ -99,12 +100,12 @@ func okResponse(connection *http.Conn, data interface{}) {
   }
 }
 
-func RunFrontEnd(port int) {
+func RunFrontEnd(config *config.Configuration) {
   mux := http.NewServeMux()
   mux.HandleFunc("/", indexHandler)
   mux.Handle("/fe/", http.FileServer(kFrontEndFiles, "/fe/"))
   mux.HandleFunc("/service", serviceHandler)
 
-  error := http.ListenAndServe(fmt.Sprintf(":%d", port), mux)
+  error := http.ListenAndServe(fmt.Sprintf(":%d", config.Port), mux)
   fmt.Printf("error %v", error)
 }