init commit
This commit is contained in:
commit
80728aaf77
BIN
ftpsClient.exe
Normal file
BIN
ftpsClient.exe
Normal file
Binary file not shown.
75
ftpsClient.go
Normal file
75
ftpsClient.go
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/secsy/goftp"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
host string = ""
|
||||||
|
port string = ""
|
||||||
|
user string = ""
|
||||||
|
pswd string = ""
|
||||||
|
rmt string = ""
|
||||||
|
loc string = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flag.StringVar(&host, "h", "10.60.254.52", "FTPS Server Address")
|
||||||
|
flag.StringVar(&port, "o", "3031", "FTPS Server Port")
|
||||||
|
flag.StringVar(&user, "u", "idte", "Username")
|
||||||
|
flag.StringVar(&pswd, "p", "wistronTE2022", "Password")
|
||||||
|
flag.StringVar(&loc, "L", "", "Local Path")
|
||||||
|
flag.StringVar(&rmt, "R", "", "Remote Path")
|
||||||
|
flag.Parse()
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
log.SetFlags(log.Ldate | log.Ltime)
|
||||||
|
log.SetOutput(os.Stdout)
|
||||||
|
|
||||||
|
if host == "" || port == "" || user == "" || pswd == "" {
|
||||||
|
log.Println("[ERR] Invalid Arguments.")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg := goftp.Config{
|
||||||
|
User: user,
|
||||||
|
Password: pswd,
|
||||||
|
Timeout: time.Second * 30,
|
||||||
|
TLSMode: goftp.TLSExplicit,
|
||||||
|
TLSConfig: &tls.Config{
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
MinVersion: tls.VersionTLS10,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
client, err := goftp.DialConfig(cfg, host+":"+port)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[ERR] %s\r\n", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
defer client.Close()
|
||||||
|
|
||||||
|
cwd, err := client.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[ERR] %s\r\n", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
log.Printf("[MSG] CWD: %s\r\n", cwd)
|
||||||
|
|
||||||
|
fis, err := client.ReadDir(cwd)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[ERR] %s\r\n", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
for _, f := range fis {
|
||||||
|
fmt.Printf("FileName=%v; FileSize=%v; ModTime=%v; IsDir=%v\r\n", f.Name(), f.Size(), f.ModTime().Format("2006-01-02 15:04:05"), f.IsDir())
|
||||||
|
}
|
||||||
|
}
|
||||||
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module ftpsClient
|
||||||
|
|
||||||
|
go 1.20
|
||||||
|
|
||||||
|
require github.com/secsy/goftp v0.0.0-20200609142545-aa2de14babf4
|
||||||
Loading…
x
Reference in New Issue
Block a user