• Stars
    star
    171
  • Rank 222,266 (Top 5 %)
  • Language
    C
  • License
    Other
  • Created over 14 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fast persistent nosql database with a HTTP/JSON interface, not only for geographical data.

Pincaster

Pincaster is an in-memory, persistent data store for geographic data and key/dictionary pairs, with replication and a HTTP/JSON interface.

Client libraries

Schema overview

  • A Pincaster database contains a set of independent layers.

  • A layer is a namespace and a geographic space (flat or spherical). Each layer stores dynamic records.

  • A record is uniquely identified by a name and can hold either:

    1. No related value (void type).
    2. A set of key/value pairs (properties, or hash type). Values are binary-safe and can be freely and atomically updated and deleted.
    3. A geographic location (point type) defined by a latitude and a longitude.
    4. A set of key/value pairs and a geographic location (point+hash type).

    A layer can store records of arbitrary sizes and types.

    Records can automatically expire.

Installation

./configure
make install

Review the pincaster.conf configuration file and run:

pincaster /path/to/pincaster.conf

Layers

  • Registering a new layer:

    Method: POST

    URI: http://$HOST:4269/api/1.0/layers/(layer name).json

  • Deleting a layer:

    Method: DELETE

    URI: http://$HOST:4269/api/1.0/layers/(layer name).json

  • Retrieving registered layers:

    Method: GET

    URI: http://$HOST:4269/api/1.0/layers/index.json

Records

  • Creating or updating a record:

    Method: PUT

    URI: http://$HOST:4269/api/1.0/records/(layer name)/(record name).json

    This PUT request can contain application/x-www-form-urlencoded data, in order to create/update arbitrary properties.

    Property names starting with an underscore are reserved. In particular:

    • _delete:(property name)=1 removes a property of the record,
    • _delete_all=1 removes the whole properties set of the record, downgrading its type to void or point,
    • _add_int:(property name)=(value) atomically adds (value) to the property named (property name), creating it if necessary,
    • _loc:(latitude),(longitude) adds or updates a geographic position associated with the record.
    • _expires_at=(unix timestamp) have the record automatically expire at this date. If you later want to remove the expiration of a record, just use _expires_at= (empty value) or _expires_at=0.

    A single request can create/change/delete any number of properties.

  • Retrieving a record:

    Method: GET

    URI: http://$HOST:4269/api/1.0/records/(layer name)/(record name).json

  • Deleting a record:

    Method: DELETE

    URI: http://$HOST:4269/api/1.0/records/(layer name)/(record name).json

Geographic search

  • Finding records whose location is within a radius:

    Method: GET

    URI: http://$HOST:4269/api/1.0/search/(layer name)/nearby/(center point).json?radius=(radius, in meters)

    The center point is defined as latitude,longitude.

    Additional arguments can be added to this query:

    • limit=(max number of results that once reached, will return an overflow)
    • properties=(0 or 1) in order to include properties or not in the reply.
  • Finding records whose location is within a rectangle:

    Method: GET

    URI: http://$HOST:4269/api/1.0/search/(layer name)/in_rect/(l0,L0,l1,L1).json

    Additional arguments can be added to this query:

    • limit=(max number of results that once reached, will return an overflow)
    • properties=(0 or 1) in order to include properties or not in the reply.

Range queries

Keys are indexed with a RB-tree, and they are always pre-sorted in lexical order.

Hence, retrieving keys matching a prefix is a very fast operation.

  • Finding keys matching a prefix:

    Method: GET

    URI: http://$HOST:4269/api/1.0/search/(layer name)/keys/(prefix)*.json

    This retrieves every key starting with (prefix). If the final * character is omitted, an exact matching is performed instead of a prefix matching.

    Additional arguments can be added to this query:

    • limit=(max number of results) - please note that the default limit is 250 in order to avoid returning kazillions objects in case of an erroneous query. If you need to retrieve more, don't forget to explicitly set this argument.
    • content=(0 or 1) in order to retrieve only a list of keys, or full objects.
    • properties=(0 or 1) in order to include properties or not in the reply.

Relations through symbolic links

Relations between records can be stored as properties whose key name starts with $link: and whose value is the key of another record.

While retrieving a specific record, and in geographical and range queries, adding links=1 will automatically traverse links and recursively retrieve every linked record.

