func (self *Server) Listen() { for { conn, err := self.listener.Accept() utils.HandleError(err) fmt.Println("Client connected:", conn.RemoteAddr()) t := telnet.NewTelnet(conn) wc := utils.NewWatchableReadWriter(t) ch := connectionHandler{ conn: &wrappedConnection{Telnet: *t, watcher: wc}, } ch.Handle() } }
func openTelnet() (t *telnet.Telnet, err error) { var conn net.Conn if *useTLS { conn, err = tls.Dial("tcp", *muckHost, &tls.Config{ InsecureSkipVerify: true, }) } else { conn, err = net.Dial("tcp", *muckHost) } if err != nil { return nil, err } return telnet.NewTelnet(conn), nil }