summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2017-07-03 14:01:17 +0100
committerKatolaZ <katolaz@freaknet.org>2017-07-03 14:01:17 +0100
commit683e302fa48f613c0489094ce18c486bb231f4ce (patch)
tree733d399c81b167fef8b60b7ee986c8557468fa5f
parent3fa367ce4edeee5f6119235ef0f32a1ab3eb0139 (diff)
Added "-c" option to specify config file
-rw-r--r--binnit.go14
-rw-r--r--config.go4
2 files changed, 15 insertions, 3 deletions
diff --git a/binnit.go b/binnit.go
index 1b11f03..0aaae5b 100644
--- a/binnit.go
+++ b/binnit.go
@@ -33,9 +33,14 @@ import (
"time"
"io"
"binnit/paste"
+ "flag"
)
+var conf_file = flag.String("c", "./binnit.cfg", "Configuration file for binnit")
+
+
+
var p_conf = Config{
server_name: "localhost",
bind_addr: "0.0.0.0",
@@ -147,13 +152,15 @@ func req_handler(w http.ResponseWriter, r *http.Request) {
}
}
+
+
func main() {
-
- parse_config("binnit.cfg", &p_conf)
-
+ flag.Parse()
+ parse_config(*conf_file, &p_conf)
+
f, err := os.OpenFile(p_conf.log_file, os.O_APPEND | os.O_CREATE | os.O_RDWR, 0600)
if err != nil {
fmt.Fprintf(os.Stderr, "Error opening log_file: %s. Exiting\n", p_conf.log_file)
@@ -167,6 +174,7 @@ func main() {
log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds)
log.Println("Binnit version 0.1 -- Starting ")
+ log.Printf(" + Config file: %s\n", *conf_file)
log.Printf(" + Serving pastes on: %s\n", p_conf.server_name)
log.Printf(" + listening on: %s:%s\n", p_conf.bind_addr, p_conf.bind_port )
log.Printf(" + paste_dir: %s\n", p_conf.paste_dir)
diff --git a/config.go b/config.go
index 9967ab8..aa9d966 100644
--- a/config.go
+++ b/config.go
@@ -34,6 +34,10 @@ import (
"strconv"
)
+type Options struct {
+ conf_file string
+}
+
type Config struct {
server_name string