The server will take care of avoiding loops and duplicate records.

Results contain an additional property named $links containing found symlinked records.

Serving documents

Pincaster can also act like a web server and directly serve documents stored in keys.

In order to be accesible this way, a key:

  • must have a $content property whose value holds the content that has to be served
  • may have a $content_type property with the Content-Type.

The default Content-Type currently is text/plain.

  • Public data from layer (layer name) and key (key) is reachable at:

    Method: GET

    URI: http://$HOST:4269/public/(layer name)/(key)

Having a HTTP proxy between Pincaster and untrusted users is highly recommended in order to serve public data.

Misc

  • Ping:

    Method: any

    URI: http://$HOST:4269/api/1.0/system/ping.json

  • Shutting the server down:

    Method: POST

    URI: http://$HOST:4269/api/1.0/system/shutdown.json

  • Compacting the journal:

    The on-disk journal is an append-only file that logs every transaction that creates or changes data.

    In order to save disk space and to speed up the server start up, a new and optimized journal can be written by a background process. Once this operation is complete, the new journal will automatically replace the previous file.

    This is something you might want to run as a cron job.

    Method: POST

    URI: http://$HOST:4269/api/1.0/system/rewrite.json

Example

Command-line example with curl:

Register a new layer called "restaurants":

$ curl -dx http://diz:4269/api/1.0/layers/restaurants.json
{
	"tid": 1,
	"status": "created"
}

Check the list of active layers:

$ curl http://diz:4269/api/1.0/layers/index.json
{
	"tid": 2,
	"layers": [
		{
			"name": "restaurants",
			"records": 0,
			"geo_records": 0,
			"type": "ellipsoidal",
			"distance_accuracy": "fast",
			"latitude_accuracy": 0.0001,
			"longitude_accuracy": 0.0001,
			"bounds": [
				-90,
				-180,
				90,
				180
			]
		}
	]
}

Now let's add a hash record called "info". Just a set of key/values with no geographic data:

$ curl -XPUT -d'secret_key=supersecret&last_update=2001/07/08' http://diz:4269/api/1.0/records/restaurants/info.json
{
	"tid": 3,
	"status": "stored"
}

What does the record look like?

$ curl http://diz:4269/api/1.0/records/restaurants/info.json
{
	"tid": 4,
	"key": "info",
	"type": "hash",
	"properties": {
		"secret_key": "supersecret",
		"last_update": "2001/07/08"
	}
}

Let's add a McDonald's, just with geographic data:

$ curl -XPUT -d'_loc=48.512,2.243' http://diz:4269/api/1.0/records/restaurants/abcd.json
{
	"tid": 5,
	"status": "stored"
}

What does the "abcd" record of the "restaurants" layer look like?

$ curl http://diz:4269/api/1.0/records/restaurants/abcd.json
{
	"tid": 6,
	"key": "abcd",
	"type": "point",
	"latitude": 48.512,
	"longitude": 2.243
}

Let's add some properties to this record, like a name, the fact that it's currently closed, an address and an initial number of visits:

$ curl -XPUT -d'name=MacDonalds&closed=1&address=blabla&visits=100000' http://diz:4269/api/1.0/records/restaurants/abcd.json
{
	"tid": 7,
	"status": "stored"
}

Let's check it:

$ curl http://diz:4269/api/1.0/records/restaurants/abcd.json
{
	"tid": 8,
	"key": "abcd",
	"type": "point+hash",
	"latitude": 48.512,
	"longitude": 2.243,
	"properties": {
		"name": "MacDonalds",
		"closed": "1",
		"address": "blabla",
		"visits": "100000"
	}
}

Atomically delete the "closed" property from this record and add 127 visits:

$ curl -XPUT -d'_delete:closed=1&_add_int:visits=127' http://diz:4269/api/1.0/records/restaurants/abcd.json
{
	"tid": 9,
	"status": "stored"
}

Now let's look for records whose location is near N 48.510 E 2.240, within a 7 kilometers radius:

$ curl http://diz:4269/api/1.0/search/restaurants/nearby/48.510,2.240.json?radius=7000
{
	"tid": 10,
	"matches": [
		{
			"distance": 313.502,
			"key": "abcd",
			"type": "point+hash",
			"latitude": 48.512,
			"longitude": 2.243,
			"properties": {
				"name": "MacDonalds",
				"address": "blabla",
				"visits": "100127"
			}
		}
	]
}

