asciidoctor-rfc 0.2.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +116 -6
  3. data/asciidoctor-rfc.gemspec +15 -1
  4. data/lib/asciidoctor/rfc/common/base.rb +74 -7
  5. data/lib/asciidoctor/rfc/common/front.rb +1 -1
  6. data/lib/asciidoctor/rfc/v2/base.rb +87 -38
  7. data/lib/asciidoctor/rfc/v2/blocks.rb +29 -2
  8. data/lib/asciidoctor/rfc/v2/converter.rb +0 -1
  9. data/lib/asciidoctor/rfc/v2/inline_anchor.rb +2 -8
  10. data/lib/asciidoctor/rfc/v2/lists.rb +7 -4
  11. data/lib/asciidoctor/rfc/v2/table.rb +1 -1
  12. data/lib/asciidoctor/rfc/v3/base.rb +41 -43
  13. data/lib/asciidoctor/rfc/v3/blocks.rb +29 -2
  14. data/lib/asciidoctor/rfc/v3/converter.rb +0 -2
  15. data/lib/asciidoctor/rfc/v3/inline_anchor.rb +2 -6
  16. data/lib/asciidoctor/rfc/version.rb +1 -1
  17. data/spec/asciidoctor/rfc/v2/comments_spec.rb +7 -3
  18. data/spec/asciidoctor/rfc/v2/date_spec.rb +23 -0
  19. data/spec/asciidoctor/rfc/v2/dlist_spec.rb +107 -9
  20. data/spec/asciidoctor/rfc/v2/image_spec.rb +17 -0
  21. data/spec/asciidoctor/rfc/v2/inline_formatting_spec.rb +12 -0
  22. data/spec/asciidoctor/rfc/v2/listing_spec.rb +22 -0
  23. data/spec/asciidoctor/rfc/v2/literal_spec.rb +22 -2
  24. data/spec/asciidoctor/rfc/v2/preamble_spec.rb +72 -0
  25. data/spec/asciidoctor/rfc/v2/references_spec.rb +3 -1
  26. data/spec/asciidoctor/rfc/v2/table_spec.rb +104 -4
  27. data/spec/asciidoctor/rfc/v2/text_spec.rb +89 -0
  28. data/spec/asciidoctor/rfc/v2/ulist_spec.rb +40 -0
  29. data/spec/asciidoctor/rfc/v3/dlist_spec.rb +103 -1
  30. data/spec/asciidoctor/rfc/v3/image_spec.rb +18 -0
  31. data/spec/asciidoctor/rfc/v3/listing_spec.rb +26 -0
  32. data/spec/asciidoctor/rfc/v3/literal_spec.rb +20 -1
  33. data/spec/asciidoctor/rfc/v3/preamble_spec.rb +150 -0
  34. data/spec/asciidoctor/rfc/v3/references_spec.rb +35 -34
  35. data/spec/asciidoctor/rfc/v3/series_info_spec.rb +39 -0
  36. data/spec/examples/README.adoc +162 -0
  37. data/spec/examples/davies-template-bare-06.adoc +3 -0
  38. data/spec/examples/draft-ietf-core-block-xx.mkd +935 -0
  39. data/spec/examples/draft-ietf-core-block-xx.mkd.adoc +1013 -0
  40. data/spec/examples/draft-ietf-core-block-xx.xml.orig +1251 -0
  41. data/spec/examples/example-v2.adoc +6 -2
  42. data/spec/examples/example-v3.adoc +5 -1
  43. data/spec/examples/hoffmanv2.xml.adoc +247 -0
  44. data/spec/examples/hoffmanv2.xml.orig +339 -0
  45. data/spec/examples/hoffmanv3.xml.orig +346 -0
  46. data/spec/examples/mib-doc-template-xml-06.adoc +5 -1
  47. data/spec/examples/rfc2100.md.adoc +2 -3
  48. data/spec/examples/rfc3514.md.adoc +3 -2
  49. data/spec/examples/rfc5841.md.adoc +1 -1
  50. data/spec/examples/rfc748.md.adoc +7 -6
  51. data/spec/examples/rfc7511.md.adoc +15 -15
  52. data/spec/examples/skel.mkd +32 -0
  53. data/spec/examples/skel.mkd.adoc +50 -0
  54. data/spec/examples/skel.xml.orig +105 -0
  55. data/spec/examples/stupid-s.mkd +569 -0
  56. data/spec/examples/stupid-s.mkd.adoc +771 -0
  57. data/spec/examples/stupid-s.xml.orig +880 -0
  58. data/spec/spec_helper.rb +1 -1
  59. metadata +32 -4
@@ -82,7 +82,9 @@ specification in <<RFC2460,4.2 of>>.
82
82
 
