diff options
author | Christian Pointner <equinox@spreadspace.org> | 2017-07-04 22:51:00 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2017-07-04 22:51:00 +0200 |
commit | 202ed9dbe312aa1051219908cc226b4cfb7a24ef (patch) | |
tree | 31b5f706209dc7f30b8034b84dfcc698ee3444ed /src | |
parent | add missing file frem previous commits (diff) |
srv now uses a config struct it self
Diffstat (limited to 'src')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive-hub/s5hub.go | 5 | ||||
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5srv.go | 12 | ||||
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5srvConf.go | 45 |
3 files changed, 54 insertions, 8 deletions
diff --git a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go index 6411e1e..15b1034 100644 --- a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go +++ b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go @@ -37,8 +37,9 @@ import ( "log" "os" "os/signal" - "spreadspace.org/sfive" "sync" + + "spreadspace.org/sfive" ) var s5hl = log.New(os.Stderr, "[s5hub]\t", log.LstdFlags) @@ -73,7 +74,7 @@ func main() { return } - srv, err := sfive.NewServer(*db, *readOnly, *anonymize, *anonKeyFile, *geoipDB) + srv, err := sfive.NewServer(sfive.SrvConfig{sfive.StoreConfig{*db, *readOnly}, sfive.TransformConfig{*anonymize, *anonKeyFile, *geoipDB}}) if err != nil { s5hl.Fatalf(err.Error()) } diff --git a/src/hub/src/spreadspace.org/sfive/s5srv.go b/src/hub/src/spreadspace.org/sfive/s5srv.go index f6f4bc8..579aec7 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srv.go +++ b/src/hub/src/spreadspace.org/sfive/s5srv.go @@ -147,23 +147,23 @@ func (srv Server) Close() { s5l.Printf("server: finished") } -func NewServer(dbPath string, readOnly, anonymize bool, anonKeyfile, geoipDB string) (srv *Server, err error) { +func NewServer(cfg SrvConfig) (srv *Server, err error) { // TODO: read configuration and create instance with correct settings srv = &Server{} - if srv.store, err = NewStore(StoreConfig{dbPath, readOnly}); err != nil { + if srv.store, err = NewStore(cfg.Store); err != nil { return } - if anonymize { - if srv.anonymization, err = NewCryptopanAnonymization(anonKeyfile); err != nil { + if cfg.Transform.Anonymize { + if srv.anonymization, err = NewCryptopanAnonymization(cfg.Transform.AnonKeyfile); err != nil { err = errors.New("failed to initialize IP address anonymization: " + err.Error()) return } s5l.Printf("using IP address anonymization: %s", srv.anonymization) } - if geoipDB != "" { - if srv.geoip, err = NewMaxMindGeoIP2(geoipDB); err != nil { + if cfg.Transform.GeoipDB != "" { + if srv.geoip, err = NewMaxMindGeoIP2(cfg.Transform.GeoipDB); err != nil { err = errors.New("failed to initialize Geo-IP Lookup: " + err.Error()) return } diff --git a/src/hub/src/spreadspace.org/sfive/s5srvConf.go b/src/hub/src/spreadspace.org/sfive/s5srvConf.go new file mode 100644 index 0000000..7f08a73 --- /dev/null +++ b/src/hub/src/spreadspace.org/sfive/s5srvConf.go @@ -0,0 +1,45 @@ +// +// sfive +// +// sfive - spreadspace streaming statistics suite is a generic +// statistic collection tool for streaming server infrastuctures. +// The system collects and stores meta data like number of views +// and throughput from a number of streaming servers and stores +// it in a global data store. +// The data acquisition is designed to be generic and extensible in +// order to support different streaming software. +// sfive also contains tools and applications to filter and visualize +// live and recorded data. +// +// +// Copyright (C) 2014-2017 Christian Pointner <equinox@spreadspace.org> +// Markus Grüneis <gimpf@gimpf.org> +// +// This file is part of sfive. +// +// sfive is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 3 +// as published by the Free Software Foundation. +// +// sfive is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with sfive. If not, see <http://www.gnu.org/licenses/>. +// + +package sfive + +type TransformConfig struct { + Anonymize bool `json:"anonymize" yaml:"anonymize" toml:"anonymize"` + AnonKeyfile string `json:"anonymization-key" yaml:"anonymization-key" toml:"anonymization-key"` + GeoipDB string `json:"geo-ip-db" yaml:"geo-ip-db" toml:"geo-ip-db"` +} + +type SrvConfig struct { + // ListenAddr string `json:"listen" yaml:"listen" toml:"listen"` + Store StoreConfig `json:"store" yaml:"store" toml:"store"` + Transform TransformConfig `json:"transform" yaml:"transform" toml:"transform"` +} |