And what's in a rectangle, without properties?

$ curl http://diz:4269/api/1.0/search/restaurants/in_rect/48.000,2.000,49.000,3.000.json?properties=0
{
	"tid": 11,
	"matches": [
		{
			"distance": 20254.9,
			"key": "abcd",
			"type": "point+hash",
			"latitude": 48.512,
			"longitude": 2.243
		}
	]
}

What about adding a HTML document to the abcd record?

$ curl -XPUT -d'$content=%3Chtml%3E%3Cbody%3E%3Ch1%3EHello+world%3C%2Fh1%3E%3C%2Fbody%3E%3C%2Fhtml%3E&$content_type=text/html' http://diz:4269/api/1.0/records/restaurants/abcd.json

(feel free to replace $ with %24 if you feel pedantic. These examples use the unencoded character for the sake of being easily readable).

Now point your web browser to:

http://diz:4269/public/restaurants/abcd

And enjoy the web page!

Now, what about storing a record about Donald Duck, whose favorite restaurant is this very Mac Donald's:

curl -XPUT -d'first_name=Donald&last_name=Duck&$link:favorite_restaurant=abcd' http://diz:4269/api/1.0/records/restaurants/donald.json

As expected, Donald's record looks like:

$ curl http://diz:4269/api/1.0/records/restaurants/donald.json
{
	"tid": 21,
	"key": "donald",
	"type": "hash",
	"properties": {
		"first_name": "Donald",
		"last_name": "Duck",
		"$link:favorite_restaurant": "abcd"
	}
}

Here's the same query, with a twist: links traversal. Properties starting with $link are resolved, retrieved and send back with the query result as a $links property:

$ curl http://diz:4269/api/1.0/records/restaurants/donald.json?links=1
{
	"tid": 22,
	"key": "donald",
	"type": "hash",
	"properties": {
		"first_name": "Donald",
		"last_name": "Duck",
		"$link:favorite_restaurant": "abcd"
	},
	"$links": {
		"abcd": {
			"key": "abcd",
			"type": "point+hash",
			"latitude": 48.512,
			"longitude": 2.243,
			"properties": {
				"name": "MacDonalds",
				"address": "blabla",
				"visits": "100127",
				"$content": "<html><body><h1>Hello world</h1></body></html>",
				"$content_type": "text/html"
			}
		}
	}
}

Let's delete the Mac Donald's record:

$ curl -XDELETE http://diz:4269/api/1.0/records/restaurants/abcd.json
{
	"tid": 12,
	"status": "deleted"
}

And shut the server down:

$ curl -XPOST http://diz:4269/api/1.0/system/shutdown.json

But can it ping?

$ curl http://diz:4269/api/1.0/system/ping.json

No, it can't any more, boo-ooh!

More Repositories

1

libsodium

A modern, portable, easy to use crypto library.
C
12,131
star
2

dsvpn

A Dead Simple VPN.
C
5,068
star
3

piknik

Copy/paste anything over the network.
Go
2,342
star
4

minisign

A dead simple tool to sign files and verify digital signatures.
C
1,856
star
5

libsodium.js

libsodium compiled to Webassembly and pure JavaScript, with convenient wrappers.
HTML
899
star
6

libhydrogen

A lightweight, secure, easy-to-use crypto library suitable for constrained environments.
C
599
star
7

pure-ftpd

Pure FTP server
C
589
star
8

libsodium-php

The PHP extension for libsodium.
C
546
star
9

swift-sodium

Safe and easy to use crypto for iOS and macOS
C
518
star
10

edgedns

A high performance DNS cache designed for Content Delivery Networks
Rust
490
star
11

libpuzzle

A library to quickly find visually similar images
C
262
star
12

iptoasn-webservice

Web service to map IP addresses to AS information, using iptoasn.com
Rust
254
star
13

dnsblast

A simple and stupid load testing tool for DNS resolvers
C
233
star
14

as-wasi

An AssemblyScript API layer for WASI system calls.
TypeScript
232
star
15

rust-jwt-simple

A secure, standard-conformant, easy to use JWT implementation for Rust.
Rust
222
star
16

wasm-crypto

