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: auth-user-search:
main: utils/authd-user-search.cr main: utils/authd-user-search.cr
crystal: 0.31 crystal: 0.35.1
dependencies: dependencies:
grok: grok:

View File

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

View File

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