I am trying to make a telnet client using the go-telnet library. I am able to connect to the server, but I was expecting to receive some data to login in with user and password.
But I don't get any message. What I could do until now is just send a message to the server and the server prints it.
If I connect using a regular telnet client first thing I have to do is to log in with user and password. I want to replicate this using my own client.
I don't see any examples on GitHub on how to send or receive messages so I am a little confused.
Here is my current code:
func main() {
err = telnet.DialToAndCall("192.168.206.226:23", caller{})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
type caller struct {}
func (c caller) CallTELNET(ctx telnet.Context, w telnet.Writer, r telnet.Reader) {
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
}
Are there any other steps I need to do when connecting? Or am I doing something wrong?
edit (reading part):
//var data []byte
for {
//numBytes, err := conn.Read(data)
reader := bufio.NewReader(os.Stdin)
fmt.Println(reader.ReadString('
'))
}