A WebAssembly (via AssemblyScript) set of cryptographic primitives for building authentication and key exchange protocols.
TypeScript
214
star
17

rust-bloom-filter

A fast Bloom filter implementation in Rust
Rust
187
star
18

encpipe

The dum^H^H^Hsimplest encryption tool in the world.
C
182
star
19

UCarp

UCARP allows a couple of hosts to share common virtual IP addresses in order to provide automatic failover. It is a portable userland implementation of the secure and patent-free Common Address Redundancy Protocol (CARP, OpenBSD's alternative to the patents-bloated VRRP).
M4
170
star
20

blacknurse

BlackNurse attack PoC
C
170
star
21

libsodium-doc

Gitbook documentation for libsodium
Shell
166
star
22

bitbar-dnscrypt-proxy-switcher

BitBar plugin to control dnscrypt-proxy usage
Shell
148
star
23

charm

A really tiny crypto library.
C
148
star
24

witx-codegen

WITX code and documentation generator for AssemblyScript, Zig, Rust and more.
Rust
134
star
25

siphash-js

A Javascript implementation of SipHash-2-4
JavaScript
122
star
26

rust-ed25519-compact

Small, wasm-friendly, zero-dependencies Ed25519 and X25519 implementation for Rust.
Rust
120
star
27

rsign2

A command-line tool to sign files and verify signatures in pure Rust.
Rust
112
star
28

go-minisign

Minisign verification library for Golang.
Go
103
star
29

rust-nats

A simple NATS client library for Rust
Rust
102
star
30

zigly

The easiest way to write services for Fastly's Compute@Edge in Zig.
Zig
84
star
31

was-not-wasm

A hostile memory allocator to make WebAssembly applications more predictable.
Rust
81
star
32

webassembly-benchmarks

Libsodium WebAssembly benchmarks results.
79
star
33

rust-minisign

A pure Rust implementation of the Minisign signature tool.
Rust
78
star
34

zig-charm

A Zig version of the Charm crypto library.
Zig
74
star
35

rust-ffmpeg-wasi

ffmpeg 7 libraries precompiled for WebAsembly/WASI, as a Rust crate.
Rust
67
star
36

openssl-wasm

OpenSSL 3 compiled for WebAssembly/WASI (up-to-date, maintained)
C
66
star
37

rust-sthash

Very fast cryptographic hashing for large messages.
Rust
65
star
38

vtun

A mirror of VTUN, with some changes
C
63
star
39

iptrap

A simple, but damn fast sinkhole
Rust
62
star
40

boringssl-wasm

BoringSSL for WebAssembly/WASI
Zig
59
star
41

libsodium-signcryption

Signcryption using libsodium.
C
59
star
42

wasmsign

A tool to add and verify digital signatures to/from WASM binaries
Rust
56
star
43

libaegis

Portable C implementations of the AEGIS family of high-performance authenticated encryption algorithms.
C
56
star
44

blobcrypt

Authenticated encryption for streams and arbitrary large files using libsodium
C
54
star
45

rust-coarsetime

Time and duration crate optimized for speed
Rust
52
star
46

zig-minisign

Minisign reimplemented in Zig.
Zig
50
star
47

rust-siphash

SipHash (2-4, 1-3 + 128 bit variant) implementations for Rust
Rust
48
star
48

6Jack

A framework for analyzing/testing/fuzzing network applications.
C
46
star
49

rust-hyperloglog

A HyperLogLog implementation in Rust.
Rust
46
star
50

libchloride

Networking layer for libsodium, based on CurveCP
C
44
star
51

rust-qptrie

A qp-trie implementation in Rust
Rust
42
star
52

minicsv

A tiny, fast, simple, single-file, BSD-licensed CSV parsing library in C.
C
39
star
53

spake2-ee

A SPAKE2+ Elligator Edition implementation for libsodium 1.0.16+
C
36
star
54

massresolver

Mass DNS resolution tool
C
36
star
55

cpace

A CPace PAKE implementation using libsodium.
C
35
star
56

aegis-X

The AEGIS-128X and AEGIS-256X high performance ciphers.
Zig
34
star
57

rust-privdrop

A simple Rust crate to drop privileges
Rust
34
star
58

PureDB

PureDB is a portable and tiny set of libraries for creating and reading constant databases.
C
33
star
59

libclang_rt.builtins-wasm32.a

The missing libclang_rt.builtins-wasm32.a file to compile to WebAssembly.
32
star
60

c-ipcrypt

ipcrypt implementation in C
C
31
star
61

rust-dnsclient

A simple and secure DNS client crate for Rust.
Rust
29
star
62

rust-xoodyak

Xoodyak, a lightweight and versatile cryptographic scheme implemented in Rust.
Rust
29
star
63

fastly-terrarium-examples

Example code you can run in Fastly Terrarium: https://www.fastlylabs.com/
C
28
star
64

libsodium-xchacha20-siv

Deterministic/nonce-reuse resistant authenticated encryption scheme using XChaCha20, implemented on libsodium.
C
28
star
65

rust-geoip

GeoIP bindings for Rust
Rust
28
star
66

rust-minisign-verify

A small Rust crate to verify Minisign signatures.
Rust
27
star
67

whatsmyresolver

A tiny DNS server that returns the client (resolver) IP
Go
26
star
68

libsodium-sys-stable

Sodiumoxide's libsodium-sys crate, but that installs stable versions of libsodium.
Rust
26
star
69

spritz

A C implementation of Spritz, a spongy RC4-like stream cipher and hash function.
C
25
star
70

metrohash-c

C version of the MetroHash function
C
25
star
71

rust-hmac-sha256

A small, self-contained SHA256 and HMAC-SHA256 implementation.
Rust
25
star
72

rust-cpace

A Rust implementation of CPace, a balanced PAKE.
Rust
25
star
73

rust-clockpro-cache

CLOCK-Pro cache replacement algorithm for Rust
Rust
24
star
74

rust-blind-rsa-signatures

RSA blind signatures in Rust
Rust
24
star
75

PHP-OAuth2-Provider

Skyrock OAuth2 server
PHP
23
star
76

rust-aegis

AEGIS high performance ciphers for Rust.
Rust
23
star
77

system-tuning-for-crypto

System tuning recommendations for running cryptographic applications
23
star
78

hashseq

A simple proof of work, mainly designed to mitigate DDoS attacks.
C
23
star
79

dnssector

A DNS library for Rust.
Rust
23
star
80

openssl-family-bench

A quick benchmark of {Open,Libre,Boring}SSL
C
23
star
81

randen-rng

A port of the Google Randen fast backtracking-resistant random generator to the C language.
C
21
star
82

Blogbench

A filesystem benchmark tool that simulates a realistic load
C
21
star
83

vue-dnsstamp

DNS Stamp calculator component for VueJS
Vue
21
star
84

supercop

Always up-to-date mirror of the SUPERCOP cryptographic benchmark.
C
21
star
85

yaifo

YAIFO [remote OpenBSD installer] for OpenBSD-current
Shell
21
star
86

ratelimit

Plug-and-play IP rate limiter in C
C
21
star
87

draft-aegis-aead

The AEGIS cipher family - Draft.
20
star
88

go-hpke-compact

A small and easy to use HPKE implementation in Go.
Go
20
star
89

ipgrep

Extract, defang, resolve names and IPs from text
Python
20
star
90

zig-rocca-s

An implementation of the ROCCA-S encryption scheme.
Zig
19
star
91

Simple-Comet-Server

HTTP long-polling server and javascript client library.
Python
19
star
92

simpira384

An AES-based 384 bit permutation.
C
18
star
93

PHP-WebDAV-extension

The PHP WebDAV extension allows easy access to remote resources with PHP through the DAV protocol.
Shell
18
star
94

nonce-extension

Make AES-GCM safe to use with random nonces, for any practical number of messages.
Rust
17
star
95

rust-sealed_box

Sealed boxes implementation for Rust/WebAssembly.
Rust
16
star
96

zig-eddsa-key-blinding

A Zig implementation of EdDSA signatures with blind keys.
Zig
16
star
97

c-blind-rsa-signatures

Blind RSA signatures for OpenSSL/BoringSSL.
C
16
star
98

aes-torture

A software AES implementation to torture code generators.
C
16
star
99

js-base64-ct

Safe Base64 encoding/decoding in pure JavaScript.
TypeScript
16
star
100

rust-aes-wasm

Fast(er) AES-based constructions for WebAssembly and Rust.
Rust
16
star