-
Notifications
You must be signed in to change notification settings - Fork 0
/
service
executable file
·42 lines (35 loc) · 1.13 KB
/
service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/./lib"))
require 'repository_service'
tcp = RepositoryService.start
print "Starting Repository Server\n"
print "I will listen... for now.\n"
while (sock = tcp.accept)
Thread.start do
begin
RepositoryService.load_grammar
server = RepositoryService::Server.new(sock, RepositoryService.policy_file)
client = RepositoryService::Client.new(sock)
client.credentials server
server.challenges client
client.responds server
until client.finished?
client.requests server
server.replies client
end
sock.shutdown
print "We're done here.\n"
rescue RepositoryService::ClientException
sock.shutdown
print "\nClient Performed and Invalid Action. Connection Closed.\n"
print "#{$!}\n"
rescue EOFError
sock.shutdown
print "\nClient Disconnected.\n"
rescue
sock.shutdown
print "Exception Occured: #{$!}\n#{$!.backtrace.join("\n")}"
print "\nConnection Closed.\n"
end
end
end