From 2192f44ffc79545be10e97c85a51d3976f732cd1 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Wed, 1 Feb 2023 20:32:21 +0100 Subject: [PATCH] Crystal bindings: authd compiles. --- .../some-crystal-app/authd/libclient.cr | 2 +- .../crystal/some-crystal-app/authd/main.cr | 7 +++++-- zig-impl/crystal/some-crystal-app/makefile | 13 ++++++++++--- zig-impl/crystal/some-crystal-app/shard.yml | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/zig-impl/crystal/some-crystal-app/authd/libclient.cr b/zig-impl/crystal/some-crystal-app/authd/libclient.cr index 072e0ce..6318549 100644 --- a/zig-impl/crystal/some-crystal-app/authd/libclient.cr +++ b/zig-impl/crystal/some-crystal-app/authd/libclient.cr @@ -1,4 +1,4 @@ -require "ipc/json" +require "../src/json" module AuthD class Client < IPC diff --git a/zig-impl/crystal/some-crystal-app/authd/main.cr b/zig-impl/crystal/some-crystal-app/authd/main.cr index d4e8bb4..ae12f5f 100644 --- a/zig-impl/crystal/some-crystal-app/authd/main.cr +++ b/zig-impl/crystal/some-crystal-app/authd/main.cr @@ -42,7 +42,7 @@ class AuthD::Service < IPC property last_uid_file : String def initialize(@configuration) - super + super() @users = DODB::DataBase(User).new @configuration.storage @users_per_uid = @users.new_index "uid", &.uid.to_s @@ -81,7 +81,10 @@ class AuthD::Service < IPC def handle_request(event : IPC::Event) request_start = Time.utc - request = AuthD.requests.parse_ipc_json event.message.not_nil! + array = event.message.not_nil! + slice = Slice.new array.to_unsafe, array.size + message = IPCMessage::TypedMessage.deserialize slice + request = AuthD.requests.parse_ipc_json message.not_nil! if request.nil? raise "unknown request type" diff --git a/zig-impl/crystal/some-crystal-app/makefile b/zig-impl/crystal/some-crystal-app/makefile index 4866368..981f587 100644 --- a/zig-impl/crystal/some-crystal-app/makefile +++ b/zig-impl/crystal/some-crystal-app/makefile @@ -15,11 +15,18 @@ valgrind: run: LD_LIBRARY_PATH=$(LDPATH) $(SRC) -run-pongd: - LD_LIBRARY_PATH=$(LDPATH) ./bin/pongd - build-pongd: CRYSTAL_LIBRARY_PATH=$(LDPATH) shards build pongd +run-pongd: + LD_LIBRARY_PATH=$(LDPATH) ./bin/pongd + +build-authd: + CRYSTAL_LIBRARY_PATH=$(LDPATH) shards build authd + +run-authd: + LD_LIBRARY_PATH=$(LDPATH) ./bin/authd + + run-test: crystal run src/libauth.cr diff --git a/zig-impl/crystal/some-crystal-app/shard.yml b/zig-impl/crystal/some-crystal-app/shard.yml index 6ed8707..86e0ddf 100644 --- a/zig-impl/crystal/some-crystal-app/shard.yml +++ b/zig-impl/crystal/some-crystal-app/shard.yml @@ -9,7 +9,25 @@ targets: main: src/main.cr pongd: main: src/pongd.cr + authd: + main: authd/main.cr crystal: 1.7.1 +dependencies: + grok: + github: spinscale/grok.cr + passwd: + git: https://git.baguette.netlib.re/Baguette/passwd.cr + branch: master + jwt: + github: crystal-community/jwt + branch: master + baguette-crystal-base: + git: https://git.baguette.netlib.re/Baguette/baguette-crystal-base + branch: master + dodb: + git: https://git.baguette.netlib.re/Baguette/dodb.cr + branch: master + license: MIT