Sighting DB is designed to scale writing and reading a count of attributes, tracking when if was first and last seen.
- Make sure you have Rust and Cargo installed
- Run ''make''
To run from the source directory:
- Generate a certificate:
cd etc; mkdir ssl; cd ssl; openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout key.pem -out cert.pem; cd ../..
ln -s etc/ssl ssl
ln -s etc/sighting-daemon.ini sighting-daemon.ini
- Start the Sighting DB: ./target/debug/sighting-daemon
The b64 command is just formating the string as base64 URL with no padding, it is build as part of this program, or you can make your own.
$ curl -k https://localhost:9999/w/my/namespace/?val=$(b64 127.0.0.1)
{"message":"ok"}
$ curl -k https://localhost:9999/w/another/namespace/?val=$(b64 127.0.0.1)
{"message":"ok"}
$ curl -k https://localhost:9999/w/another/namespace/?val=$(b64 127.0.0.1)
{"message":"ok"}
$ curl -k https://localhost:9999/r/my/namespace/?val=$(b64 127.0.0.1)
{"value":"127.0.0.1","first_seen":1566624658,"last_seen":1566624658,"source":"unknown","source_timestamp":1566624658,"count":1}
$ curl -k https://localhost:9999/w/another/namespace/?val=$(b64 127.0.0.1)
{"value":"127.0.0.1","first_seen":1566624686,"last_seen":1566624689,"source":"unknown","source_timestamp":1566624686,"count":2}
Default storage is a simple tree which contains the path + value. The path is usually the type of value, such as a host, an IP address, a hash etc.
We do a XOR on the available machines with the first four bytes of our value in order to avoid using a consensus to read and write our data. This allow a blazingly fast access to our values.
This is a slow operation which requires to re-XOR our values in order to move the appropriate ones to the new node. We take only one thread for this so the DB is still fast, new writes go directly to the new node, while read is first fetch to the new node and then looked on the original node handling them if the data has not been moved.