dnsmanager v2, initial commit
commit
b4c4588416
|
@ -0,0 +1,4 @@
|
|||
shard.lock
|
||||
bin
|
||||
drop
|
||||
lib
|
|
@ -0,0 +1,22 @@
|
|||
name: dnsmanager
|
||||
version: 0.1.0
|
||||
|
||||
authors:
|
||||
- karchnu <karchnu@karchnu.fr>
|
||||
|
||||
description: |
|
||||
A registrar tool.
|
||||
|
||||
dependencies:
|
||||
ipc:
|
||||
git: https://git.karchnu.fr/WeirdOS/ipc.cr
|
||||
dodb:
|
||||
git: https://git.karchnu.fr/WeirdOS/dodb.cr
|
||||
authd:
|
||||
git: https://git.karchnu.fr/WeirdOS/authd
|
||||
|
||||
targets:
|
||||
dnsmanager:
|
||||
main: src/main.cr
|
||||
|
||||
license: MIT
|
|
@ -0,0 +1,29 @@
|
|||
require "http/server"
|
||||
require "option_parser"
|
||||
|
||||
require "authd"
|
||||
|
||||
service_name = "dnsmanager"
|
||||
verbosity = 1
|
||||
authd_key_file = nil
|
||||
|
||||
require "./parser"
|
||||
|
||||
begin
|
||||
authd = AuthD::Client.new
|
||||
authd.key = File.read(Context.authd_key_file.not_nil!).chomp
|
||||
|
||||
server = HTTP::Server.new do |context|
|
||||
context.response.content_type = "text/plain"
|
||||
pp! context.request
|
||||
context.response.print "Hello. New version of DNSManager, soon."
|
||||
end
|
||||
|
||||
address = server.bind_tcp Context.activation_server_port
|
||||
puts "Listening on http://#{address}"
|
||||
server.listen
|
||||
|
||||
rescue e
|
||||
puts "Error: #{e}"
|
||||
exit 1
|
||||
end
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
class Context
|
||||
class_property verbosity = 1
|
||||
class_property authd_key_file : String? = nil
|
||||
class_property activation_server_port : Int32 = 9000
|
||||
end
|
||||
|
||||
|
||||
OptionParser.parse do |parser|
|
||||
|
||||
parser.on "-v verbosity-level", "--verbosity level", "Verbosity." do |opt|
|
||||
Context.verbosity = opt.to_i
|
||||
end
|
||||
|
||||
parser.on "-p port", "--port port", "Listening port." do |port|
|
||||
Context.activation_server_port = port.to_i
|
||||
end
|
||||
|
||||
parser.on "-K key-file", "--key-file file", "Key file." do |opt|
|
||||
Context.authd_key_file = opt
|
||||
end
|
||||
|
||||
parser.on "-h", "--help", "Show this help" do
|
||||
puts parser
|
||||
exit 0
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue