updated config and added tls support

This commit is contained in:
wt
2025-05-30 01:48:44 +07:00
parent 6375fc028e
commit 1080c8fcd9
2 changed files with 21 additions and 2 deletions
+8 -1
View File
@@ -1,3 +1,10 @@
USERS_FILE=users.json
USERS_DB=users.db
ENABLE_SELF_REGISTER=false
ENABLE_SELF_REGISTER=false
ENABLE_TLS=false
CERT_FILE=/home/tola/certs/localhost/localhost.crt
KEY_FILE=/home/tola/certs/localhost/localhost.key
SERVER_ADDRESS=localhost
SERVER_PORT=8090
+13 -1
View File
@@ -39,5 +39,17 @@ func main() {
http.HandleFunc("/api/users/change", users.ChangeUser)
http.HandleFunc("/api/users/del", users.DelUser)
http.HandleFunc("/api/users/add", users.AddUser)
http.ListenAndServe(":8090", nil)
if os.Getenv("ENABLE_TLS") == "true" {
http.ListenAndServeTLS(
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
os.Getenv("CERT_FILE"),
os.Getenv("KEY_FILE"),
nil,
)
} else {
http.ListenAndServe(
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
nil,
)
}
}