summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rhctl/conf.go3
-rw-r--r--src/rhctl/main.go22
-rw-r--r--src/rhctl/telnet.go59
3 files changed, 80 insertions, 4 deletions
diff --git a/src/rhctl/conf.go b/src/rhctl/conf.go
index 47a51b8..e740bde 100644
--- a/src/rhctl/conf.go
+++ b/src/rhctl/conf.go
@@ -53,6 +53,9 @@ type Config struct {
Web struct {
Address string `toml:"addr"`
}
+ Telnet struct {
+ Address string `toml:"addr"`
+ }
}
}
diff --git a/src/rhctl/main.go b/src/rhctl/main.go
index 2aaf7aa..923a287 100644
--- a/src/rhctl/main.go
+++ b/src/rhctl/main.go
@@ -78,6 +78,8 @@ func main() {
rhl.Printf("just started...")
rhdl.Printf("configuration: %+v", conf)
+ //**************************************************
+ // initializing essential parts
sw, err := SwitchInit(conf)
if err != nil {
rhl.Println("error initializing audio switch: ", err)
@@ -93,13 +95,17 @@ func main() {
}
servers = append(servers, server)
}
- if len(servers) <= 0 {
- rhl.Printf("Error: there is no playout server configured...")
- return
- }
+ // if len(servers) <= 0 {
+ // rhl.Printf("Error: there is no playout server configured...")
+ // return
+ // }
ctrl := SwitchControlInit(conf, sw, servers)
+ // running non-essential parts aka clients
+ telnet := TelnetInit(conf, ctrl)
+
+ //**************************************************
// running essential parts
stop := make(chan bool)
@@ -126,6 +132,14 @@ func main() {
stop <- true
}()
+ // running non-essential parts aka clients
+ if conf.Clients.Telnet.Address != "" {
+ rhl.Printf("starting telnet interface")
+ telnet.Run()
+ rhl.Printf("telnet interface just stopped")
+ }
+
+ //**************************************************
<-stop
rhl.Printf("at least one essential part has stopped - bringing down the whole process")
}
diff --git a/src/rhctl/telnet.go b/src/rhctl/telnet.go
new file mode 100644
index 0000000..3cc2b44
--- /dev/null
+++ b/src/rhctl/telnet.go
@@ -0,0 +1,59 @@
+//
+// rhctl
+//
+// Copyright (C) 2009-2016 Christian Pointner <equinox@helsinki.at>
+//
+// This file is part of rhctl.
+//
+// rhctl 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.
+//
+// rhctl 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 rhctl. If not, see <http://www.gnu.org/licenses/>.
+//
+
+package main
+
+import (
+ "github.com/spreadspace/telgo"
+)
+
+type TelnetInterface struct {
+ server *telgo.Server
+}
+
+func status(c *telgo.Client, args []string, ctrl *SwitchControl) bool {
+ // TODO: get status from ctrl
+ c.Sayln("not yet implemented!")
+ return false
+}
+
+func quit(c *telgo.Client, args []string) bool {
+ return true
+}
+
+func (telnet *TelnetInterface) Run() {
+ rhdl.Printf("Telnet: handler running...")
+ if err := telnet.server.Run(); err != nil {
+ rhl.Printf("Telnet: server returned: %s", err)
+ }
+}
+
+func TelnetInit(conf *Config, ctrl *SwitchControl) (telnet *TelnetInterface) {
+ telnet = &TelnetInterface{}
+
+ cmdlist := make(telgo.CmdList)
+ cmdlist["status"] = func(c *telgo.Client, args []string) bool { return status(c, args, ctrl) }
+ cmdlist["quit"] = quit
+
+ telnet.server = telgo.NewServer(conf.Clients.Telnet.Address, "rhctl> ", cmdlist, ctrl)
+
+ return
+}