zoossh
is a parser written in Go for Tor-specific data formats. In case you
are wondering, "zoossh" is the sound it makes when such documents are parsed!
Though admittedly, the speed mostly comes from zoossh
being implemented in a
compiled language and not because the parsing code is particularly
sophisticated.
At this point, zoossh
should not be used in practice because the APIs are not
yet stable.
The following file formats are currently partially supported. For more information about file formats, have a look at CollecTor.
- Server descriptors (
@type server-descriptor 1.0
) - Network status consensuses (
@type network-status-consensus-3 1.0
)
Here's how you can parse a network status document and iterate over all relay statuses:
consensus, err := zoossh.ParseConsensusFile(fileName)
if err != nil {
// Handle error.
}
for status := range consensus.Iterate() {
fmt.Println(status)
}
Similarly, here's how you can parse a file containing server descriptors:
descriptors, err := zoossh.ParseDescriptorFile(fileName)
if err != nil {
// Handle error.
}
for desc := range descriptors.Iterate() {
fmt.Println(desc)
}
Check out the Python library Stem
or the Java
library metrics-lib
.
Contact: Philipp Winter phw@nymity.ch
OpenPGP fingerprint: B369 E7A2 18FE CEAD EB96 8C73 CF70 89E3 D7FD C0D0