Skip to content

Commit

Permalink
Add a way to disable binary mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Bowbaq committed Jun 5, 2020
1 parent 9a44114 commit 5c96b61
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ type DialOption struct {

// dialOptions contains all the options set by DialOption.setup
type dialOptions struct {
context context.Context
dialer net.Dialer
tlsConfig *tls.Config
explicitTLS bool
conn net.Conn
disableEPSV bool
location *time.Location
debugOutput io.Writer
dialFunc func(network, address string) (net.Conn, error)
context context.Context
dialer net.Dialer
tlsConfig *tls.Config
explicitTLS bool
conn net.Conn
disableEPSV bool
disableBinaryMode bool
location *time.Location
debugOutput io.Writer
dialFunc func(network, address string) (net.Conn, error)
}

// Entry describes a file and is returned by List().
Expand Down Expand Up @@ -176,6 +177,14 @@ func DialWithDisabledEPSV(disabled bool) DialOption {
}}
}

// DialWithBinaryModeDisabled returns a DialOption that configures the ServerConn without binary mode (TYPE I)
// Binary mode is enabled by default
func DialWithBinaryModeDisabled() DialOption {
return DialOption{func(do *dialOptions) {
do.disableBinaryMode = true
}}
}

// DialWithLocation returns a DialOption that configures the ServerConn with specified time.Location
// The location is used to parse the dates sent by the server which are in server's timezone
func DialWithLocation(location *time.Location) DialOption {
Expand Down

0 comments on commit 5c96b61

Please sign in to comment.