-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
81 lines (61 loc) · 2.15 KB
/
commands.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package imap
import (
"crypto/tls"
"fmt"
"strconv"
. "github.com/logrusorgru/aurora"
)
func login(conn *tls.Conn, login string, pass string) []string {
prefix := "a0001"
fmt.Println("Client->", Green(prefix+" login "+login+" ******"))
fmt.Fprintf(conn, prefix+" login "+login+" "+pass+"\n")
return readBeforPrefixLine(conn, prefix)
}
func examineBox(conn *tls.Conn, selectedBox string) []string {
prefix := "a0002"
fmt.Println("Client->", Green(prefix+" examine "+selectedBox))
fmt.Fprintf(conn, "%s examine %s\n", prefix, selectedBox)
return readBeforPrefixLine(conn, prefix)
}
func selectInbox(conn *tls.Conn, selectedBox string) []string {
prefix := "a0003"
fmt.Println("Client->", Green(prefix+" select "+selectedBox))
fmt.Fprintf(conn, "%s select %s\n", prefix, selectedBox)
return readBeforPrefixLine(conn, prefix)
}
func fetchHeader(conn *tls.Conn) []string {
prefix := "a0004"
fmt.Println("Client->", Green(prefix+" fetch 1:* (ENVELOPE UID) "))
fmt.Fprintf(conn, prefix+" fetch 1:* (ENVELOPE UID) \n")
return readBeforPrefixLine(conn, prefix)
}
func searchUnseen(conn *tls.Conn) []string {
prefix := "a0005"
fmt.Println("Client->", Green(prefix+" search unseen"))
fmt.Fprintf(conn, prefix+" search unseen\n")
return readBeforPrefixLine(conn, prefix)
}
func findLetter(conn *tls.Conn, uid string) []string {
prefix := "a0006"
fmt.Println("Client->", Green(prefix+" search UID "+uid))
fmt.Fprintf(conn, "%s search UID %s\n", prefix, uid)
return readBeforPrefixLine(conn, prefix)
}
func fetchLetter(conn *tls.Conn, num int) []string {
prefix := "a0007"
fmt.Println("Client->", Green(prefix+" fetch "+strconv.Itoa(num)+" (body[])"))
fmt.Fprintf(conn, "%s fetch %d (body[]) \n", prefix, num)
return readBeforPrefixLine(conn, prefix)
}
func getListOfBoxes(conn *tls.Conn) []string {
prefix := "a0008"
fmt.Println("Client->", Green(prefix+` LIST "" "%" `))
fmt.Fprintf(conn, "%s LIST \"\" \"%%\" \n", prefix)
return readBeforPrefixLine(conn, prefix)
}
func logout(conn *tls.Conn) []string {
prefix := "a00010"
fmt.Println("Client->", Green(prefix+" logout"))
fmt.Fprintf(conn, prefix+" logout\n")
return readBeforPrefixLine(conn, prefix)
}