Following the libipc master branch.

ipc07
Karchnu 2020-07-13 14:43:19 +02:00
parent 7e1277e2d1
commit 28c30b110d
3 changed files with 14 additions and 13 deletions

View File

@ -26,7 +26,7 @@ targets:
auth-user-search:
main: utils/authd-user-search.cr
crystal: 0.31
crystal: 0.35.1
dependencies:
grok:

View File

@ -169,9 +169,9 @@ class AuthD::Response
end
end
class IPC::Connection
def send(response : AuthD::Response)
send response.type.to_u8, response.to_json
class IPC::Context
def send(fd, response : AuthD::Response)
send fd, response.type.to_u8, response.to_json
end
end
@ -369,14 +369,14 @@ class AuthD::Request
end
end
class IPC::Connection
def send(request : AuthD::Request)
send request.type.to_u8, request.to_json
class IPC::Context
def send(fd, request : AuthD::Request)
send fd, request.type.to_u8, request.to_json
end
end
module AuthD
class Client < IPC::Connection
class Client < IPC::Client
property key : String
def initialize

View File

@ -51,7 +51,7 @@ class AuthD::Service
uid
end
def handle_request(request : AuthD::Request?, connection : IPC::Connection)
def handle_request(request : AuthD::Request?)
case request
when Request::GetToken
begin
@ -454,7 +454,8 @@ class AuthD::Service
def run
##
# Provides a JWT-based authentication scheme for service-specific users.
IPC::Service.new "auth" do |event|
server = IPC::Server.new "auth"
server.loop do |event|
if event.is_a? IPC::Exception
puts "oh no"
pp! event
@ -462,15 +463,15 @@ class AuthD::Service
end
case event
when IPC::Event::Message
when IPC::Event::MessageReceived
begin
request = Request.from_ipc event.message
info "<< #{request.class.name.sub /^Request::/, ""}"
response = handle_request request, event.connection
response = handle_request request
event.connection.send response
server.send event.fd, response
rescue e : MalformedRequest
error "#{e.message}"
error " .. type was: #{e.ipc_type}"