-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
39 lines (35 loc) · 688 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"bufio"
"fmt"
"net"
)
type client struct {
conn net.Conn
writer *bufio.Writer
scanner *bufio.Scanner
path []string
login bool
pasv net.Conn
ftype rune
mode rune
input []string
}
func sendMessage(client *client, code int) error {
msg := []byte(fmt.Sprintf("%d %s\r\n", code, codeMap[code]))
_, err := client.writer.Write(msg)
// TODO: best way of handling these errors?
if err != nil {
return err
}
err = client.writer.Flush()
if err != nil {
return err
}
return nil
}
func sendPasv(client *client, address string) {
msg := []byte(fmt.Sprintf("227 %s\r\n", address))
client.writer.Write(msg)
client.writer.Flush()
}