83
83
  [#fig-scenic-routing-option-layout]
84
84
  .Scenic Routing Option Layout
85
+ [align=center]
85
86
  ====
87
+ [align=center]
86
88
  ....
87
89
  0 1 2 3
88
90
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -97,18 +99,18 @@ specification in <<RFC2460,4.2 of>>.
97
99
  Option Type::
98
100
  +
99
101
  --
100
- {blank}
101
-
102
102
  8-bit identifier of the type of option. The option identifier
103
103
  0x0A (On Air) is proposed for Scenic Routing.
104
104
 
105
105
  [#fig-option-type]
106
106
  .Scenic Routing Option Type
107
+ [align=center]
107
108
  ====
109
+ [align=center]
108
110
  ....
109
- HEX act chg rest
110
- --- --- --- -----
111
- 0A 00 0 01010 Scenic Routing
111
+ HEX act chg rest
112
+ --- --- --- -----
113
+ 0A 00 0 01010 Scenic Routing
112
114
  ....
113
115
  ====
114
116
 
@@ -119,11 +121,9 @@ The highest-order two bits are set to 00 so any node not
119
121
  final destination.
120
122
  --
121
123
 
122
- Option Length:: {blank}
124
+ Option Length::
123
125
  +
124
126
  --
125
- {blank}
126
-
127
127
  8-bit unsigned integer. The length of the option in octets
128
128
  (excluding the Option Type and Option Length fields). The value
129
129
  **MUST** be greater than 0.
@@ -132,17 +132,17 @@ Option Length:: {blank}
132
132
  SRO Param::
133
133
  +
134
134
  --
135
- {blank}
136
-
137
135
  8-bit identifier indicating Scenic Routing parameters encoded as a bit string.
138
136
 
139
137
  [#fig-bit-string-layout]
140
138
  .SRO Param Bit String Layout
139
+ [align=center]
141
140
  ====
141
+ [align=center]
142
142
  ....
143
- +-+-+-+-+-+-+-+-+
144
- | SR A W AA X Y |
145
- +-+-+-+-+-+-+-+-+
143
+ +-+-+-+-+-+-+-+-+
144
+ | SR A W AA X Y |
145
+ +-+-+-+-+-+-+-+-+
146
146
  ....
147
147
  ====
148
148
 
@@ -192,7 +192,7 @@ Backbone operators who desire to be fully compliant with Scenic
192
192
  Routing **MAY WISH TO** -- well, they **SHOULD** -- have separate MPLS paths
193
193
  ready that provide the most fresh-air time for a given path and are
194
194
  to be used when Scenic Routing is requested by a packet. If such a
195
- path exists, the path MUST be used in favor of any other path, even
195
+ path exists, the path **MUST** be used in favor of any other path, even
196
196
  if another path is considered cheaper according to the path costs
197
197
  used regularly, without taking Scenic Routing into account.
198
198
 
@@ -204,7 +204,7 @@ Scenic Routing for any packets sent back to the originating host for
204
204
  the current connection.
205
205
 
206
206
  If Scenic Routing is requested for connections of local origin, the
207
- host MUST obey the request and route the packet(s) over a wireless
207
+ host **MUST** obey the request and route the packet(s) over a wireless
208
208
  link or use Avian IP Carriers (if available and as requested within
209
209
  the SRO Params).
210
210
 
@@ -0,0 +1,32 @@
1
+ ---
2
+ coding: utf-8
3
+
4
+ title: Many fine lunches and dinners
5
+ abbrev: mfld
6
+ docname: draft-mfld-00
7
+ category: info
8
+
9
+ stand_alone: yes
10
+ pi: [toc, sortrefs, symrefs, comments]
11
+
12
+ author:
13
+ -
14
+ ins: C. Bormann
15
+ name: Carsten Bormann
16
+ org: Universität Bremen TZI
17
+ street: Postfach 330440
18
+ city: Bremen
19
+ code: D-28359
20
+ country: Germany
21
+ phone: +49-421-218-63921
22
+ email: cabo@tzi.org
23
+
24
+ --- abstract
25
+
26
+ insert abstract here
27
+
28
+ --- middle
29
+
30
+ # Introduction
31
+
32
+ This MAY {{?RFC2119}} be useful.
@@ -0,0 +1,50 @@
1
+ = Many fine lunches and dinners
2
+ Carsten Bormann <cabo@tzi.org>
3
+ :doctype: internet-draft
4
+ :abbrev: mfld
5
+ :name: draft-mfld-00
6
+ :status: informational
7
+ :toc-include: yes
8
+ :sort-refs: yes
9
+ :sym-refs: yes
10
+ :forename_initials: C.
11
+ :organization: Universität Bremen TZI
12
+ :street: Postfach 330440
13
+ :city: Bremen
14
+ :code: D-28359
15
+ :country: Germany
16
+ :phone: +49-421-218-63921
17
+ :email: cabo@tzi.org
18
+ :revdate: 2017-11-03
19
+ :comments: yes
20
+
21
+ [abstract]
22
+ insert abstract here
23
+
24
+ == Introduction
25
+
26
+ This MAY <<RFC2119>> be useful.
27
+
28
+ [bibliography]
29
+ == Informative References
30
+ ++++
31
+ <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
32
+ <front>
33
+ <title>
34
+ Key words for use in RFCs to Indicate Requirement Levels
35
+ </title>
36
+ <author initials="S." surname="Bradner" fullname="S. Bradner">
37
+ <organization/>
38
+ </author>
39
+ <date year="1997" month="March"/>
40
+ <abstract>
41
+ <t>
42
+ In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.
43
+ </t>
44
+ </abstract>
45
+ </front>
46
+ <seriesInfo name="BCP" value="14"/>
47
+ <seriesInfo name="RFC" value="2119"/>
48
+ <seriesInfo name="DOI" value="10.17487/RFC2119"/>
49
+ </reference>
50
+ ++++
@@ -0,0 +1,105 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
3
+ <!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.2.7 -->
4
+
5
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
6
+ ]>
7
+
8
+ <?rfc toc="yes"?>
9
+ <?rfc sortrefs="yes"?>
10
+ <?rfc symrefs="yes"?>
11
+ <?rfc comments="yes"?>
12
+
13
+ <rfc docName="draft-mfld-00" category="info">
14
+
15
+ <front>
16
+ <title abbrev="mfld">Many fine lunches and dinners</title>
17
+
18
+ <author initials="C." surname="Bormann" fullname="Carsten Bormann">
19
+ <organization>Universit&auml;t Bremen TZI</organization>
20
+ <address>
21
+ <postal>
22
+ <street>Postfach 330440</street>
23
+ <city>Bremen</city>
24
+ <code>D-28359</code>
25
+ <country>Germany</country>
26
+ </postal>
27
+ <phone>+49-421-218-63921</phone>
28
+ <email>cabo@tzi.org</email>
29
+ </address>
30
+ </author>
31
+
32
+ <date year="2017" month="November" day="03"/>
33
+
34
+
35
+
36
+
37
+
38
+ <abstract>
39
+
40
+
41
+ <t>insert abstract here</t>
42
+
43
+
44
+
45
+ </abstract>
46
+
47
+
48
+ </front>
49
+
50
+ <middle>
51
+
52
+
53
+ <section anchor="introduction" title="Introduction">
54
+
55
+ <t>This MAY <xref target="RFC2119"/> be useful.</t>
56
+
57
+ </section>
58
+
59
+
60
+ </middle>
61
+
62
+ <back>
63
+
64
+
65
+ <references title='Informative References'>
66
+
67
+
68
+
69
+
70
+
71
+ <reference anchor="RFC2119" target='https://www.rfc-editor.org/info/rfc2119'>
72
+ <front>
73
+ <title>Key words for use in RFCs to Indicate Requirement Levels</title>
74
+ <author initials='S.' surname='Bradner' fullname='S. Bradner'><organization /></author>
75
+ <date year='1997' month='March' />
76
+ <abstract><t>In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t></abstract>
77
+ </front>
78
+ <seriesInfo name='BCP' value='14'/>
79
+ <seriesInfo name='RFC' value='2119'/>
80
+ <seriesInfo name='DOI' value='10.17487/RFC2119'/>
81
+ </reference>
82
+
83
+
84
+
85
+
86
+ </references>
87
+
88
+
89
+
90
+ </back>
91
+
92
+ <!-- ##markdown-source:
93
+ H4sIAM0V/FkAA1VPy0rEQBC891c0eNRZNtlVdufiY0XxIIjoQUVkMtPZDCQz
94
+ MtMRovg3/ok/Zm8igoeGpqq6q0opBTY6H7Yae67VCoA9t6Tx2oQBax8I2z7Y
95
+ hjKa4FCUgVIGU1WJ3jR2devARRtMJzcumZrVDlPzOVjDtI1p0OhDHQEyy4cX
96
+ 08Yg0oEyvHqNTxztAeaYOFGdZRu6abGx6yhwfgYwPTcxaUBUMijvssbNDM9i
97
+ 6kwIIzYF2JiUmcI/Jibpdh/8m+T2/P3FeJZIXuPd49UoyGJNrPEmZq6NbXCx
98
+ mC+X85GzniX/dDAB0YnPuSpXi8P1L9IH3rW8pJ3pMIKvzdhyf7lWy7JQZbFS
99
+ R4t1WYwkdca3Gq2p4gm/+5kkBFBKoakki7EMIBUp8R+ADSWaNJ13rpV9D6/E
100
+ Nrreso8B4K7xGa9PH/Dj4/j2YlMWxfrzEyvCPlPdtzP4AdVfVdTrAQAA
101
+
102
+ -->
103
+
104
+ </rfc>
105
+
@@ -0,0 +1,569 @@
1
+ ---
2
+ title: STUN/TURN using PHP in Despair
3
+ abbrev: STuPiD
4
+ docname: draft-hartke-xmpp-stupid-00
5
+ date: 2009-07-05
6
+ category: info
7
+
8
+ ipr: trust200902
9
+ area: General
10
+ workgroup: XMPP Working Group
11
+ keyword: Internet-Draft
12
+
13
+ stand_alone: yes
14
+ pi: [toc, sortrefs, symrefs]
15
+
16
+ author:
17
+ -
18
+ ins: K. Hartke
19
+ name: Klaus Hartke
20
+ organization: Universität Bremen TZI
21
+ email: hartke@tzi.org
22
+ -
23
+ ins: C. Bormann
24
+ name: Carsten Bormann
25
+ org: Universität Bremen TZI
26
+ street: Postfach 330440
27
+ city: Bremen
28
+ code: D-28359
29
+ country: Germany
30
+ phone: +49-421-218-63921
31
+ facsimile: +49-421-218-7000
32
+ email: cabo@tzi.org
33
+
34
+ normative:
35
+ RFC2119:
36
+ RFC3986:
37
+ RFC4086:
38
+ RFC4648:
39
+
40
+ informative:
41
+ RFC5389:
42
+ I-D.ietf-behave-turn:
43
+ STUNT:
44
+ target: http://deusty.blogspot.com/2007/09/stunt-out-of-band-channels.html
45
+ title: STUNT & out-of-band channels
46
+ author:
47
+ name: Robbie Hanson
48
+ ins: R. Hanson
49
+ date: 2007-09-17
50
+ I-D.meyer-xmpp-e2e-encryption:
51
+ I-D.ietf-xmpp-3920bis:
52
+
53
+
54
+
55
+ --- abstract
56
+
57
+ NAT (Network Address Translator) Traversal may require TURN
58
+ (Traversal Using Relays around NAT) functionality in certain
59
+ cases that are not unlikely to occur. There is little
60
+ incentive to deploy TURN servers, except by those who need
61
+ them — who may not be in a position to deploy a new protocol
62
+ on an Internet-connected node, in particular not one with
63
+ deployment requirements as high as those of TURN.
64
+
65
+ "STUN/TURN using PHP in Despair" is a highly deployable
66
+ protocol for obtaining TURN-like functionality, while also
67
+ providing the most important function of STUN.
68
+
69
+ --- middle
70
+
71
+ Introduction {#problems}
72
+ ============
73
+
74
+ NAT (Network Address Translator) Traversal may require TURN
75
+ (Traversal Using Relays around NAT)
76
+ {{I-D.ietf-behave-turn}}
77
+ functionality in certain
78
+ cases that are not unlikely to occur. There is little
79
+ incentive to deploy TURN servers, except by those who need
80
+ them — who may not be in a position to deploy a new protocol
81
+ on an Internet-connected node, in particular not one with
82
+ deployment requirements as high as those of TURN.
83
+
84
+ "STUN/TURN using PHP in Despair" is a highly deployable
85
+ protocol for obtaining TURN-like functionality, while also
86
+ providing the most important function of STUN
87
+ {{RFC5389}}.
88
+
89
+ The high degree of deployability is achieved by making STuPiD
90
+ a Web service, implementable in any Web application deployment
91
+ scheme. As PHP appears to be the solution of choice for
92
+ avoiding deployment problems in the Web world, a PHP-based
93
+ sample implementation of STuPiD is presented in {{figimpl}} in {{impl}}.
94
+ (This single-page script has been tested with a free-of-charge
95
+ web hoster, so it should be deployable by literally everyone.)
96
+
97
+
98
+ The Need for Standardization {#need}
99
+ ----------------------------
100
+
101
+ If STuPiD is so easy to deploy, why standardize on it?
102
+ First of all, STuPiD server implementations will be done by
103
+ other people than the clients making use of the service.
104
+ Clearly communicating between these communities is a good
105
+ idea, in particular if there are security considerations.
106
+
107
+ Having one standard form of STuPiD service instead of one
108
+ specific to each kind of client also creates an incentive
109
+ for optimized implementations.
110
+
111
+ Finally, where STuPiD becomes part of a client standard
112
+ (such as a potential extension to XMPP's in-band byte-stream
113
+ protocol as hinted in {{xmpp}}), it is a good
114
+ thing if STuPiD is already defined.
115
+
116
+ Hence, this document focuses on the definition of the STuPiD
117
+ service itself, tries to make this as general as possible
118
+ without increasing complexity or cost and leaves the details
119
+ of any client standards to future documents.
120
+
121
+
122
+ Basic Protocol Operation {#ops}
123
+ ========================
124
+
125
+ The STuPiD protocol will typically be used with application
126
+ instances that first attempt to obtain connectivity using
127
+ mechanisms similar to those described in the STUN
128
+ specification {{RFC5389}}. However, with STuPiD,
129
+ STUN is not really needed for TCP, as was demonstrated in
130
+ previous STUN-like implementations {{STUNT}}.
131
+ Instead, STuPiD (like {{STUNT}}) provides a
132
+ simple Web service that
133
+ echoes the remote address and port of an incoming HTTP
134
+ request; in most cases, this is enough to get the job done.
135
+
136
+ In case no connection can be established with this simple
137
+ STUN(T)-like mechanism, a TURN-like relay is needed as a final
138
+ fall-back.
139
+ The STuPiD protocol supports this, but solely provides a way
140
+ for the data to be
141
+ relayed. STuPiD relies on an out-of-band channel to notify
142
+ the peer whenever new data is available (synchronization signal).
143
+ See {{xmpp}} for one likely example of such an
144
+ out-of-band channel.
145
+ (Note that the out-of-band channel may have a much lower
146
+ throughput than the STuPiD relay channel — this is exactly
147
+ the case in the example provided in {{xmpp}},
148
+ where the out-of-band channel is typically throughput-limited
149
+ to on the order of a few kilobits per second.)
150
+
151
+ By designing the STuPiD web service in such a way that it can
152
+ be implemented by a simple PHP script such as that presented
153
+ in {{impl}}, it is easy to deploy by those who
154
+ need the STuPiD services.
155
+ The combination of the low-throughput out-of-band channel for
156
+ synchronization and the STuPiD web service for bulk data
157
+ relaying is somewhat silly but gets the job done.
158
+
159
+ The STuPiD data relay is implemented as follows (see {{figops}}):
160
+
161
+ 1. Peer A, the source of the data to be relayed, stores a chunk of
162
+ data at the STuPiD server using an opaque identifier, the "chunk
163
+ identifier". How that chunk identifier is chosen is local to Peer
164
+ A; it could be composed of a random session id and a sequence number.
165
+
166
+ 2. Peer A notifies the receiver of the data, Peer
167
+ B, that a new data chunk is available, specifying the URI needed
168
+ for retrieval.
169
+ This notification is provided through an out-out-band channel.
170
+ (As an optimization for multiple consecutive transfers, A might
171
+ inform B once of a constant prefix of that URI and only send a
172
+ varying part such as a sequence number in each notification —
173
+ this is something to be decided in the client-client notification
174
+ protocol.)
175
+
176
+ 3. Peer B retrieves the data from the STuPiD server using the URI
177
+ provided by Peer A.
178
+
179
+ Note that the data transfer mechanism is one-way, i.e. to send
180
+ data in the other direction as well, Peer B needs to perform
181
+ the same steps using a STuPiD server at the same or a
182
+ different location.
183
+
184
+ ~~~~~~~~~~
185
+
186
+
187
+ STuPiD ```````````````````````````````,
188
+ Script <----------------------------. ,
189
+ | ,
190
+ ^ , | ,
191
+ | , | ,
192
+ (1) | , | , (3)
193
+ POST | , | , GET
194
+ | , | ,
195
+ | v | v
196
+
197
+ Peer A -----------------------> Peer B
198
+ (2)
199
+ out-of-band
200
+ Notification
201
+ ~~~~~~~~~~
202
+ {: #figops title="STuPiD Protocol Operation"}
203
+
204
+
205
+ Protocol Definition
206
+ ===================
207
+
208
+ Terminology {#Terminology}
209
+ -----------
210
+ In this document, the key words "MUST", "MUST NOT", "REQUIRED",
211
+ "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY",
212
+ and "OPTIONAL" are to be interpreted as described in BCP 14, RFC 2119
213
+ {{RFC2119}} and indicate requirement levels for compliant STuPiD
214
+ implementations.
215
+
216
+
217
+ Discovering External IP Address and Port
218
+ ----------------------------------------
219
+
220
+ A client may discover its external IP address and the port
221
+ required for port prediction by performing a HTTP GET
222
+ request to a STuPiD server. The STuPiD server MUST reply
223
+ with the remote address and remote port in the following
224
+ format:
225
+
226
+ host ":" port
227
+
228
+ where 'host' and 'port' are defined as in {{RFC3986}}.
229
+
230
+
231
+ Storing Data
232
+ ------------
233
+
234
+ Data chunks are stored using the POST request of HTTP. The
235
+ STuPiD server MUST support one URI parameter which is passed
236
+ as query-string:
237
+
238
+ 'chid': A unique ID identifying the data chunk to be stored.
239
+ The ID SHOULD be chosen from the characters of the base64url
240
+ set {{RFC4648}}.
241
+
242
+ The payload of the POST request MUST be the data to be
243
+ stored. The 'Content-Type' SHOULD be
244
+ 'application/octet-stream', although a STuPiD server
245
+ implementation SHOULD simply ignore the 'Content-Type' as a
246
+ client implementation may be restricted and may not able to
247
+ specify a specific 'Content-Type'. (E.g., in certain cases,
248
+ the peer may be limited to sending the data as
249
+ multipart-form-encoded — still, the data is stored as a
250
+ byte stream.)
251
+
252
+ STuPiD servers may reject data chunks that are larger than
253
+ some predefined limit.
254
+ This maximum size in bytes of each data chunk is RECOMMENDED
255
+ to be 65536 or more.
256
+
257
+ As HTTP already provides data transparency,
258
+ the data chunk SHOULD NOT be encoded using Base64 or any
259
+ other data transparency mechanism; in any case, the STuPiD
260
+ server will not attempt to decode the chunk.
261
+
262
+ The sender MUST wait for the HTTP response before
263
+ going on to notify the receiver.
264
+
265
+
266
+ Notification
267
+ ------------
268
+
269
+ The sender notifies the receiver of the data chunk by passing
270
+ via an out-of-band channel (which is not part of the STuPiD
271
+ protocol):
272
+
273
+ The full URL from which the data chunk can be retrieved,
274
+ i.e. the same URL that was used to store the data chunk,
275
+ including the chunk ID parameter.
276
+
277
+ The exact notification mechanism over the out-of-band channel
278
+ and the definition of a session is dependent on the
279
+ out-of-band channel. See {{xmpp}} for one
280
+ example of such an out-of-band channel.
281
+
282
+
283
+ Retrieving Data
284
+ ---------------
285
+
286
+ The notified peer retrieves the data chunk using a GET request
287
+ with the URL supplied by the sender. The STuPiD server MUST
288
+ set the 'Content-Type' of the returned body to
289
+ 'application/octet-stream'.
290
+
291
+
292
+ Implementation Notes
293
+ ====================
294
+
295
+ A STuPiD server implementation SHOULD delete stored data some
296
+ time after it was stored. It is RECOMMENDED not to delete the
297
+ data before five minutes have elapsed after it was stored.
298
+ Different client protocols will have different reactions to
299
+ data that have been deleted prematurely and cannot be
300
+ retrieved by the notified peer; this may be as trivial as
301
+ packet loss or it may cause a reliable byte-stream to fail
302
+ ({{impl}}).
303
+ (TODO: It may be useful to provide some hints in the storing
304
+ POST request.)
305
+
306
+ STuPiD clients should aggregate data in order to minimize the
307
+ number of requests to the STuPiD server per second.
308
+ The specific aggregation method chosen depends on the data
309
+ rate required (and the maximum chunk size), the latency
310
+ requirements, and the application semantics.
311
+
312
+ Clearly, it is up to the implementation to decide how the data
313
+ chunks are actually stored. A sufficiently silly STuPiD server
314
+ implementation might for instance use a MySQL database.
315
+
316
+
317
+ Security Considerations
318
+ =======================
319
+
320
+ The security objectives of STuPiD are to be as secure as if
321
+ NAT traversal had succeeded, i.e., an on-path attacker can
322
+ overhear and fake messages, but an off-path attacker cannot.
323
+ If a higher level of security is desired, it should be
324
+ provided on top of the data relayed by STuPiD, e.g. by using
325
+ XTLS {{I-D.meyer-xmpp-e2e-encryption}}.
326
+
327
+ Much of the security of STuPiD is based on the assumption that
328
+ an off-path attacker cannot guess the chunk identifiers. A
329
+ suitable source of randomness {{RFC4086}} should
330
+ be used to generate at least a sufficiently large part of the
331
+ chunk identifiers (e.g., the chunk identifier could be a hard
332
+ to guess prefix followed by a serial number).
333
+
334
+ To protect the STuPiD server against denial of service and
335
+ possibly some forms of theft of service, it is RECOMMENDED
336
+ that the POST side of the STuPiD server be protected by some
337
+ form of authentication such as HTTP authentication. There is
338
+ little need to protect the GET side.
339
+
340
+ --- back
341
+
342
+
343
+ Examples {#xmp}
344
+ ========
345
+
346
+ This appendix provides some examples of the STuPiD protocol operation.
347
+
348
+ ~~~~~~~~~~
349
+ Request:
350
+
351
+ GET /stupid.php HTTP/1.0
352
+ User-Agent: Example/1.11.4
353
+ Accept: */*
354
+ Host: example.org
355
+ Connection: Keep-Alive
356
+
357
+ Response:
358
+
359
+ HTTP/1.1 200 OK
360
+ Date: Sun, 05 Jul 2009 00:30:37 GMT
361
+ Server: Apache/2.2
362
+ Cache-Control: no-cache, must-revalidate
363
+ Expires: Sat, 26 Jul 1997 05:00:00 GMT
364
+ Vary: Accept-Encoding
365
+ Content-Length: 17
366
+ Keep-Alive: timeout=1, max=400
367
+ Connection: Keep-Alive
368
+ Content-Type: application/octet-stream
369
+
370
+ 192.0.2.239:36654
371
+ ~~~~~~~~~~
372
+ {: #figxmpdisco title="Discovering External IP Address and Port"}
373
+
374
+ ~~~~~~~~~~
375
+ Request:
376
+
377
+ POST /stupid.php?chid=i781hf64-0 HTTP/1.0
378
+ User-Agent: Example/1.11.4
379
+ Accept: */*
380
+ Host: example.org
381
+ Connection: Keep-Alive
382
+ Content-Type: application/octet-stream
383
+ Content-Length: 11
384
+
385
+ Hello World
386
+
387
+ Response:
388
+
389
+ HTTP/1.1 200 OK
390
+ Date: Sun, 05 Jul 2009 00:20:34 GMT
391
+ Server: Apache/2.2
392
+ Cache-Control: no-cache, must-revalidate
393
+ Expires: Sat, 26 Jul 1997 05:00:00 GMT
394
+ Vary: Accept-Encoding
395
+ Content-Length: 0
396
+ Keep-Alive: timeout=1, max=400
397
+ Connection: Keep-Alive
398
+ Content-Type: application/octet-stream
399
+ ~~~~~~~~~~
400
+ {: #figxmpstore title="Storing Data"}
401
+
402
+ ~~~~~~~~~~
403
+ Request:
404
+
405
+ GET /stupid.php?chid=i781hf64-0 HTTP/1.0
406
+ User-Agent: Example/1.11.4
407
+ Accept: */*
408
+ Host: example.org
409
+ Connection: Keep-Alive
410
+
411
+ Response:
412
+
413
+ HTTP/1.1 200 OK
414
+ Date: Sun, 05 Jul 2009 00:21:29 GMT
415
+ Server: Apache/2.2
416
+ Cache-Control: no-cache, must-revalidate
417
+ Expires: Sat, 26 Jul 1997 05:00:00 GMT
418
+ Vary: Accept-Encoding
419
+ Content-Length: 11
420
+ Keep-Alive: timeout=1, max=400
421
+ Connection: Keep-Alive
422
+ Content-Type: application/octet-stream
423
+
424
+ Hello World
425
+ ~~~~~~~~~~
426
+ {: #figxmpretr title="Retrieving Data"}
427
+
428
+
429
+ Sample Implementation {#impl}
430
+ =====================
431
+
432
+ ~~~~~~~~~~
433
+ <?php
434
+ header("Cache-Control: no-cache, must-revalidate");
435
+ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
436
+ header("Content-Type: application/octet-stream");
437
+
438
+ mysql_connect(localhost, "username", "password");
439
+ mysql_select_db("stupid");
440
+
441
+ $chid = mysql_real_escape_string($_GET["chid"]);
442
+
443
+ if ($_SERVER["REQUEST_METHOD"] == "GET") {
444
+ if (empty($chid)) {
445
+ echo $_SERVER["REMOTE_ADDR"] . ":" . $_SERVER["REMOTE_PORT"];
446
+ } elseif ($result = mysql_query("SELECT `data` FROM `Data` " .
447
+ "WHERE `chid` = '$chid'")) {
448
+ if ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
449
+ echo base64_decode($row["data"]);
450
+ } else {
451
+ header("HTTP/1.0 404 Not Found");
452
+ }
453
+ mysql_free_result($result);
454
+ } else {
455
+ header("HTTP/1.0 404 Not Found");
456
+ }
457
+ } elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
458
+ if (empty($chid)) {
459
+ header("HTTP/1.0 404 Not Found");
460
+ } else {
461
+ mysql_query("DELETE FROM `Data` " .
462
+ "WHERE `timestamp` < DATE_SUB(NOW(), INTERVAL 5 MINUTE)");
463
+ $data = base64_encode(file_get_contents("php://input"));
464
+ if (!mysql_query("INSERT INTO `Data` (`chid`, `data`) " .
465
+ "VALUES ('$chid', '$data')")) {
466
+ header("HTTP/1.0 403 Bad Request");
467
+ }
468
+ }
469
+ } else {
470
+ header("HTTP/1.0 405 Method Not Allowed");
471
+ header("Allow: GET, HEAD, POST");
472
+ }
473
+ mysql_close();
474
+ ?>
475
+ ~~~~~~~~~~
476
+ {: #figimpl title="STuPiD Sample Implementation"}
477
+
478
+
479
+ Using XMPP as Out-Of-Band Channel {#xmpp}
480
+ =================================
481
+
482
+ XMPP {{I-D.ietf-xmpp-3920bis}} is a good choice for
483
+ an out-of-band channel.
484
+
485
+ The notification protocol is closely modeled after XMPP's
486
+ In-Band Bytestreams (IBB, see
487
+ http://xmpp.org/extensions/xep-0047.html). Just replace the
488
+ namespace and insert the STuPiD Retrieval URI instead of the
489
+ actual Base64 encoded data, see {{figxmpnots}}.
490
+ (Note that the current proposal redundantly sends a sid and a
491
+ seq as well as the chid composed of these two; it may be
492
+ possible to optimize this, possibly sending the constant prefix
493
+ of the URI once at bytestream creation time.)
494
+
495
+ Notifications MUST be processed in the order they are
496
+ received. If an out-of-sequence notification is received for a
497
+ particular session (determined by checking the 'seq' attribute),
498
+ then this indicates that a notification has been lost. The
499
+ recipient MUST NOT process such an out-of-sequence notification,
500
+ nor any that follow it within the same session; instead, the
501
+ recipient MUST consider the session invalid. (Adapted from
502
+ http://xmpp.org/extensions/xep-0047.html#send)
503
+
504
+ Of course, other methods can be used for setup and teardown, such as Jingle
505
+ (see http://xmpp.org/extensions/xep-0261.html).
506
+
507
+ ~~~~~~~~~~
508
+ <iq from='romeo@montague.net/orchard'
509
+ id='jn3h8g65'
510
+ to='juliet@capulet.com/balcony'
511
+ type='set'>
512
+ <open xmlns='urn:xmpp:tmp:stupid'
513
+ block-size='65536'
514
+ sid='i781hf64'
515
+ stanza='iq'/>
516
+ </iq>
517
+ ~~~~~~~~~~
518
+ {: #figxmpcri title="Creating a Bytestream: Initiator requests session"}
519
+
520
+
521
+ ~~~~~~~~~~
522
+ <iq from='juliet@capulet.com/balcony'
523
+ id='jn3h8g65'
524
+ to='romeo@montague.net/orchard'
525
+ type='result'/>
526
+ ~~~~~~~~~~
527
+ {: #figxmpcrr title="Creating a Bytestream: Responder accepts session"}
528
+
529
+
530
+
531
+ ~~~~~~~~~~
532
+ <iq from='romeo@montague.net/orchard'
533
+ id='kr91n475'
534
+ to='juliet@capulet.com/balcony'
535
+ type='set'>
536
+ <data xmlns='urn:xmpp:tmp:stupid'
537
+ seq='0'
538
+ sid='i781hf64'
539
+ url='http://example.org/stupid.php?chid=i781hf64-0'/>
540
+ </iq>
541
+ ~~~~~~~~~~
542
+ {: #figxmpnots title="Sending Notifications: Notification in an IQ stanza"}
543
+
544
+ ~~~~~~~~~~
545
+ <iq from='juliet@capulet.com/balcony'
546
+ id='kr91n475'
547
+ to='romeo@montague.net/orchard'
548
+ type='result'/>
549
+ ~~~~~~~~~~
550
+ {: #figxmpnota title="Sending Notifications: Acknowledging notification using IQ"}
551
+
552
+ ~~~~~~~~~~
553
+ <iq from='romeo@montague.net/orchard'
554
+ id='us71g45j'
555
+ to='juliet@capulet.com/balcony'
556
+ type='set'>
557
+ <close xmlns='urn:xmpp:tmp:stupid'
558
+ sid='i781hf64'/>
559
+ </iq>
560
+ ~~~~~~~~~~
561
+ {: #figxmpclor title="Closing the Bytestream: Request"}
562
+
563
+ ~~~~~~~~~~
564
+ <iq from='juliet@capulet.com/balcony'
565
+ id='us71g45j'
566
+ to='romeo@montague.net/orchard'
567
+ type='result'/>
568
+ ~~~~~~~~~~
569
+ {: #figxmpclos title="Closing the Bytestream: Success response"}