object_server and object_client
The database object server example tools: store and read objects, and ask for vector searches (Linux and Windows).
Usage
object_server PORT CERT KEY CA CLIENT_CN DB_NAME DB_FILE [--stop-file FILE] object_client HOST PORT SERVER_NAME CERT KEY CA DB_NAME "text" object_client HOST PORT SERVER_NAME CERT KEY CA DB_NAME --vinfo object_client HOST PORT SERVER_NAME CERT KEY CA DB_NAME --vsearch K < query (whitespace separated floats)
object_server serves one database with mutual TLS (only CLIENT_CN may connect). object_client stores a text object and reads it back, or with --vinfo / --vsearch asks a server whose database names its vectors (a gxObjectDbConfig with vectors) for the index's description or the K nearest to the query on stdin. The requests: Object Server Vector Searches; a complete program: vector_search_service.
Stopping the server: Ctrl+C, or TERM on Linux; Ctrl+C, Ctrl+Break or closing the console on Windows; or, on both, creating the file given with --stop-file (checked every second; a service wrapper or a script uses this). Clients get up to 10 seconds to finish. Windows (7.4): the same programs over Winsock and Schannel, and they work with Linux servers and clients both ways. The multiplex never blocks on a TLS write, so two sides that both send large messages at once do not wait on each other (gxdbmux_test both_ways_large_tls checks this on both systems).
Examples
Test certificates for mutual TLS: a CA, a server certificate for localhost and a client certificate with the CN app1 (testing only):
openssl req -x509 -newkey rsa:2048 -nodes -keyout ca.key -out ca.pem -days 30 -subj "/CN=Test CA" openssl req -newkey rsa:2048 -nodes -keyout server.key -out server.csr -subj "/CN=localhost" printf "subjectAltName=DNS:localhost,IP:127.0.0.1\n" > san.ext openssl x509 -req -in server.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out server.pem -days 30 -extfile san.ext openssl req -newkey rsa:2048 -nodes -keyout client.key -out client.csr -subj "/CN=app1" openssl x509 -req -in client.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out client.pem -days 30
Serve the database notes (file notes.gxd) on port 39871 to the client app1 only, and stop when the file stop.now appears:
$ object_server 39871 server.pem server.key ca.pem app1 notes notes.gxd --stop-file stop.now & serving database notes on port 39871
Store two objects and read each back:
$ object_client localhost 39871 localhost client.pem client.key ca.pem notes "first note" stored 10 bytes at address 128 read back: first note $ object_client localhost 39871 localhost client.pem client.key ca.pem notes "second note" stored 11 bytes at address 170 read back: second note
A database the server does not serve, and a vector request to a database without vectors, are refused (exit 1):
$ object_client localhost 39871 localhost client.pem client.key ca.pem other "x" no database other $ object_client localhost 39871 localhost client.pem client.key ca.pem notes --vinfo vinfo: the server refused the request
Stop the server:
$ touch stop.now stop file stop.now seen stopped