mirror of
https://git.ragorasplace.com/Ragora/Old_LIT2.git
synced 2026-03-24 10:09:07 +00:00
78 lines
1.4 KiB
Ruby
Executable file
78 lines
1.4 KiB
Ruby
Executable file
"""
|
|
Experimental Thing
|
|
"""
|
|
|
|
require 'socket'
|
|
require './crypto.rb'
|
|
require './certstore.rb'
|
|
certstore_loadAccounts()
|
|
|
|
handle = File.new("auth.key", "r")
|
|
$AuthKey = handle.read()
|
|
handle.close()
|
|
|
|
def t2csri_verify_auth_signature(s)
|
|
return rsa_mod_exp(s.to_i(16), 3, $AuthKey.to_i(16));
|
|
end
|
|
|
|
def cmp(one, two)
|
|
if(one == two)
|
|
return 1
|
|
end
|
|
return 0
|
|
end
|
|
|
|
# Start the Server
|
|
server = TCPServer.new("127.0.0.1", 2000)
|
|
print("Running LIT2Serv on 127.0.0.1:2000 ....\n")
|
|
|
|
$OutPath = ENV['HOME'] + "/.loki/tribes2/base/lit2.txt"
|
|
File.open($OutPath, "w") { |handle| handle.close() }
|
|
|
|
# Setup the permissions such that only owner can read
|
|
File.chmod(0600, $OutPath)
|
|
|
|
begin
|
|
loop {
|
|
$Client = server.accept
|
|
|
|
done = false
|
|
$Buffer = ""
|
|
while not done do
|
|
$Buffer += $Client.recv(8)
|
|
|
|
if ($Buffer.index("<END>") != nil)
|
|
buffer_split = $Buffer.split("<END>")
|
|
|
|
$Buffer = buffer_split[1]
|
|
if ($Buffer == nil)
|
|
$Buffer = ""
|
|
end
|
|
|
|
result = buffer_split[0]
|
|
if (result == nil)
|
|
next
|
|
end
|
|
|
|
begin
|
|
handle = File.new($OutPath, "w")
|
|
File.chmod(0600, $OutPath)
|
|
$Result = eval(result)
|
|
handle.write($Result)
|
|
handle.write("<END>")
|
|
handle.close()
|
|
rescue StandardError => e
|
|
handle.write(e.message)
|
|
handle.write("<END>")
|
|
handle.close()
|
|
end
|
|
|
|
done = true
|
|
end
|
|
end
|
|
$Client.close()
|
|
}
|
|
rescue Interrupt
|
|
print("Closing lit2 server...\n")
|
|
File.delete($OutPath)
|
|
end
|