7 | 7 |
"context"
|
8 | 8 |
"crypto/tls"
|
9 | 9 |
"errors"
|
|
10 |
"fmt"
|
10 | 11 |
"io"
|
11 | 12 |
"net"
|
12 | 13 |
"net/textproto"
|
|
25 | 26 |
EntryTypeLink
|
26 | 27 |
)
|
27 | 28 |
|
|
29 |
// Time format used by the MDTM and MFMT commands
|
|
30 |
const timeFormat = "20060102150405"
|
|
31 |
|
28 | 32 |
// ServerConn represents the connection to a remote FTP server.
|
29 | 33 |
// A single connection only supports one in-flight data connection.
|
30 | 34 |
// It is not safe to be called concurrently.
|
31 | 35 |
type ServerConn struct {
|
32 | 36 |
options *dialOptions
|
33 | |
conn *textproto.Conn
|
|
37 |
conn *textproto.Conn // connection wrapper for text protocol
|
|
38 |
netConn net.Conn // underlying network connection
|
34 | 39 |
host string
|
35 | 40 |
|
36 | 41 |
// Server capabilities discovered at runtime
|
37 | 42 |
features map[string]string
|
38 | 43 |
skipEPSV bool
|
39 | 44 |
mlstSupported bool
|
|
45 |
mfmtSupported bool
|
|
46 |
mdtmSupported bool
|
|
47 |
mdtmCanWrite bool
|
|
48 |
usePRET bool
|
40 | 49 |
}
|
41 | 50 |
|
42 | 51 |
// DialOption represents an option to start a new connection with Dial
|
|
53 | 62 |
conn net.Conn
|
54 | 63 |
disableEPSV bool
|
55 | 64 |
disableUTF8 bool
|
|
65 |
disableMLSD bool
|
|
66 |
writingMDTM bool
|
56 | 67 |
location *time.Location
|
57 | 68 |
debugOutput io.Writer
|
58 | 69 |
dialFunc func(network, address string) (net.Conn, error)
|
|
70 |
shutTimeout time.Duration // time to wait for data connection closing status
|
59 | 71 |
}
|
60 | 72 |
|
61 | 73 |
// Entry describes a file and is returned by List().
|
|
116 | 128 |
options: do,
|
117 | 129 |
features: make(map[string]string),
|
118 | 130 |
conn: textproto.NewConn(do.wrapConn(tconn)),
|
|
131 |
netConn: tconn,
|
119 | 132 |
host: remoteAddr.IP.String(),
|
120 | 133 |
}
|
121 | 134 |
|
122 | 135 |
_, _, err := c.conn.ReadResponse(StatusReady)
|
123 | 136 |
if err != nil {
|
124 | |
c.Quit()
|
|
137 |
_ = c.Quit()
|
125 | 138 |
return nil, err
|
126 | 139 |
}
|
127 | 140 |
|
|
134 | 147 |
c.conn = textproto.NewConn(do.wrapConn(tconn))
|
135 | 148 |
}
|
136 | 149 |
|
137 | |
err = c.feat()
|
138 | |
if err != nil {
|
139 | |
c.Quit()
|
140 | |
return nil, err
|
141 | |
}
|
142 | |
|
143 | |
if _, mlstSupported := c.features["MLST"]; mlstSupported {
|
144 | |
c.mlstSupported = true
|
145 | |
}
|
146 | |
|
147 | 150 |
return c, nil
|
148 | 151 |
}
|
149 | 152 |
|
|
151 | 154 |
func DialWithTimeout(timeout time.Duration) DialOption {
|
152 | 155 |
return DialOption{func(do *dialOptions) {
|
153 | 156 |
do.dialer.Timeout = timeout
|
|
157 |
}}
|
|
158 |
}
|
|
159 |
|
|
160 |
// DialWithShutTimeout returns a DialOption that configures the ServerConn with
|
|
161 |
// maximum time to wait for the data closing status on control connection
|
|
162 |
// and nudging the control connection deadline before reading status.
|
|
163 |
func DialWithShutTimeout(shutTimeout time.Duration) DialOption {
|
|
164 |
return DialOption{func(do *dialOptions) {
|
|
165 |
do.shutTimeout = shutTimeout
|
154 | 166 |
}}
|
155 | 167 |
}
|
156 | 168 |
|
|
180 | 192 |
func DialWithDisabledUTF8(disabled bool) DialOption {
|
181 | 193 |
return DialOption{func(do *dialOptions) {
|
182 | 194 |
do.disableUTF8 = disabled
|
|
195 |
}}
|
|
196 |
}
|
|
197 |
|
|
198 |
// DialWithDisabledMLSD returns a DialOption that configures the ServerConn with MLSD option disabled
|
|
199 |
//
|
|
200 |
// This is useful for servers which advertise MLSD (eg some versions
|
|
201 |
// of Serv-U) but don't support it properly.
|
|
202 |
func DialWithDisabledMLSD(disabled bool) DialOption {
|
|
203 |
return DialOption{func(do *dialOptions) {
|
|
204 |
do.disableMLSD = disabled
|
|
205 |
}}
|
|
206 |
}
|
|
207 |
|
|
208 |
// DialWithWritingMDTM returns a DialOption making ServerConn use MDTM to set file time
|
|
209 |
//
|
|
210 |
// This option addresses a quirk in the VsFtpd server which doesn't support
|
|
211 |
// the MFMT command for setting file time like other servers but by default
|
|
212 |
// uses the MDTM command with non-standard arguments for that.
|
|
213 |
// See "mdtm_write" in https://security.appspot.com/vsftpd/vsftpd_conf.html
|
|
214 |
func DialWithWritingMDTM(enabled bool) DialOption {
|
|
215 |
return DialOption{func(do *dialOptions) {
|
|
216 |
do.writingMDTM = enabled
|
183 | 217 |
}}
|
184 | 218 |
}
|
185 | 219 |
|
|
245 | 279 |
}
|
246 | 280 |
|
247 | 281 |
return newDebugWrapper(netConn, o.debugOutput)
|
|
282 |
}
|
|
283 |
|
|
284 |
func (o *dialOptions) wrapStream(rd io.ReadCloser) io.ReadCloser {
|
|
285 |
if o.debugOutput == nil {
|
|
286 |
return rd
|
|
287 |
}
|
|
288 |
|
|
289 |
return newStreamDebugWrapper(rd, o.debugOutput)
|
248 | 290 |
}
|
249 | 291 |
|
250 | 292 |
// Connect is an alias to Dial, for backward compatibility
|
|
281 | 323 |
return errors.New(message)
|
282 | 324 |
}
|
283 | 325 |
|
|
326 |
// Probe features
|
|
327 |
err = c.feat()
|
|
328 |
if err != nil {
|
|
329 |
return err
|
|
330 |
}
|
|
331 |
if _, mlstSupported := c.features["MLST"]; mlstSupported && !c.options.disableMLSD {
|
|
332 |
c.mlstSupported = true
|
|
333 |
}
|
|
334 |
_, c.usePRET = c.features["PRET"]
|
|
335 |
|
|
336 |
_, c.mfmtSupported = c.features["MFMT"]
|
|
337 |
_, c.mdtmSupported = c.features["MDTM"]
|
|
338 |
c.mdtmCanWrite = c.mdtmSupported && c.options.writingMDTM
|
|
339 |
|
284 | 340 |
// Switch to binary mode
|
285 | 341 |
if _, _, err = c.cmd(StatusCommandOK, "TYPE I"); err != nil {
|
286 | 342 |
return err
|
|
293 | 349 |
|
294 | 350 |
// If using implicit TLS, make data connections also use TLS
|
295 | 351 |
if c.options.tlsConfig != nil {
|
296 | |
c.cmd(StatusCommandOK, "PBSZ 0")
|
297 | |
c.cmd(StatusCommandOK, "PROT P")
|
|
352 |
if _, _, err = c.cmd(StatusCommandOK, "PBSZ 0"); err != nil {
|
|
353 |
return err
|
|
354 |
}
|
|
355 |
if _, _, err = c.cmd(StatusCommandOK, "PROT P"); err != nil {
|
|
356 |
return err
|
|
357 |
}
|
298 | 358 |
}
|
299 | 359 |
|
300 | 360 |
return err
|
|
377 | 437 |
func (c *ServerConn) epsv() (port int, err error) {
|
378 | 438 |
_, line, err := c.cmd(StatusExtendedPassiveMode, "EPSV")
|
379 | 439 |
if err != nil {
|
380 | |
return
|
|
440 |
return 0, err
|
381 | 441 |
}
|
382 | 442 |
|
383 | 443 |
start := strings.Index(line, "|||")
|
384 | 444 |
end := strings.LastIndex(line, "|")
|
385 | 445 |
if start == -1 || end == -1 {
|
386 | |
err = errors.New("invalid EPSV response format")
|
387 | |
return
|
|
446 |
return 0, errors.New("invalid EPSV response format")
|
388 | 447 |
}
|
389 | 448 |
port, err = strconv.Atoi(line[start+3 : end])
|
390 | |
return
|
|
449 |
return port, err
|
391 | 450 |
}
|
392 | 451 |
|
393 | 452 |
// pasv issues a "PASV" command to get a port number for a data connection.
|
394 | 453 |
func (c *ServerConn) pasv() (host string, port int, err error) {
|
395 | 454 |
_, line, err := c.cmd(StatusPassiveMode, "PASV")
|
396 | 455 |
if err != nil {
|
397 | |
return
|
|
456 |
return "", 0, err
|
398 | 457 |
}
|
399 | 458 |
|
400 | 459 |
// PASV response format : 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).
|
401 | 460 |
start := strings.Index(line, "(")
|
402 | 461 |
end := strings.LastIndex(line, ")")
|
403 | 462 |
if start == -1 || end == -1 {
|
404 | |
err = errors.New("invalid PASV response format")
|
405 | |
return
|
|
463 |
return "", 0, errors.New("invalid PASV response format")
|
406 | 464 |
}
|
407 | 465 |
|
408 | 466 |
// We have to split the response string
|
409 | 467 |
pasvData := strings.Split(line[start+1:end], ",")
|
410 | 468 |
|
411 | 469 |
if len(pasvData) < 6 {
|
412 | |
err = errors.New("invalid PASV response format")
|
413 | |
return
|
|
470 |
return "", 0, errors.New("invalid PASV response format")
|
414 | 471 |
}
|
415 | 472 |
|
416 | 473 |
// Let's compute the port number
|
417 | |
portPart1, err1 := strconv.Atoi(pasvData[4])
|
418 | |
if err1 != nil {
|
419 | |
err = err1
|
420 | |
return
|
421 | |
}
|
422 | |
|
423 | |
portPart2, err2 := strconv.Atoi(pasvData[5])
|
424 | |
if err2 != nil {
|
425 | |
err = err2
|
426 | |
return
|
|
474 |
portPart1, err := strconv.Atoi(pasvData[4])
|
|
475 |
if err != nil {
|
|
476 |
return "", 0, err
|
|
477 |
}
|
|
478 |
|
|
479 |
portPart2, err := strconv.Atoi(pasvData[5])
|
|
480 |
if err != nil {
|
|
481 |
return "", 0, err
|
427 | 482 |
}
|
428 | 483 |
|
429 | 484 |
// Recompose port
|
|
431 | 486 |
|
432 | 487 |
// Make the IP address to connect to
|
433 | 488 |
host = strings.Join(pasvData[0:4], ".")
|
434 | |
return
|
|
489 |
return host, port, nil
|
435 | 490 |
}
|
436 | 491 |
|
437 | 492 |
// getDataConnPort returns a host, port for a new data connection
|
|
486 | 541 |
// cmdDataConnFrom executes a command which require a FTP data connection.
|
487 | 542 |
// Issues a REST FTP command to specify the number of bytes to skip for the transfer.
|
488 | 543 |
func (c *ServerConn) cmdDataConnFrom(offset uint64, format string, args ...interface{}) (net.Conn, error) {
|
|
544 |
// If server requires PRET send the PRET command to warm it up
|
|
545 |
// See: https://tools.ietf.org/html/draft-dd-pret-00
|
|
546 |
if c.usePRET {
|
|
547 |
_, _, err := c.cmd(-1, "PRET "+format, args...)
|
|
548 |
if err != nil {
|
|
549 |
return nil, err
|
|
550 |
}
|
|
551 |
}
|
|
552 |
|
489 | 553 |
conn, err := c.openDataConn()
|
490 | 554 |
if err != nil {
|
491 | 555 |
return nil, err
|
492 | 556 |
}
|
493 | 557 |
|
494 | 558 |
if offset != 0 {
|
495 | |
_, _, err := c.cmd(StatusRequestFilePending, "REST %d", offset)
|
|
559 |
_, _, err = c.cmd(StatusRequestFilePending, "REST %d", offset)
|
496 | 560 |
if err != nil {
|
497 | |
conn.Close()
|
|
561 |
_ = conn.Close()
|
498 | 562 |
return nil, err
|
499 | 563 |
}
|
500 | 564 |
}
|
501 | 565 |
|
502 | 566 |
_, err = c.conn.Cmd(format, args...)
|
503 | 567 |
if err != nil {
|
504 | |
conn.Close()
|
|
568 |
_ = conn.Close()
|
505 | 569 |
return nil, err
|
506 | 570 |
}
|
507 | 571 |
|
508 | 572 |
code, msg, err := c.conn.ReadResponse(-1)
|
509 | 573 |
if err != nil {
|
510 | |
conn.Close()
|
|
574 |
_ = conn.Close()
|
511 | 575 |
return nil, err
|
512 | 576 |
}
|
513 | 577 |
if code != StatusAlreadyOpen && code != StatusAboutToSend {
|
514 | |
conn.Close()
|
|
578 |
_ = conn.Close()
|
515 | 579 |
return nil, &textproto.Error{Code: code, Msg: msg}
|
516 | 580 |
}
|
517 | 581 |
|
|
520 | 584 |
|
521 | 585 |
// NameList issues an NLST FTP command.
|
522 | 586 |
func (c *ServerConn) NameList(path string) (entries []string, err error) {
|
523 | |
conn, err := c.cmdDataConnFrom(0, "NLST %s", path)
|
524 | |
if err != nil {
|
525 | |
return
|
|
587 |
space := " "
|
|
588 |
if path == "" {
|
|
589 |
space = ""
|
|
590 |
}
|
|
591 |
conn, err := c.cmdDataConnFrom(0, "NLST%s%s", space, path)
|
|
592 |
if err != nil {
|
|
593 |
return nil, err
|
526 | 594 |
}
|
527 | 595 |
|
528 | 596 |
r := &Response{conn: conn, c: c}
|
529 | |
defer r.Close()
|
530 | |
|
531 | |
scanner := bufio.NewScanner(r)
|
|
597 |
defer func() {
|
|
598 |
errClose := r.Close()
|
|
599 |
if err == nil {
|
|
600 |
err = errClose
|
|
601 |
}
|
|
602 |
}()
|
|
603 |
|
|
604 |
scanner := bufio.NewScanner(c.options.wrapStream(r))
|
532 | 605 |
for scanner.Scan() {
|
533 | 606 |
entries = append(entries, scanner.Text())
|
534 | 607 |
}
|
535 | |
if err = scanner.Err(); err != nil {
|
536 | |
return entries, err
|
537 | |
}
|
538 | |
return
|
|
608 |
|
|
609 |
err = scanner.Err()
|
|
610 |
return entries, err
|
539 | 611 |
}
|
540 | 612 |
|
541 | 613 |
// List issues a LIST FTP command.
|
|
551 | 623 |
parser = parseListLine
|
552 | 624 |
}
|
553 | 625 |
|
554 | |
conn, err := c.cmdDataConnFrom(0, "%s %s", cmd, path)
|
555 | |
if err != nil {
|
556 | |
return
|
|
626 |
space := " "
|
|
627 |
if path == "" {
|
|
628 |
space = ""
|
|
629 |
}
|
|
630 |
conn, err := c.cmdDataConnFrom(0, "%s%s%s", cmd, space, path)
|
|
631 |
if err != nil {
|
|
632 |
return nil, err
|
557 | 633 |
}
|
558 | 634 |
|
559 | 635 |
r := &Response{conn: conn, c: c}
|
560 | |
defer r.Close()
|
561 | |
|
562 | |
scanner := bufio.NewScanner(r)
|
|
636 |
defer func() {
|
|
637 |
errClose := r.Close()
|
|
638 |
if err == nil {
|
|
639 |
err = errClose
|
|
640 |
}
|
|
641 |
}()
|
|
642 |
|
|
643 |
scanner := bufio.NewScanner(c.options.wrapStream(r))
|
563 | 644 |
now := time.Now()
|
564 | 645 |
for scanner.Scan() {
|
565 | |
entry, err := parser(scanner.Text(), now, c.options.location)
|
566 | |
if err == nil {
|
|
646 |
entry, errParse := parser(scanner.Text(), now, c.options.location)
|
|
647 |
if errParse == nil {
|
567 | 648 |
entries = append(entries, entry)
|
568 | 649 |
}
|
569 | 650 |
}
|
570 | |
if err := scanner.Err(); err != nil {
|
571 | |
return nil, err
|
572 | |
}
|
573 | |
return
|
|
651 |
|
|
652 |
err = scanner.Err()
|
|
653 |
return entries, err
|
|
654 |
}
|
|
655 |
|
|
656 |
// IsTimePreciseInList returns true if client and server support the MLSD
|
|
657 |
// command so List can return time with 1-second precision for all files.
|
|
658 |
func (c *ServerConn) IsTimePreciseInList() bool {
|
|
659 |
return c.mlstSupported
|
574 | 660 |
}
|
575 | 661 |
|
576 | 662 |
// ChangeDir issues a CWD FTP command, which changes the current directory to
|
|
616 | 702 |
return strconv.ParseInt(msg, 10, 64)
|
617 | 703 |
}
|
618 | 704 |
|
|
705 |
// GetTime issues the MDTM FTP command to obtain the file modification time.
|
|
706 |
// It returns a UTC time.
|
|
707 |
func (c *ServerConn) GetTime(path string) (time.Time, error) {
|
|
708 |
var t time.Time
|
|
709 |
if !c.mdtmSupported {
|
|
710 |
return t, errors.New("GetTime is not supported")
|
|
711 |
}
|
|
712 |
_, msg, err := c.cmd(StatusFile, "MDTM %s", path)
|
|
713 |
if err != nil {
|
|
714 |
return t, err
|
|
715 |
}
|
|
716 |
return time.ParseInLocation(timeFormat, msg, time.UTC)
|
|
717 |
}
|
|
718 |
|
|
719 |
// IsGetTimeSupported allows library callers to check in advance that they
|
|
720 |
// can use GetTime to get file time.
|
|
721 |
func (c *ServerConn) IsGetTimeSupported() bool {
|
|
722 |
return c.mdtmSupported
|
|
723 |
}
|
|
724 |
|
|
725 |
// SetTime issues the MFMT FTP command to set the file modification time.
|
|
726 |
// Also it can use a non-standard form of the MDTM command supported by
|
|
727 |
// the VsFtpd server instead of MFMT for the same purpose.
|
|
728 |
// See "mdtm_write" in https://security.appspot.com/vsftpd/vsftpd_conf.html
|
|
729 |
func (c *ServerConn) SetTime(path string, t time.Time) (err error) {
|
|
730 |
utime := t.In(time.UTC).Format(timeFormat)
|
|
731 |
switch {
|
|
732 |
case c.mfmtSupported:
|
|
733 |
_, _, err = c.cmd(StatusFile, "MFMT %s %s", utime, path)
|
|
734 |
case c.mdtmCanWrite:
|
|
735 |
_, _, err = c.cmd(StatusFile, "MDTM %s %s", utime, path)
|
|
736 |
default:
|
|
737 |
err = errors.New("SetTime is not supported")
|
|
738 |
}
|
|
739 |
return
|
|
740 |
}
|
|
741 |
|
|
742 |
// IsSetTimeSupported allows library callers to check in advance that they
|
|
743 |
// can use SetTime to set file time.
|
|
744 |
func (c *ServerConn) IsSetTimeSupported() bool {
|
|
745 |
return c.mfmtSupported || c.mdtmCanWrite
|
|
746 |
}
|
|
747 |
|
619 | 748 |
// Retr issues a RETR FTP command to fetch the specified file from the remote
|
620 | 749 |
// FTP server.
|
621 | 750 |
//
|
|
643 | 772 |
// Hint: io.Pipe() can be used if an io.Writer is required.
|
644 | 773 |
func (c *ServerConn) Stor(path string, r io.Reader) error {
|
645 | 774 |
return c.StorFrom(path, r, 0)
|
|
775 |
}
|
|
776 |
|
|
777 |
// checkDataShut reads the "closing data connection" status from the
|
|
778 |
// control connection. It is called after transferring a piece of data
|
|
779 |
// on the data connection during which the control connection was idle.
|
|
780 |
// This may result in the idle timeout triggering on the control connection
|
|
781 |
// right when we try to read the response.
|
|
782 |
// The ShutTimeout dial option will rescue here. It will nudge the control
|
|
783 |
// connection deadline right before checking the data closing status.
|
|
784 |
func (c *ServerConn) checkDataShut() error {
|
|
785 |
if c.options.shutTimeout != 0 {
|
|
786 |
shutDeadline := time.Now().Add(c.options.shutTimeout)
|
|
787 |
if err := c.netConn.SetDeadline(shutDeadline); err != nil {
|
|
788 |
return err
|
|
789 |
}
|
|
790 |
}
|
|
791 |
_, _, err := c.conn.ReadResponse(StatusClosingDataConnection)
|
|
792 |
return err
|
646 | 793 |
}
|
647 | 794 |
|
648 | 795 |
// StorFrom issues a STOR FTP command to store a file to the remote FTP server.
|
|
662 | 809 |
// the response and we cannot use the connection to send other commands.
|
663 | 810 |
// So we don't check io.Copy error and we return the error from
|
664 | 811 |
// ReadResponse so the user can see the real error
|
665 | |
io.Copy(conn, r)
|
666 | |
conn.Close()
|
667 | |
|
668 | |
_, _, err = c.conn.ReadResponse(StatusClosingDataConnection)
|
|
812 |
var n int64
|
|
813 |
n, err = io.Copy(conn, r)
|
|
814 |
|
|
815 |
// If we wrote no bytes but got no error, make sure we call
|
|
816 |
// tls.Handshake on the connection as it won't get called
|
|
817 |
// unless Write() is called.
|
|
818 |
//
|
|
819 |
// ProFTP doesn't like this and returns "Unable to build data
|
|
820 |
// connection: Operation not permitted" when trying to upload
|
|
821 |
// an empty file without this.
|
|
822 |
if n == 0 && err == nil {
|
|
823 |
if do, ok := conn.(interface{ Handshake() error }); ok {
|
|
824 |
err = do.Handshake()
|
|
825 |
}
|
|
826 |
}
|
|
827 |
|
|
828 |
// Use io.Copy or Handshake error in preference to this one
|
|
829 |
closeErr := conn.Close()
|
|
830 |
if err == nil {
|
|
831 |
err = closeErr
|
|
832 |
}
|
|
833 |
|
|
834 |
// Read the response and use this error in preference to
|
|
835 |
// previous errors
|
|
836 |
respErr := c.checkDataShut()
|
|
837 |
if respErr != nil {
|
|
838 |
err = respErr
|
|
839 |
}
|
669 | 840 |
return err
|
670 | 841 |
}
|
671 | 842 |
|
|
681 | 852 |
}
|
682 | 853 |
|
683 | 854 |
// see the comment for StorFrom above
|
684 | |
io.Copy(conn, r)
|
685 | |
conn.Close()
|
686 | |
|
687 | |
_, _, err = c.conn.ReadResponse(StatusClosingDataConnection)
|
|
855 |
_, err = io.Copy(conn, r)
|
|
856 |
errClose := conn.Close()
|
|
857 |
|
|
858 |
respErr := c.checkDataShut()
|
|
859 |
if respErr != nil {
|
|
860 |
err = respErr
|
|
861 |
}
|
|
862 |
|
|
863 |
if err == nil {
|
|
864 |
err = errClose
|
|
865 |
}
|
|
866 |
|
688 | 867 |
return err
|
689 | 868 |
}
|
690 | 869 |
|
|
792 | 971 |
// Quit issues a QUIT FTP command to properly close the connection from the
|
793 | 972 |
// remote FTP server.
|
794 | 973 |
func (c *ServerConn) Quit() error {
|
795 | |
c.conn.Cmd("QUIT")
|
796 | |
return c.conn.Close()
|
|
974 |
_, errQuit := c.conn.Cmd("QUIT")
|
|
975 |
err := c.conn.Close()
|
|
976 |
|
|
977 |
if errQuit != nil {
|
|
978 |
if err != nil {
|
|
979 |
return fmt.Errorf("error while quitting: %s: %w", errQuit, err)
|
|
980 |
}
|
|
981 |
return errQuit
|
|
982 |
}
|
|
983 |
|
|
984 |
return err
|
797 | 985 |
}
|
798 | 986 |
|
799 | 987 |
// Read implements the io.Reader interface on a FTP data connection.
|
|
808 | 996 |
return nil
|
809 | 997 |
}
|
810 | 998 |
err := r.conn.Close()
|
811 | |
_, _, err2 := r.c.conn.ReadResponse(StatusClosingDataConnection)
|
|
999 |
err2 := r.c.checkDataShut()
|
812 | 1000 |
if err2 != nil {
|
813 | 1001 |
err = err2
|
814 | 1002 |
}
|