Following the libipc master branch.
This commit is contained in:
parent
7e1277e2d1
commit
28c30b110d
@ -26,7 +26,7 @@ targets:
|
||||
auth-user-search:
|
||||
main: utils/authd-user-search.cr
|
||||
|
||||
crystal: 0.31
|
||||
crystal: 0.35.1
|
||||
|
||||
dependencies:
|
||||
grok:
|
||||
|
14
src/authd.cr
14
src/authd.cr
@ -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
|
||||
|
11
src/main.cr
11
src/main.cr
@ -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}"
|
||||
|
Loading…
Reference in New Issue
Block a user