diff options
author | Christian Pointner <equinox@spreadspace.org> | 2016-03-29 20:25:48 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2016-03-29 20:25:48 (GMT) |
commit | 59f010d9d418992e30fc9c798019a76b9d3df07b (patch) | |
tree | 910047f631f90809cd2e1618c4cbb092165a459d /src/rhctl/telnet.go | |
parent | d3efdc817664bb48a66e9b64c9167c02d0e1304c (diff) |
added telnet control interface
Diffstat (limited to 'src/rhctl/telnet.go')
-rw-r--r-- | src/rhctl/telnet.go | 59 |
1 files changed, 59 insertions, 0 deletions
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 +} |