From ab0137230f661a76e66797ad3f8e19512ad55fab Mon Sep 17 00:00:00 2001 From: Jakub Date: Sat, 9 May 2026 13:02:17 +0800 Subject: [PATCH] Clean up the URLs a bit --- gomuks.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gomuks.el b/gomuks.el index bd68a71..d724169 100644 --- a/gomuks.el +++ b/gomuks.el @@ -43,6 +43,11 @@ :type 'string :group 'gomuks) +(defcustom gomuks-base-url "localhost:29325" + "The base URL for the Gomuks backend, only IP address and port required." + :type 'string + :group 'gomuks) + (defun gomuks-server-start () "Start the gomuks server process" (interactive) @@ -57,11 +62,10 @@ (kill-process gomuks-server-name) (notifications-notify :title "Gomuks Server Closed" :app-name "gomuks.el")) -(defvar gomuks-url "http://localhost:29325") -(defvar gomuks-auth-endpoint (concat gomuks-url "/_gomuks/auth")) -(defvar gomuks-auth-cookie ) +(defvar gomuks-auth-endpoint (concat "http://" gomuks-base-url "/_gomuks/auth")) +(defvar gomuks-auth-cookie) -(defvar gomuks-ws-endpoint (concat gomuks-url "/_gomuks/websocket")) +(defvar gomuks-ws-endpoint (concat "ws://" gomuks-base-url "/_gomuks/websocket")) (defun gomuks-connect (gomuks-username) "Opens a websocket connection with the specified gomuks endpoint" @@ -76,6 +80,7 @@ (base64-encode-string (concat gomuks-username ":" gomuks-password)))))) (sleep-for 0.5) + ;; TODO: this needs to select domain dynamically, instead of hardcoding a string here (cdar (request--netscape-get-cookies request--curl-cookie-jar "localhost" "/_gomuks" t))))) (setq gomuks-ping-timer (run-with-timer 0 @@ -84,7 +89,7 @@ (message "pinging") (websocket-send-text gomuks-websocket "{\"command\":\"ping\"}")))) - (setq gomuks-websocket (websocket-open "ws://localhost:29325/_gomuks/websocket" + (setq gomuks-websocket (websocket-open gomuks-ws-endpoint :custom-header-alist `(("Cookie" . ,(concat "gomuks_auth=" gomuks-auth-cookie))) :on-message (lambda (_ws frame)