##// END OF EJS Templates
Added attachment refs to the protocol sample
neko259 -
r1505:0b6b89f6 decentral
parent child Browse files
Show More
@@ -1,205 +1,203 b''
1 1 # 0 Title #
2 2
3 3 DIP-1 Common protocol description
4 4
5 5 # 1 Intro #
6 6
7 7 This document describes the Data Interchange Protocol (DIP), designed to
8 8 exchange filtered data that can be stored as a graph structure between
9 9 network nodes.
10 10
11 11 # 2 Purpose #
12 12
13 13 This protocol will be used to share the models (originally imageboard posts)
14 14 across multiple servers. The main differnce of this protocol is that the node
15 15 can specify what models it wants to get and from whom. The nodes can get
16 16 models from a specific server, or from all except some specific servers. Also
17 17 the models can be filtered by timestamps or tags.
18 18
19 19 # 3 Protocol description #
20 20
21 21 The node requests other node's changes list since some time (since epoch if
22 22 this is the start). The other node sends a list of post ids or posts in the
23 23 XML format.
24 24
25 25 Protocol version is the version of the sync api. Model version is the version
26 26 of data models. If at least one of them is different, the sync cannot be
27 27 performed.
28 28
29 29 The node signs the data with its keys. The receiving node saves the key at the
30 30 first sync and checks it every time. If the key has changed, the info won't be
31 31 saved from the node (or the node id must be changed). A model can be signed
32 32 with several keys but at least one of them must be the same as in the global
33 33 ID to verify the sender.
34 34
35 35 Each node can have several keys. Nodes can have shared keys to serve as a pool
36 36 (several nodes with the same key).
37 37
38 38 Each post has an ID in the unique format: key-type::key::local-id
39 39
40 40 All requests pass a request type, protocol and model versions, and a list of
41 41 optional arguments used for filtering.
42 42
43 43 Each request has its own version. Version consists of 2 numbers: first is
44 44 incompatible version (1.3 and 2.0 are not compatible and must not be in sync)
45 45 and the second one is minor and compatible (for example, new optional field
46 46 is added which will be igroned by those who don't support it yet).
47 47
48 48 Post edits and reflinks are not saved to the sync model. The replied post ID
49 49 can be got from the post text, and reflinks can be computed when loading
50 50 posts. The edit time is not saved because a foreign post can be 'edited' (new
51 51 replies are added) but the signature must not change (so we can't update the
52 52 content). The inner posts can be edited, and the signature will change then
53 53 but the local-id won't, so the other node can detect that and replace the post
54 54 instead of adding a new one.
55 55
56 56 ## 3.1 Requests ##
57 57
58 58 There is no constraint on how the server should calculate the request. The
59 59 server can return any information by any filter and the requesting node is
60 60 responsible for validating it.
61 61
62 62 The server is required to return the status of request. See 3.2 for details.
63 63
64 64 ### 3.1.1 pull ###
65 65
66 66 "pull" request gets the desired model id list by the given filter (e.g. thread, tags,
67 67 author)
68 68
69 69 Sample request is as follows:
70 70
71 71 <?xml version="1.1" encoding="UTF-8" ?>
72 72 <request version="1.0" type="pull">
73 73 <model version="1.0" name="post">
74 74 <timestamp_from>0</timestamp_from>
75 75 <timestamp_to>0</timestamp_to>
76 76 <tags>
77 77 <tag>tag1</tag>
78 78 </tags>
79 79 <sender>
80 80 <allow>
81 81 <key>abcehy3h9t</key>
82 82 <key>ehoehyoe</key>
83 83 </allow>
84 84 <!-- There can be only allow block (all other are denied) or deny block (all other are allowed) -->
85 85 </sender>
86 86 </model>
87 87 </request>
88 88
89 89 Under the <model> tag there are filters. Filters for the "post" model can
90 90 be found in DIP-2.
91 91
92 92 Sample response:
93 93
94 94 <?xml version="1.1" encoding="UTF-8" ?>
95 95 <response>
96 96 <status>success</status>
97 97 <models>
98 98 <id key="id1" type="ecdsa" local-id="1" />
99 99 <id key="id1" type="ecdsa" local-id="2" />
100 100 <id key="id2" type="ecdsa" local-id="1" />
101 101 <id key="id2" type="ecdsa" local-id="5" />
102 102 </models>
103 103 </response>
104 104
105 105 ### 3.1.2 get ###
106 106
107 107 "get" gets models by id list.
108 108
109 109 Sample request:
110 110
111 111 <?xml version="1.1" encoding="UTF-8" ?>
112 112 <request version="1.0" type="get">
113 113 <model version="1.0" name="post">
114 114 <id key="id1" type="ecdsa" local-id="1" />
115 115 <id key="id1" type="ecdsa" local-id="2" />
116 116 </model>
117 117 </request>
118 118
119 119 Id consists of a key, key type and local id. This key is used for signing and
120 120 validating of data in the model content.
121 121
122 122 Sample response:
123 123
124 124 <?xml version="1.1" encoding="UTF-8" ?>
125 125 <response>
126 126 <!--
127 127 Valid statuses are 'success' and 'error'.
128 128 -->
129 129 <status>success</status>
130 130 <models>
131 131 <model name="post">
132 132 <!--
133 133 Content tag is the data that is signed by signatures and must
134 134 not be changed for the post from other node.
135 135 -->
136 136 <content>
137 137 <id key="id1" type="ecdsa" local-id="1" />
138 138 <title>13</title>
139 139 <text>Thirteen</text>
140 140 <thread><id key="id1" type="ecdsa" local-id="2" /></thread>
141 141 <pub-time>12</pub-time>
142 142 <!--
143 143 Images are saved as attachments and included in the
144 144 signature.
145 145 -->
146 146 <attachments>
147 <attachment mimetype="image/png" name="12345.png">
148 TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0
149 aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1
150 c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0
151 aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl
152 LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=
153 </attachment>
147 <attachment mimetype="image/png">TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5I</attachment>
154 148 </attachments>
155 149 </content>
156 150 <!--
157 151 There can be several signatures for one model. At least one
158 152 signature must be made with the key used in global ID.
159 153 -->
160 154 <signatures>
161 155 <signature key="id1" type="ecdsa" value="dhefhtreh" />
162 156 <signature key="id45" type="ecdsa" value="dsgfgdhefhtreh" />
163 157 </signatures>
158 <attachment-refs>
159 <attachment-ref ref="TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0"
160 url="/media/images/12345.png" />
161 </attachment-refs>
164 162 </model>
165 163 <model name="post">
166 164 <content>
167 165 <id key="id1" type="ecdsa" local-id="id2" />
168 166 <title>13</title>
169 167 <text>Thirteen</text>
170 168 <pub-time>12</pub-time>
171 169 <edit-time>13</edit-time>
172 170 <tags>
173 171 <tag>tag1</tag>
174 172 </tags>
175 173 </content>
176 174 <signatures>
177 175 <signature key="id2" type="ecdsa" value="dehdfh" />
178 176 </signatures>
179 177 </model>
180 178 </models>
181 179 </response>
182 180
183 181 ### 3.1.3 put ###
184 182
185 183 "put" gives a model to the given node (you have no guarantee the node takes
186 184 it, consider you are just advising the node to take your post). This request
187 185 type is useful in pool where all the nodes try to duplicate all of their data
188 186 across the pool.
189 187
190 188 ## 3.2 Responses ##
191 189
192 190 ### 3.2.1 "not supported" ###
193 191
194 192 If the request if completely not supported, a "not supported" status will be
195 193 returned.
196 194
197 195 ### 3.2.2 "success" ###
198 196
199 197 "success" status means the request was processed and the result is returned.
200 198
201 199 ### 3.2.3 "error" ###
202 200
203 201 If the server knows for sure that the operation cannot be processed, it sends
204 202 the "error" status. Additional tags describing the error may be <description>
205 203 and <stack>.
General Comments 0
You need to be logged in to leave comments. Login now