potknocker/common/ftp.go

35 lines
574 B
Go
Raw Permalink Normal View History

2024-08-30 23:51:26 +00:00
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)
}