Updated dataspec lexer
This commit is contained in:
@ -11,8 +11,8 @@ class DataSpecLexer(RegexLexer):
|
||||
(r'(\s*)(\+-)', bygroups(Text, Text), 'boundary'),
|
||||
(r'(\s+)([\+|])', bygroups(Text, Text), 'content'),
|
||||
(r'(\s*)(~)', bygroups(Text, Generic.Strong), 'content'),
|
||||
(r'(\s*)([\w=;]+)(\s)(::)(\s)', bygroups(Text, Name.Tag, Text, Operator, Text)),
|
||||
(r'(\s*)((?:[A-Z][a-z]+)+)', bygroups(Text, Name.Class)),
|
||||
(r'(\s*)([\w=;]+)(\s[\w=;]+)*(\s)(::)(\s)', bygroups(Text, Name.Tag, Name.Tag, Text, Operator, Text)),
|
||||
(r'(\s*)`((?:[A-Z][a-z]+)(?:[A-Z][a-z]*)*)`', bygroups(Text, Name.Class)),
|
||||
(r'(\s*)([A-Z]{2,})', bygroups(Text, Name.Constant)),
|
||||
(r'(\s*)([\[\]])', bygroups(Text, Punctuation)),
|
||||
(r'(\s*)(\$\w+)', bygroups(Text, Name.Tag)),
|
||||
@ -34,8 +34,8 @@ class DataSpecLexer(RegexLexer):
|
||||
(r'(\s*)(\.\.\.)(\s)', bygroups(Text, Generic.Strong, Text)),
|
||||
(r'(\s*)(\.\.\.)$', bygroups(Text, Generic.Strong), '#pop'),
|
||||
(r'(\s*)(~)$', bygroups(Text, Generic.Strong), '#pop'),
|
||||
(r'(\s*)([\w=;]+)$', bygroups(Text, Name.Tag), '#pop'),
|
||||
(r'(\s*)([\w=;]+)', bygroups(Text, Name.Tag)),
|
||||
(r'(\s*)([\w=;]+)(\s[\w=;]+)*$', bygroups(Text, Name.Tag, Name.Tag), '#pop'),
|
||||
(r'(\s*)([\w=;]+)(\s[\w=;]+)*', bygroups(Text, Name.Tag, Name.Tag)),
|
||||
(r'(\s*)(\|)', bygroups(Text, Text)),
|
||||
(r'(\s*)(\()', bygroups(Text, Punctuation), 'expression'),
|
||||
],
|
||||
|
@ -184,7 +184,7 @@ A certificate is a container for various receipts or proof of works used through
|
||||
|type| length | payload
|
||||
+----+----+----+----+----+-//
|
||||
|
||||
type :: Integer
|
||||
type :: `Integer`
|
||||
length -> 1 byte
|
||||
|
||||
case 0 -> NULL
|
||||
@ -193,7 +193,7 @@ type :: Integer
|
||||
case 3 -> SIGNED
|
||||
case 4 -> MULTIPLE
|
||||
|
||||
length :: Integer
|
||||
length :: `Integer`
|
||||
length -> 2 bytes
|
||||
|
||||
payload :: data
|
||||
@ -238,16 +238,16 @@ A 2-byte size Integer followed by a series of String=String; pairs
|
||||
+----+----+----+----+----+----+----+----+
|
||||
| val_string (len + data) | ; | ...
|
||||
+----+----+----+----+----+----+----+
|
||||
size :: Integer
|
||||
size :: `Integer`
|
||||
length -> 2 bytes
|
||||
Total number of bytes that follow
|
||||
|
||||
key_string :: String
|
||||
key_string :: `String`
|
||||
A string (one byte length followed by UTF-8 encoded characters)
|
||||
|
||||
= :: A single byte containing '='
|
||||
|
||||
val_string :: String
|
||||
val_string :: `String`
|
||||
A string (one byte length followed by UTF-8 encoded characters)
|
||||
|
||||
; :: A single byte containing ';'
|
||||
@ -336,13 +336,13 @@ Defines the way to uniquely identify a particular router
|
||||
| certificate |
|
||||
+----+----+----+-//
|
||||
|
||||
public_key :: PublicKey
|
||||
public_key :: `PublicKey`
|
||||
length -> 256 bytes
|
||||
|
||||
signing_key :: SigningPublicKey
|
||||
signing_key :: `SigningPublicKey`
|
||||
length -> 128 bytes
|
||||
|
||||
certificate :: Certificate
|
||||
certificate :: `Certificate`
|
||||
length -> >= 3 bytes
|
||||
|
||||
total length: 387+ bytes
|
||||
@ -385,13 +385,13 @@ A Destination defines a particular endpoint to which messages can be directed fo
|
||||
| certificate
|
||||
+-//
|
||||
|
||||
public_key :: PublicKey
|
||||
public_key :: `PublicKey`
|
||||
length -> 256 bytes
|
||||
|
||||
signing_public_key :: SigningPublicKey
|
||||
signing_public_key :: `SigningPublicKey`
|
||||
length -> 128 bytes
|
||||
|
||||
certificate :: Certificate
|
||||
certificate :: `Certificate`
|
||||
length -> >= 3 bytes
|
||||
|
||||
total length: 387+ bytes
|
||||
@ -432,13 +432,13 @@ SHA256 <a href="#type_Hash">Hash</a> of the
|
||||
|
|
||||
+----+----+----+----+
|
||||
|
||||
tunnel_gw :: Hash of the RouterIdentity of the tunnel gateway
|
||||
tunnel_gw :: Hash of the `RouterIdentity` of the tunnel gateway
|
||||
length -> 32 bytes
|
||||
|
||||
tunnel_id :: TunnelId
|
||||
tunnel_id :: `TunnelId`
|
||||
length -> 4 bytes
|
||||
|
||||
end_date :: Date
|
||||
end_date :: `Date`
|
||||
length -> 8 bytes
|
||||
{% endhighlight %}
|
||||
|
||||
@ -529,23 +529,23 @@ bytes signed by the <a href="#struct_Destination">Destination's</a> <a href="#ty
|
||||
| |
|
||||
+----+----+----+----+----+----+----+----+
|
||||
|
||||
destination :: Destination
|
||||
destination :: `Destination`
|
||||
length -> >= 387 bytes
|
||||
|
||||
encryption_key :: PublicKey
|
||||
encryption_key :: `PublicKey`
|
||||
length -> 256 bytes
|
||||
|
||||
signing_key :: SigningPublicKey
|
||||
signing_key :: `SigningPublicKey`
|
||||
length -> 128 bytes
|
||||
|
||||
num :: Integer
|
||||
num :: `Integer`
|
||||
length -> 1 byte
|
||||
value: 0 <= num <= 16
|
||||
|
||||
leases :: [Lease]
|
||||
leases :: [`Lease`]
|
||||
length -> $num*44 bytes
|
||||
|
||||
signature :: Signature
|
||||
signature :: `Signature`
|
||||
length -> 40 bytes
|
||||
|
||||
{% endhighlight %}
|
||||
@ -611,21 +611,21 @@ IP address, port number, email address, URL, etc.
|
||||
| options |
|
||||
+----+----+----+----+-//-+----+----+----+
|
||||
|
||||
cost :: Integer
|
||||
cost :: `Integer`
|
||||
length -> 1 byte
|
||||
|
||||
case 0 -> free
|
||||
case 255 -> expensive
|
||||
|
||||
expiration :: Date (must be all zeros, see notes below)
|
||||
expiration :: `Date` (must be all zeros, see notes below)
|
||||
length -> 8 bytes
|
||||
|
||||
case null -> never expires
|
||||
|
||||
transport_style :: String
|
||||
transport_style :: `String`
|
||||
length -> 1-256 bytes
|
||||
|
||||
options :: Mapping
|
||||
options :: `Mapping`
|
||||
{% endhighlight %}
|
||||
|
||||
<h4>{% trans %}Notes{% endtrans %}</h4>
|
||||
@ -712,26 +712,26 @@ the contained <a href="#struct_RouterIdentity">RouterIdentity</a>.
|
||||
| |
|
||||
+----+----+----+----+----+----+----+----+
|
||||
|
||||
router_ident :: RouterIdentity
|
||||
router_ident :: `RouterIdentity`
|
||||
length -> >= 387 bytes
|
||||
|
||||
published :: Date
|
||||
published :: `Date`
|
||||
length -> 8 bytes
|
||||
|
||||
size :: Integer
|
||||
size :: `Integer`
|
||||
length -> 1 byte
|
||||
|
||||
addresses :: [RouterAddress]
|
||||
addresses :: [`RouterAddress`]
|
||||
length -> >= $size*267 bytes
|
||||
|
||||
peer_size :: Integer
|
||||
peer_size :: `Integer`
|
||||
length -> 1 byte
|
||||
|
||||
value -> 0
|
||||
|
||||
options :: Mapping
|
||||
options :: `Mapping`
|
||||
|
||||
signature :: Signature
|
||||
signature :: `Signature`
|
||||
length -> 40 bytes
|
||||
|
||||
{% endhighlight %}
|
||||
|
@ -49,12 +49,12 @@ Short (SSU, 5 bytes):
|
||||
|
||||
<h4>Definition</h4>
|
||||
{% highlight lang='dataspec' %}
|
||||
type :: Integer
|
||||
type :: `Integer`
|
||||
length -> 1 byte
|
||||
|
||||
purpose -> identifies the message type (see table below)
|
||||
|
||||
msg_id :: Integer
|
||||
msg_id :: `Integer`
|
||||
length -> 4 bytes
|
||||
|
||||
purpose -> uniquely identifies this message (for some time at least)
|
||||
@ -62,20 +62,20 @@ msg_id :: Integer
|
||||
outgoing tunnel build messages it may be derived from
|
||||
the incoming message. See below.
|
||||
|
||||
expiration :: Date
|
||||
expiration :: `Date`
|
||||
8 bytes
|
||||
date this message will expire
|
||||
|
||||
short_expiration :: Integer
|
||||
short_expiration :: `Integer`
|
||||
4 bytes
|
||||
date this message will expire (seconds since the epoch)
|
||||
|
||||
size :: Integer
|
||||
size :: `Integer`
|
||||
length -> 2 bytes
|
||||
|
||||
purpose -> length of the payload
|
||||
|
||||
chks :: Integer
|
||||
chks :: `Integer`
|
||||
length -> 1 byte
|
||||
|
||||
purpose -> checksum of the payload
|
||||
@ -202,37 +202,37 @@ ElGamal and AES encrypted:
|
||||
{% highlight lang='dataspec' %}
|
||||
unencrypted:
|
||||
|
||||
receive_tunnel :: TunnelId
|
||||
receive_tunnel :: `TunnelId`
|
||||
length -> 4 bytes
|
||||
our_ident :: Hash
|
||||
our_ident :: `Hash`
|
||||
length -> 32 bytes
|
||||
|
||||
next_tunnel :: TunnelId
|
||||
next_tunnel :: `TunnelId`
|
||||
length -> 4 bytes
|
||||
|
||||
next_ident :: Hash
|
||||
next_ident :: `Hash`
|
||||
length -> 32 bytes
|
||||
|
||||
layer_key :: SessionKey
|
||||
layer_key :: `SessionKey`
|
||||
length -> 32 bytes
|
||||
|
||||
iv_key :: SessionKey
|
||||
iv_key :: `SessionKey`
|
||||
length -> 32 bytes
|
||||
|
||||
reply_key :: SessionKey
|
||||
reply_key :: `SessionKey`
|
||||
length -> 32 bytes
|
||||
|
||||
reply_iv :: data
|
||||
length -> 16 bytes
|
||||
|
||||
flag :: Integer
|
||||
flag :: `Integer`
|
||||
length -> 1 byte
|
||||
|
||||
request_time :: Integer
|
||||
request_time :: `Integer`
|
||||
length -> 4 bytes
|
||||
Hours since the epoch, i.e. current time / 3600
|
||||
|
||||
send_message_id :: Integer
|
||||
send_message_id :: `Integer`
|
||||
length -> 4 bytes
|
||||
|
||||
padding :: Data
|
||||
@ -343,9 +343,9 @@ Delivery Instructions :: <a href="{{ site_url('docs/spec/tunnel-message') }}#del
|
||||
|
||||
I2NP Message :: Any I2NP Message
|
||||
|
||||
Clove ID :: 4 byte Integer
|
||||
Clove ID :: 4 byte `Integer`
|
||||
|
||||
Expiration :: Date (8 bytes)
|
||||
Expiration :: `Date` (8 bytes)
|
||||
|
||||
Certificate :: Always NULL in the current implementation (3 bytes total, all zeroes)
|
||||
|
||||
@ -493,8 +493,8 @@ type:
|
||||
1 byte
|
||||
type identifier
|
||||
mapping:
|
||||
0 RouterInfo
|
||||
1 LeaseSet
|
||||
0 `RouterInfo`
|
||||
1 `LeaseSet`
|
||||
|
||||
reply token:
|
||||
4 bytes
|
||||
@ -504,7 +504,7 @@ reply token:
|
||||
if the token is greater than zero.
|
||||
|
||||
reply tunnelId:
|
||||
4 byte Tunnel ID
|
||||
4 byte `TunnelID`
|
||||
only included if reply token > 0
|
||||
This is the <a href="{{ site_url('docs/spec/common-structures') }}#type_TunnelID">tunnel ID</a> of the inbound gateway of the tunnel the response should be sent to
|
||||
|
||||
@ -515,8 +515,8 @@ reply gateway:
|
||||
This is the router hash of the inbound gateway of the tunnel the response should be sent to
|
||||
|
||||
data:
|
||||
If type == 0, data is a 2-byte integer specifying the number of bytes that follow, followed by a gzip-compressed RouterInfo.
|
||||
If type == 1, data is an uncompressed LeaseSet.
|
||||
If type == 0, data is a 2-byte integer specifying the number of bytes that follow, followed by a gzip-compressed `RouterInfo`.
|
||||
If type == 1, data is an uncompressed `LeaseSet`.
|
||||
</pre>
|
||||
|
||||
<h4>Notes</h4>
|
||||
@ -615,12 +615,12 @@ flags ::
|
||||
as of release 0.9.6, ignored, set to 0 for compatibility with future uses and with older routers
|
||||
|
||||
reply_tunnelId ::
|
||||
4 byte Tunnel ID
|
||||
4 byte `TunnelID`
|
||||
only included if deliveryFlag == 1
|
||||
tunnelId of the tunnel to send the reply to
|
||||
|
||||
size ::
|
||||
2 byte Integer
|
||||
2 byte `Integer`
|
||||
valid range: 0-512
|
||||
number of peers to exclude from the DatabaseSearchReply Message
|
||||
|
||||
@ -632,17 +632,17 @@ excludedPeers ::
|
||||
the DatabaseSearchReply Message is requested to list non-floodfill routers only.
|
||||
|
||||
reply_key ::
|
||||
32 byte SessionKey
|
||||
32 byte `SessionKey`
|
||||
only included if encryptionFlag == 1, only as of release 0.9.7
|
||||
|
||||
tags ::
|
||||
1 byte Integer
|
||||
1 byte `Integer`
|
||||
valid range: 1-32 (typically 1)
|
||||
the number of reply tags that follow
|
||||
only included if encryptionFlag == 1, only as of release 0.9.7
|
||||
|
||||
reply_tags ::
|
||||
one or more 32 byte SessionTags (typically one)
|
||||
one or more 32 byte `SessionTags` (typically one)
|
||||
only included if encryptionFlag == 1, only as of release 0.9.7
|
||||
|
||||
{% endhighlight %}
|
||||
@ -715,16 +715,16 @@ key ::
|
||||
SHA256 of the object being searched
|
||||
|
||||
num ::
|
||||
1 byte Integer
|
||||
1 byte `Integer`
|
||||
number of peer hashes that follow, 0-255
|
||||
|
||||
peer_hash ($num entries) ::
|
||||
32 bytes
|
||||
SHA256 of the RouterIdentity that the other router thinks is close to the key
|
||||
SHA256 of the `RouterIdentity` that the other router thinks is close to the key
|
||||
|
||||
from ::
|
||||
32 bytes
|
||||
SHA256 of the RouterInfo of the router this reply was sent from
|
||||
SHA256 of the `RouterInfo` of the router this reply was sent from
|
||||
{% endhighlight %}
|
||||
|
||||
<h4>Notes</h4>
|
||||
@ -837,15 +837,15 @@ data ::
|
||||
Unencrypted data:
|
||||
|
||||
num ::
|
||||
1 byte Integer number of GarlicCloves to follow
|
||||
1 byte Integer number of `GarlicCloves` to follow
|
||||
|
||||
clove :: a GarlicClove
|
||||
clove :: a `GarlicClove`
|
||||
|
||||
Certificate :: always NULL in the current implementation (3 bytes total, all zeroes)
|
||||
|
||||
Message_ID :: 4 byte Integer
|
||||
Message_ID :: 4 byte `Integer`
|
||||
|
||||
Expiration :: Date (8 bytes)
|
||||
Expiration :: `Date` (8 bytes)
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
@ -899,7 +899,7 @@ Expiration :: Date (8 bytes)
|
||||
<h4>Definition</h4>
|
||||
{% highlight lang='dataspec' %}
|
||||
tunnelId ::
|
||||
4 byte Tunnel ID
|
||||
4 byte `TunnelID`
|
||||
identifies the tunnel this message is directed at
|
||||
|
||||
data ::
|
||||
@ -931,11 +931,11 @@ data ::
|
||||
<h4>Definition</h4>
|
||||
{% highlight lang='dataspec' %}
|
||||
tunnelId ::
|
||||
4 byte Tunnel ID
|
||||
4 byte `TunnelID`
|
||||
identifies the tunnel this message is directed at
|
||||
|
||||
length ::
|
||||
2 byte Integer
|
||||
2 byte `Integer`
|
||||
length of the payload
|
||||
|
||||
data ::
|
||||
@ -995,7 +995,7 @@ data ::
|
||||
|
||||
<h4>Definition</h4>
|
||||
{% highlight lang='dataspec' %}
|
||||
Just 8 Build Request Records attached together
|
||||
Just 8 `BuildRequestRecords` attached together
|
||||
record size: 528 bytes
|
||||
total size: 8*528 = 4224 bytes
|
||||
{% endhighlight %}
|
||||
@ -1011,7 +1011,7 @@ total size: 8*528 = 4224 bytes
|
||||
|
||||
<h3 id="msg_TunnelBuildReply">TunnelBuildReply</h3>
|
||||
{% highlight lang='dataspec' %}
|
||||
same format as TunnelBuild message, with Build Response Records
|
||||
same format as `TunnelBuild` message, with `BuildResponseRecords`
|
||||
{% endhighlight %}
|
||||
|
||||
<h4>Notes</h4>
|
||||
@ -1034,7 +1034,7 @@ same format as TunnelBuild message, with Build Response Records
|
||||
Same format as TunnelBuildMessage, except for the addition of an "num" field in front and $num number of Build Request Records instead of 8
|
||||
|
||||
num ::
|
||||
1 byte Integer
|
||||
1 byte `Integer`
|
||||
Valid values: 1-8
|
||||
|
||||
record size: 528 bytes
|
||||
|
@ -34,14 +34,14 @@ After the tunnel messages are created, they are encrypted as described in
|
||||
These are the contents of a tunnel data message after encryption.
|
||||
{% highlight lang='dataspec' %}
|
||||
+----+----+----+----+----+----+----+----+
|
||||
| Tunnel_ID | IV |
|
||||
| Tunnel ID | IV |
|
||||
+----+----+----+----+ +
|
||||
| |
|
||||
+ +----+----+----+----+
|
||||
| | |
|
||||
+----+----+----+----+ +
|
||||
| |
|
||||
+ Encrypted_Data +
|
||||
+ Encrypted Data +
|
||||
~ ~
|
||||
| |
|
||||
+ +-------------------+
|
||||
@ -51,7 +51,7 @@ These are the contents of a tunnel data message after encryption.
|
||||
|
||||
<h4>Definition</h4>
|
||||
{% highlight lang='dataspec' %}
|
||||
Tunnel_ID ::
|
||||
Tunnel ID ::
|
||||
4 bytes
|
||||
the ID of the next hop
|
||||
|
||||
@ -59,7 +59,7 @@ IV ::
|
||||
16 bytes
|
||||
the initialization vector
|
||||
|
||||
Encrypted_Data ::
|
||||
Encrypted Data ::
|
||||
1008 bytes
|
||||
the encrypted tunnel message
|
||||
|
||||
@ -72,7 +72,7 @@ total size: 1028 Bytes
|
||||
These are the contents of a tunnel data message when decrypted.
|
||||
{% highlight lang='dataspec' %}
|
||||
+----+----+----+----+----+----+----+----+
|
||||
| Tunnel_ID | IV |
|
||||
| Tunnel ID | IV |
|
||||
+----+----+----+----+ +
|
||||
| |
|
||||
+ +----+----+----+----+
|
||||
@ -112,7 +112,7 @@ These are the contents of a tunnel data message when decrypted.
|
||||
|
||||
<h4>Definition</h4>
|
||||
<pre>
|
||||
Tunnel_ID ::
|
||||
Tunnel ID ::
|
||||
4 bytes
|
||||
the ID of the next hop
|
||||
|
||||
@ -124,7 +124,7 @@ Checksum ::
|
||||
4 bytes
|
||||
the first 4 bytes of the SHA256 hash of the contents of the message after the zero byte concatenated with the IV
|
||||
|
||||
Nonzero_padding ::
|
||||
Nonzero padding ::
|
||||
0 or more bytes
|
||||
random nonzero data for padding
|
||||
|
||||
@ -132,12 +132,12 @@ Zero ::
|
||||
1 byte
|
||||
the value 0x00
|
||||
|
||||
Delivery_Instructions ::
|
||||
Delivery Instructions ::
|
||||
length varies but is typically 7, 39, 43, or 47 bytes
|
||||
Indicates the fragment and the routing for the fragment
|
||||
See <a href="#delivery">below</a> for specification
|
||||
|
||||
Message_Fragment ::
|
||||
Message Fragment ::
|
||||
1 to 996 bytes, actual maximum depends on delivery instruction size
|
||||
A partial or full I2NP Message
|
||||
|
||||
@ -262,7 +262,7 @@ Total length: Typical length is:
|
||||
<p>If the MSB of the first byte is 1, this is a follow-on fragment, and the instructions are:</p>
|
||||
{% highlight lang='dataspec' %}
|
||||
+----+----+----+----+----+----+----+
|
||||
|frag| Message_ID | size |
|
||||
|frag| Message ID | size |
|
||||
+----+----+----+----+----+----+----+
|
||||
{% endhighlight %}
|
||||
|
||||
@ -275,7 +275,7 @@ frag ::
|
||||
nnnnnn is the 6 bit fragment number from 1 to 63
|
||||
d is 1 to indicate the last fragment, 0 otherwise
|
||||
|
||||
Message_ID ::
|
||||
Message ID ::
|
||||
4 bytes
|
||||
Identifies the fragment sequence that this fragment belongs to.
|
||||
This will match the message ID of an initial fragment (a fragment
|
||||
|
Reference in New Issue
Block a user