init commit

This commit is contained in:
r0n1n7an 2023-11-04 17:55:35 +08:00
commit 80728aaf77
4 changed files with 82 additions and 0 deletions

BIN
ftpsClient.exe Normal file

Binary file not shown.

75
ftpsClient.go Normal file
View 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
View File

@ -0,0 +1,5 @@
module ftpsClient
go 1.20
require github.com/secsy/goftp v0.0.0-20200609142545-aa2de14babf4

2
go.sum Normal file
View File

@ -0,0 +1,2 @@
github.com/secsy/goftp v0.0.0-20200609142545-aa2de14babf4 h1:PT+ElG/UUFMfqy5HrxJxNzj3QBOf7dZwupeVC+mG1Lo=
github.com/secsy/goftp v0.0.0-20200609142545-aa2de14babf4/go.mod h1:MnkX001NG75g3p8bhFycnyIjeQoOjGL6CEIsdE/nKSY=