Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion connect.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
package goftp

import (
"crypto/tls"
"bufio"
"log"
"net"
)

// ConnectTLS (FTP over TLS).
func ConnectTLS(addr string, config *tls.Config, debug bool) (*FTP, error) {
var err error
var conn net.Conn

if conn, err = net.Dial("tcp", addr); err != nil {
return nil, err
}
conn = tls.Client(conn, config)

writer := bufio.NewWriter(conn)
reader := bufio.NewReader(conn)

// reader.ReadString('\n')
object := &FTP{conn: conn, addr: addr, reader: reader, writer: writer, tlsconfig: config, debug: debug}
object.receive()

return object, nil
}

// Connect to server at addr (format "host:port"). debug is OFF
func Connect(addr string) (*FTP, error) {
var err error
Expand All @@ -18,7 +39,7 @@ func Connect(addr string) (*FTP, error) {
writer := bufio.NewWriter(conn)
reader := bufio.NewReader(conn)

//reader.ReadString('\n')
// reader.ReadString('\n')
object := &FTP{conn: conn, addr: addr, reader: reader, writer: writer, debug: false}
object.receive()

Expand Down