mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 15:43:32 +01:00
Actually, write the torrc format in ABNF
This should make it more clear what I meant, if you know how to read ABNF. (Thanks to rl1987 for correcting numerous issues here)
This commit is contained in:
parent
7521c3ee91
commit
9d237bb00a
@ -14,68 +14,66 @@ does, not what it should do.
|
|||||||
|
|
||||||
1. File Syntax
|
1. File Syntax
|
||||||
|
|
||||||
# A file is interpreted as every Entry in the file, in order.
|
; The syntax here is defined an Augmented Backus-Naur form, as
|
||||||
TorrcFile = Line*
|
; specified in RFC5234.
|
||||||
|
|
||||||
Line = BlankLine | Entry
|
; A file is interpreted as every Entry in the file, in order.
|
||||||
|
TorrcFile = *Line
|
||||||
|
|
||||||
BlankLine = WS* OptComment LF
|
Line = BlankLine / Entry
|
||||||
| WS* LF
|
|
||||||
|
|
||||||
OptComment =
|
BlankLine = *WSP OptComment LF
|
||||||
| Comment
|
BlankLine =/ *WSP LF
|
||||||
|
|
||||||
Comment = '#' NonLF*
|
OptComment = [ Comment ]
|
||||||
|
|
||||||
# Each Entry is interpreted as an optional "Magic" flag, a key, and a
|
Comment = "#" *NonLF
|
||||||
# value.
|
|
||||||
Entry = SP* OptMagic Key (SP+ | '\\' NL SP*)+ Val LF
|
|
||||||
| SP* OptMagic Key (SP* | '\\' NL SP*)* LF
|
|
||||||
|
|
||||||
OptMagic =
|
; Each Entry is interpreted as an optional "Magic" flag, a key, and a
|
||||||
| "+"
|
; value.
|
||||||
| "/"
|
Entry = *WSP [ Magic ] Key 1*(1*WSP / "\" NL *WSP) Val LF
|
||||||
|
Entry =/ *WSP [ Magic ] Key *( *WSP / "\" NL *WSP) LF
|
||||||
|
|
||||||
# Keys are always specified verbatim. They are case insensitive. It
|
Magic = "+" / "/"
|
||||||
# is an error to specify a key that Tor does not recognize.
|
|
||||||
Key = KC*
|
|
||||||
|
|
||||||
# Sadly, every kind of value is decoded differently...
|
; Keys are always specified verbatim. They are case insensitive. It
|
||||||
Val = QuotedVal | ContinuedVal | PlainVal
|
; is an error to specify a key that Tor does not recognize.
|
||||||
|
Key = 1*KC
|
||||||
|
|
||||||
# The text of a PlainVal is the text of its PVBody portion,
|
; Sadly, every kind of value is decoded differently...
|
||||||
# plus the optional trailing backslash.
|
Val = QuotedVal / ContinuedVal / PlainVal
|
||||||
PlainVal = PVBody* ('\\')? SP* OptComment
|
|
||||||
|
|
||||||
# Note that a PVBody is copied verbatim. Slashes are included
|
; The text of a PlainVal is the text of its PVBody portion,
|
||||||
# verbatim. No changes are made. Note that a body may be empty.
|
; plus the optional trailing backslash.
|
||||||
PVBody = (VC | '\\' NonLF ) *
|
PlainVal = PVBody [ "\" ] *WSP OptComment
|
||||||
|
|
||||||
# The text of a ContinuedVal is the text of each of its PVBody
|
; Note that a PVBody is copied verbatim. Slashes are included
|
||||||
# sub-elements, in order, concatenated.
|
; verbatim. No changes are made. Note that a body may be empty.
|
||||||
ContinuedVal = CVal1 CVal2* CVal3
|
PVBody = * (VC / "\" NonLF )
|
||||||
|
|
||||||
CVal1 = PVBody '\\' LF
|
; The text of a ContinuedVal is the text of each of its PVBody
|
||||||
CVal2 = PVBody ( '\\' LF | Comment LF )
|
; sub-elements, in order, concatenated.
|
||||||
|
ContinuedVal = CVal1 *CVal2 CVal3
|
||||||
|
|
||||||
|
CVal1 = PVBody "\" LF
|
||||||
|
CVal2 = PVBody ( "\" LF / Comment LF )
|
||||||
CVal3 = PVBody
|
CVal3 = PVBody
|
||||||
|
|
||||||
# The text of a QuotedVal is decoded as if it were a C string.
|
; The text of a QuotedVal is decoded as if it were a C string.
|
||||||
QuotedVal = DQ QVBody DQ SP* Comment
|
QuotedVal = DQ QVBody DQ *WSP Comment
|
||||||
|
|
||||||
QVBody = QC
|
QVBody = QC
|
||||||
| '\\' ( 'n' | 'r' | 't' | '\\' | '\'' | DQ | 'x' XD XD | OD OD? OD? )
|
QVBody =/ "\" ( "n" / "r" / "t" / "\" / "'" / DQUOTE )
|
||||||
|
QVBOdy =/ "\" ( "x" 2HEXDIG / 1*3OCTDIG )
|
||||||
|
|
||||||
XD = any hexadecimal digit
|
; Anything besides NUL and LF
|
||||||
OD = any octal digit
|
NonLF = %x01-%x09 / %x0b - %xff
|
||||||
|
|
||||||
NonLF = Any character but '\n'
|
OCTDIG = '0' - '7'
|
||||||
LF = '\n' | EOF
|
|
||||||
WS = ' ' | '\t' | '\r'
|
KC = Any character except an isspace() character or '#' or NUL
|
||||||
SP = ' ' | '\t'
|
VC = Any character except '\\', '\n', '#', or NUL
|
||||||
DQ = '\"'
|
QC = Any character except '\n', '\\', '\"', or NUL
|
||||||
KC = Any character except an isspace() character or '#'
|
|
||||||
VC = Any character except '\\', '\n', or '#'
|
|
||||||
QC = Any character except '\n', '\\', or '\"'
|
|
||||||
|
|
||||||
2. Mid-level Semantics
|
2. Mid-level Semantics
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user