An RFC 2622 conformant Routing Policy Specification Language (RPSL) parser with a focus on speed and correctness.
โก๏ธ Outperforms other parsers by a factor of 33-60x
๐ฐ Complete implementation for multiline RPSL values
๐ฌ Able to parse objects directly from whois server responses
๐ง Low memory footprint by leveraging zero-copy
๐งช Robust parsing of any valid input ensured by Property Based Tests
๐ Python usage is supported
[!WARNING] This project is still in early stages of development and its API is not yet stable.
Examples
Parsing RPSL
A string containing an object in RPSL notation can be parsed to a rpsl::Object struct using the parse_rpsl_object function.
use parse_rpsl_object;
let role_acme = "
role: ACME Company
address: Packet Street 6
address: 128 Series of Tubes
address: Internet
email: rpsl-parser@github.com
nic-hdl: RPSL1-RIPE
source: RIPE
";
let parsed = parse_rpsl_object?;
This returns an rpsl::Object consisting of multiple rpsl::Attributes:
println!;
Object
Each rpsl::Attribute can be accessed by it's index and has a name and an optional set of values.
println!;
Attribute
Since RPSL attribute values may be spread over multiple lines and values consisting only of whitespace are valid, the Vec<Option<String>> type is used to represent them. For more information and examples, please view the parse_rpsl_object documentation.
Parsing a WHOIS server response
Whois servers often respond to queres with multiple objects.
An example ARIN query for AS32934 will return with the requested ASNumber object first, followed by it's associated OrgName:
To extract each individual object, the parse_whois_server_response function can be used to parse the response into a rpsl::ObjectCollection containing all objects within the response. Examples can be found in the function documentation.
Python bindings
To use this parser in Python, see the rpsl-parser PyPi Package.
๐ง Work in progress
-
More descriptive error messages
When invalid RPSL is parsed, the current error messages do not properly convey where exactly the error is located in the parsed text.