##// END OF EJS Templates
Updated example in the document
neko259 -
r1561:840abed8 default
parent child Browse files
Show More
@@ -1,203 +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">TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5I</attachment>
147 <attachment mimetype="image/png" id-type="md5">TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5I</attachment>
148 148 </attachments>
149 149 </content>
150 150 <!--
151 151 There can be several signatures for one model. At least one
152 152 signature must be made with the key used in global ID.
153 153 -->
154 154 <signatures>
155 155 <signature key="id1" type="ecdsa" value="dhefhtreh" />
156 156 <signature key="id45" type="ecdsa" value="dsgfgdhefhtreh" />
157 157 </signatures>
158 158 <attachment-refs>
159 159 <attachment-ref ref="TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0"
160 160 url="/media/images/12345.png" />
161 161 </attachment-refs>
162 162 </model>
163 163 <model name="post">
164 164 <content>
165 165 <id key="id1" type="ecdsa" local-id="id2" />
166 166 <title>13</title>
167 167 <text>Thirteen</text>
168 168 <pub-time>12</pub-time>
169 169 <edit-time>13</edit-time>
170 170 <tags>
171 171 <tag>tag1</tag>
172 172 </tags>
173 173 </content>
174 174 <signatures>
175 175 <signature key="id2" type="ecdsa" value="dehdfh" />
176 176 </signatures>
177 177 </model>
178 178 </models>
179 179 </response>
180 180
181 181 ### 3.1.3 put ###
182 182
183 183 "put" gives a model to the given node (you have no guarantee the node takes
184 184 it, consider you are just advising the node to take your post). This request
185 185 type is useful in pool where all the nodes try to duplicate all of their data
186 186 across the pool.
187 187
188 188 ## 3.2 Responses ##
189 189
190 190 ### 3.2.1 "not supported" ###
191 191
192 192 If the request if completely not supported, a "not supported" status will be
193 193 returned.
194 194
195 195 ### 3.2.2 "success" ###
196 196
197 197 "success" status means the request was processed and the result is returned.
198 198
199 199 ### 3.2.3 "error" ###
200 200
201 201 If the server knows for sure that the operation cannot be processed, it sends
202 202 the "error" status. Additional tags describing the error may be <description>
203 203 and <stack>.
General Comments 0
You need to be logged in to leave comments. Login now