From 5878bd0695c925c442ab9a87dae7c11e511a44b7 Mon Sep 17 00:00:00 2001 From: ivynya Date: Tue, 26 Dec 2023 23:27:07 -0800 Subject: [PATCH] feat: use env variables for more stuff --- client/client.go | 9 ++++++--- server/server.go | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/client/client.go b/client/client.go index ce6b980..daf23c7 100644 --- a/client/client.go +++ b/client/client.go @@ -13,8 +13,11 @@ import ( // global environment variables var ( - auth = os.Getenv("AUTH") - identifier = os.Getenv("IDENTIFIER") + auth = os.Getenv("AUTH") + identifier = os.Getenv("IDENTIFIER") + illm_scheme = os.Getenv("ILLM_SCHEME") + illm_host = os.Getenv("ILLM_HOST") + illm_path = os.Getenv("ILLM_PATH") ) func main() { @@ -22,7 +25,7 @@ func main() { signal.Notify(interrupt, os.Interrupt) // authorize to an illm relay as a provider - u := url.URL{Scheme: "wss", Host: "io.ivy.direct", Path: "/aura/provider"} + u := url.URL{Scheme: illm_scheme, Host: illm_host, Path: illm_path} c, _, err := websocket.DefaultDialer.Dial(u.String(), http.Header{ "Authorization": []string{"Basic " + auth}, }) diff --git a/server/server.go b/server/server.go index 8ebc9bc..0a6f734 100644 --- a/server/server.go +++ b/server/server.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "log" + "os" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/basicauth" @@ -12,6 +13,11 @@ import ( gonanoid "github.com/matoous/go-nanoid/v2" ) +var ( + username = os.Getenv("USERNAME") + password = os.Getenv("PASSWORD") +) + func main() { clients := make(map[string]*websocket.Conn) providers := make(map[string]*websocket.Conn) @@ -19,7 +25,7 @@ func main() { app := fiber.New() app.Use(basicauth.New(basicauth.Config{ Users: map[string]string{ - "ivy-aura-admin": "GmW6Xd8vhUhK3XkARh4Z", + username: password, }, }))