// // rhctl // // Copyright (C) 2009-2016 Christian Pointner // // 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 . // 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 }