removed port from config (for now)

This commit is contained in:
2021-12-30 23:53:46 +01:00
parent 4559f2b67e
commit 1dc1b9c351

View File

@@ -17,7 +17,6 @@ module Kotatsu
conf = JSON.build do |json|
json.object do
json.field "config_version", 1
json.field "port", 8080
json.field "title", "Kotatsu"
json.field "services" do
json.array do
@@ -39,12 +38,11 @@ module Kotatsu
end
#Writes the config file in JSON format
def self.writeConfig(version, port, title, services)
def self.writeConfig(version, title, services)
i = 0
conf = JSON.build do |json|
json.object do
json.field "config_version", version
json.field "port", port
json.field "title", title
json.field "services" do
json.array do
@@ -67,7 +65,6 @@ module Kotatsu
def self.readConfig()
conf = JSON.parse(File.read(CONFIG_FILE))
version = conf["config_version"].as_i
port = conf["port"].as_i
title = conf["title"].as_s
t_services = conf["services"].as_a
services = [] of Array(String)
@@ -76,7 +73,7 @@ module Kotatsu
services << [conf["services"][i][0].as_s, conf["services"][i][1].as_s, conf["services"][i][2].as_s]
i+=1
end
return version, port, title, services
return version, title, services
end
#Checks if config dir exists and then creates a config file
@@ -138,7 +135,7 @@ module Kotatsu
parser.on "add", "Add a service" do
if File.exists?(CONFIG_FILE) == true
version, port, title, services = readConfig()
version, title, services = readConfig()
print "Name: "
s_name = gets.to_s
print "Link: "
@@ -155,7 +152,7 @@ module Kotatsu
end
services_new << s_service
writeConfig(version, port, title, services_new)
writeConfig(version, title, services_new)
exit
else
STDERR.puts "ERROR! Config file not found: #{CONFIG_FILE}"
@@ -165,7 +162,7 @@ module Kotatsu
parser.on "list", "Lists all services" do
if File.exists?(CONFIG_FILE) == true
_, _, _, services = readConfig()
_, _, services = readConfig()
i = 0
while services.size > i
puts "##{i}: #{services[i][0]} ; #{services[i][1]} ; #{services[i][2]}"
@@ -194,7 +191,7 @@ module Kotatsu
end
#Reads config file
c_version, c_port, c_title, c_services = readConfig()
c_version, c_title, c_services = readConfig()
webcontent = makeContent(c_title, c_services)
@@ -203,7 +200,7 @@ module Kotatsu
context.response.content_type = "text/html"
context.response << webcontent
end
webaddr = webserv.bind_tcp c_port
webaddr = webserv.bind_tcp 8080
puts "Started kotatsu webserver on #{webaddr}"
webserv.listen
end