-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileTransferStructs.go
112 lines (91 loc) · 1.97 KB
/
fileTransferStructs.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package utils
import "github.com/gorilla/websocket"
// FileTransfer
// -------
/*
Receiver pings the server with the IP and port
Server generates a unique connection ID String len = 4
Receiver getsthe ID and the user may share the ID
type FTPayload struct {
name string => receiver | sender
type string => ip, id, metadata
payload interface{}
}
Rec side
type FTPayload struct {
type string => id, metadata
payload interface{}
}
send side
type FTPayload struct {
type string => [ip, port]
payload interface{}
}
// consts for the type of payload
// Metadata from the sender will include the ID
const (
METADATA = "metadata"
IP_PORT = "ip_port"
ID = "id"
)
Rec - [IP, Port]
Serv-Rec - ID
Rec-Send - ID (private)
Send - [ID, Metadata]
Serv-Send - [IP, Port]
Serv-Rec - Metdata
Sender pings the server with the conn ID and the MetaData and receives back the IP and port
Maybe use websockets instead???
w ws
Rec => server Message
type Message struct {
Sender string
Direction string
Config string
Content string
Password string
}
if Sender == "receiver"
*/
// consts for the type of payload
// Metadata from the sender will include the ID
const (
METADATA = "metadata"
RECEIV_URL = "receiverURL"
)
// type FTPayload struct {
// name string => receiver | sender
// type string => ip, id, metadata
// payload interface{}
// }
type FTPayload struct {
SentBy string
Command string
Content interface{}
}
// All of the metadata
// recerverURL, connID, filename, fileByteSize
type FT_MetaData_plusCONN struct {
ReceiverUrl string
ConnID string
Filename string
FileByteSize int64
ReceiverConn *websocket.Conn
SenderConn *websocket.Conn
}
type MetaDataFmt struct {
ConnID string
Filename string
FileByteSize int64
}
type FT_Transfer struct {
ReceiverConn *websocket.Conn
SenderConn *websocket.Conn
ReceiverApproved bool
TransferID string
Filename string
FileByteSize int64
}
var (
FT_Map = make(map[string]*FT_Transfer)
)