Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log IPs that connect to the telnet server #16

Open
ghost opened this issue Feb 22, 2020 · 0 comments
Open

Log IPs that connect to the telnet server #16

ghost opened this issue Feb 22, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented Feb 22, 2020

What is the best way to log IPs that connect to the telnet server. I've experimented with various ways but have been unable to do it so far. Here's a simple example.

package main

import (
"github.com/reiver/go-telnet"
"log"
)

var RBTHandler telnet.Handler = internalRBTHandler{}

type internalRBTHandler struct{}

func (handler internalRBTHandler) ServeTELNET(ctx telnet.Context, w telnet.Writer, r telnet.Reader) {
// How do I log the remote ip here?
log.Printf("%v\n", ctx)
}

func main() {
var handler telnet.Handler = RBTHandler
//var logger telnet.Logger

server := &telnet.Server{
	Addr:    ":2323",
	Handler: handler,
	//Logger:  logger,
}

err := server.ListenAndServe()
if nil != err {
	panic(err)
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants