func dial(host string, timeout time.Duration) (*telnet.Conn, error) { conn, err := telnet.DialTimeout("tcp", host+":43", timeout) if err != nil { return conn, err } conn.SetUnixWriteMode(true) return conn, nil }
// DialTelnet creates a new telnet connection. func DialTelnet(addr string) (*Telnet, error) { conn, err := gotelnet.DialTimeout("tcp", addr, 5*time.Second) if err != nil { return nil, err } telnet := &Telnet{conn: conn, prompt: "# "} if err := telnet.waitPrompt(); err != nil { return nil, err } return telnet, err }
func (t *TelnetConfig) Connect() (err error) { t.Conn, err = telnet.DialTimeout("tcp", t.IP+":23", t.Timeout) return err }
func NewTelnet() (tn *telnet.Conn, err error) { return telnet.DialTimeout("tcp", tnConfig.Ip+":23", tnConfig.Timeout) }