reiver / go-telnet

Package telnet provides TELNET and TELNETS client and server implementations, for the Go programming language, in a style similar to the "net/http" library that is part of the Go standard library, including support for "middleware"; TELNETS is secure TELNET, with the TELNET protocol over a secured TLS (or SSL) connection.
https://godoc.org/github.com/reiver/go-telnet
MIT License
266 stars 83 forks source link

Wait for connect to finish sending all data #11

Open thayama opened 5 years ago

thayama commented 5 years ago

Goroutines created in connect, transfer data from a handler to telnet client. However, as there's no synchronization between the goroutine and the telnet server, there's a case where the server sends a prompt before the goroutines finished all transmissions.

This fix assure that the telnet server waits until all data are sent to the client, before sending a prompt.

thayama commented 5 years ago

I've found an issue that the one last byte generated by telsh.Handler is sent after the shell prompt. Currently, there is a race condition between handler.Run() and go func launched in connect().

I've added channels to wait for go funcs launched in connect() to finish their jobs.

mligor commented 3 years ago

My vote for this pull request