From bdebcd19be4bee9d0011c86beffc14a3bb70f680 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 31 Dec 2015 22:10:17 +0100 Subject: small change in telgo API diff --git a/src/helsinki.at/rhimportd/ctrlTelnet.go b/src/helsinki.at/rhimportd/ctrlTelnet.go index eac36e9..5cc578e 100644 --- a/src/helsinki.at/rhimportd/ctrlTelnet.go +++ b/src/helsinki.at/rhimportd/ctrlTelnet.go @@ -33,11 +33,11 @@ import ( "strings" ) -func telnetQuit(c *telgo.TelnetClient, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { +func telnetQuit(c *telgo.Client, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { return true } -func telnetHelp(c *telgo.TelnetClient, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { +func telnetHelp(c *telgo.Client, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { switch len(args) { case 2: switch args[1] { @@ -121,7 +121,7 @@ func telnetHelp(c *telgo.TelnetClient, args []string, conf *rhimport.Config, rdd return false } -func telnetSetInt(c *telgo.TelnetClient, param *int, val string) { +func telnetSetInt(c *telgo.Client, param *int, val string) { if vint, err := strconv.ParseInt(val, 10, 32); err != nil { c.Sayln("invalid value (must be an integer)") } else { @@ -129,7 +129,7 @@ func telnetSetInt(c *telgo.TelnetClient, param *int, val string) { } } -func telnetSetUint(c *telgo.TelnetClient, param *uint, val string) { +func telnetSetUint(c *telgo.Client, param *uint, val string) { if vuint, err := strconv.ParseUint(val, 10, 32); err != nil { c.Sayln("invalid value (must be a positive integer)") } else { @@ -137,7 +137,7 @@ func telnetSetUint(c *telgo.TelnetClient, param *uint, val string) { } } -func telnetSetBool(c *telgo.TelnetClient, param *bool, val string) { +func telnetSetBool(c *telgo.Client, param *bool, val string) { if vbool, err := strconv.ParseBool(val); err != nil { c.Sayln("invalid value (must be true or false)") } else { @@ -145,7 +145,7 @@ func telnetSetBool(c *telgo.TelnetClient, param *bool, val string) { } } -func telnetSet(c *telgo.TelnetClient, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { +func telnetSet(c *telgo.Client, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { if len(args) != 3 { c.Sayln("wrong number of arguments") return false @@ -192,7 +192,7 @@ func telnetSet(c *telgo.TelnetClient, args []string, conf *rhimport.Config, rddb return false } -func telnetReset(c *telgo.TelnetClient, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { +func telnetReset(c *telgo.Client, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { if len(args) > 1 { c.Sayln("too many arguments") return false @@ -202,7 +202,7 @@ func telnetReset(c *telgo.TelnetClient, args []string, conf *rhimport.Config, rd return false } -func telnetShow(c *telgo.TelnetClient, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { +func telnetShow(c *telgo.Client, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { if len(args) > 1 { c.Sayln("too many arguments") return false @@ -230,12 +230,12 @@ func telnetShow(c *telgo.TelnetClient, args []string, conf *rhimport.Config, rdd } func telnetProgressCallback(step int, stepName string, progress float64, userdata interface{}) bool { - c := userdata.(*telgo.TelnetClient) + c := userdata.(*telgo.Client) c.Say("%s: %3.2f%%\r", stepName, progress*100) return true } -func telnetRun(c *telgo.TelnetClient, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { +func telnetRun(c *telgo.Client, args []string, conf *rhimport.Config, rddb *rhimport.RdDbChan) bool { if c.UserData == nil { c.Sayln("context is empty please set at least one option") return false @@ -277,15 +277,15 @@ func telnetRun(c *telgo.TelnetClient, args []string, conf *rhimport.Config, rddb func StartControlTelnet(addr string, conf *rhimport.Config, rddb *rhimport.RdDbChan, sessions *rhimport.SessionStoreChan) { cmdlist := make(telgo.CmdList) - cmdlist["quit"] = func(c *telgo.TelnetClient, args []string) bool { return telnetQuit(c, args, conf, rddb) } - cmdlist["help"] = func(c *telgo.TelnetClient, args []string) bool { return telnetHelp(c, args, conf, rddb) } - cmdlist["set"] = func(c *telgo.TelnetClient, args []string) bool { return telnetSet(c, args, conf, rddb) } - cmdlist["reset"] = func(c *telgo.TelnetClient, args []string) bool { return telnetReset(c, args, conf, rddb) } - cmdlist["show"] = func(c *telgo.TelnetClient, args []string) bool { return telnetShow(c, args, conf, rddb) } - cmdlist["run"] = func(c *telgo.TelnetClient, args []string) bool { return telnetRun(c, args, conf, rddb) } + cmdlist["quit"] = func(c *telgo.Client, args []string) bool { return telnetQuit(c, args, conf, rddb) } + cmdlist["help"] = func(c *telgo.Client, args []string) bool { return telnetHelp(c, args, conf, rddb) } + cmdlist["set"] = func(c *telgo.Client, args []string) bool { return telnetSet(c, args, conf, rddb) } + cmdlist["reset"] = func(c *telgo.Client, args []string) bool { return telnetReset(c, args, conf, rddb) } + cmdlist["show"] = func(c *telgo.Client, args []string) bool { return telnetShow(c, args, conf, rddb) } + cmdlist["run"] = func(c *telgo.Client, args []string) bool { return telnetRun(c, args, conf, rddb) } rhl.Println("telnet-ctrl: listening on", addr) - s := telgo.NewTelnetServer(addr, "rhimportd> ", cmdlist, nil) + s := telgo.NewServer(addr, "rhimportd> ", cmdlist, nil) if err := s.Run(); err != nil { fmt.Printf("telnet server returned: %s", err) } -- cgit v0.10.2