-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcolonio.proto
281 lines (235 loc) · 5.04 KB
/
colonio.proto
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
syntax = "proto3";
option go_package = "github.com/llamerada-jp/colonio/internal/proto";
package colonio.proto;
// basic types
message Coordinate {
double x = 1;
double y = 2;
}
message NodeID {
uint32 type = 1;
uint64 id0 = 2;
uint64 id1 = 3;
}
// node-node packet container
// Or use an empty message as a ping to cancel the timeout.
message NodePackets { repeated NodePacket packets = 1; }
message NodePacketHead {
NodeID dst_node_id = 1;
NodeID src_node_id = 2;
uint32 hop_count = 3;
uint32 mode = 4;
}
message NodePacket {
// Enable head if index is 0.
NodePacketHead head = 1;
// ID is common to sequence of packets.
uint32 id = 2;
// index decreases by 1 in a sequence of packets.
uint32 index = 3;
bytes content = 4;
}
//
message PacketContent {
oneof Content {
Error error = 1;
SignalingICE signaling_ice = 5;
SignalingOffer signaling_offer = 6;
SignalingOfferSuccess signaling_offer_success = 7;
SignalingOfferFailure signaling_offer_failure = 8;
Routing routing = 10;
Messaging messaging = 20;
MessagingResponse messaging_response = 21;
KvsAccept kvs_accept = 30;
KvsAcceptResponse kvs_accept_response = 31;
KvsBalanceAcceptor kvs_balance_acceptor = 32;
KvsBalanceProposer kvs_balance_proposer = 33;
KvsGet kvs_get = 34;
KvsGetResponse kvs_get_response = 35;
KvsHint kvs_hint = 36;
KvsPrepare kvs_prepare = 37;
KvsPrepareResponse kvs_prepare_response = 38;
KvsSet kvs_set = 39;
KvsSetResponse kvs_set_response = 40;
Spread spread = 50;
SpreadKnock spread_knock = 51;
SpreadKnockResponse spread_knock_response = 52;
SpreadRelay spread_relay = 53;
SpreadRelayResponse spread_relay_response = 54;
}
}
message Error {
uint32 code = 1;
string message = 2;
}
// for node-seed authenticate and hints
message SeedAuthenticate {
string version = 1;
NodeID node_id = 2;
bytes token = 3;
}
message SeedAuthenticateResponse {
uint32 hint = 1;
bytes config = 2;
string session_id = 3;
}
message SeedClose { string session_id = 1; }
message SeedPacket {
NodeID dst_node_id = 1;
NodeID src_node_id = 2;
uint32 hop_count = 3;
uint32 id = 4;
uint32 mode = 5;
PacketContent content = 6;
}
message SeedRelay {
string session_id = 1;
repeated SeedPacket packets = 2;
}
message SeedRelayResponse { uint32 hint = 1; }
message SeedPoll {
string session_id = 1;
bool online = 2;
}
message SeedPollResponse {
uint32 hint = 1;
string session_id = 2;
repeated SeedPacket packets = 3;
}
// for webrtc signaling
message SignalingICE {
NodeID local_node_id = 1;
NodeID remote_node_id = 2;
repeated string ices = 3;
}
message SignalingOffer {
NodeID prime_node_id = 1;
NodeID second_node_id = 2;
string sdp = 3;
uint32 type = 4;
}
message SignalingOfferSuccess {
uint32 status = 1;
NodeID second_node_id = 2;
string sdp = 3;
}
message SignalingOfferFailure {
uint32 status = 1;
NodeID prime_node_id = 2;
}
// for routing
message RoutingNodeRecord {
int64 r1d_score = 1;
Coordinate r2d_position = 2;
}
message Routing {
uint32 seed_distance = 1;
Coordinate r2d_position = 2;
// Key type of map is string from node-id.
map<string, RoutingNodeRecord> node_records = 3;
}
// for messaging module
message Messaging {
string name = 1;
bytes message = 2;
}
message MessagingResponse {
bytes response = 1;
}
// for kvs module
message KvsAccept {
uint32 opt = 1;
uint32 n = 2;
uint32 i = 3;
uint32 member_idx = 4;
string key = 5;
bytes value = 6;
}
message KvsAcceptResponse {
bool success = 1;
uint32 n = 2;
uint32 i = 3;
}
message KvsBalanceAcceptor {
uint32 na = 1;
uint32 np = 2;
uint32 ia = 3;
uint32 member_idx = 4;
string key = 5;
bytes value = 6;
}
message KvsBalanceProposer {
uint32 np = 1;
uint32 ip = 2;
string key = 3;
bytes value = 4;
}
message KvsGet {
uint32 member_idx = 1;
string key = 2;
}
message KvsGetResponse {
bool success = 1;
// The values below are used only success response.
uint32 n = 2;
uint32 i = 3;
bytes value = 4;
}
message KvsHint {
uint32 n = 1;
uint32 i = 2;
string key = 3;
bytes value = 4;
}
message KvsPrepare {
uint32 opt = 1;
uint32 n = 2;
uint32 member_idx = 3;
string key = 4;
}
message KvsPrepareResponse {
bool success = 1;
uint32 n = 2;
// `i` is set only success response.
uint32 i = 3;
}
message KvsSet {
uint32 opt = 1;
string key = 2;
bytes value = 3;
}
message KvsSetResponse {
bool success = 1;
// `reason` are set when failed response.
uint32 reason = 2;
}
// for spread module
message Spread {
NodeID source = 1;
Coordinate center = 2;
double r = 3;
uint64 uid = 4;
string name = 5;
bytes message = 6;
uint32 opt = 7;
}
message SpreadKnock {
Coordinate center = 1;
double r = 2;
uint64 uid = 3;
}
message SpreadKnockResponse {
bool accept = 1;
}
message SpreadRelay {
NodeID source = 1;
Coordinate center = 2;
double r = 3;
uint64 uid = 4;
string name = 5;
bytes message = 6;
uint32 opt = 7;
}
message SpreadRelayResponse {
bool success = 1;
}