35 lines
574 B
Go
35 lines
574 B
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/jlaffaye/ftp"
|
|
)
|
|
|
|
func connftp(addr string) (*ftp.ServerConn, error) {
|
|
c, err := ftp.Dial(fmt.Sprintf("%s:%d", addr, 21), ftp.DialWithTimeout(400*time.Millisecond))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
err = c.Login("anonymous", "anonymous")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return c, nil
|
|
}
|
|
|
|
func uploadplftp(c *ftp.ServerConn) error {
|
|
fd, err := os.Open(Params.Payload)
|
|
if err != nil {
|
|
warn("error opening local payload file")
|
|
return err
|
|
}
|
|
defer fd.Close()
|
|
|
|
return c.Stor(Params.Payload, fd)
|
|
}
|