Fix connection issues in Mud client
This commit is contained in:
parent
e96dc58c87
commit
b171fbc3bf
1 changed files with 33 additions and 13 deletions
46
pud.org
46
pud.org
|
@ -2,7 +2,7 @@
|
||||||
#+author: Howard X. Abrams
|
#+author: Howard X. Abrams
|
||||||
#+date: 2025-01-18
|
#+date: 2025-01-18
|
||||||
#+filetags: emacs hamacs
|
#+filetags: emacs hamacs
|
||||||
#+lastmod: [2025-08-05 Tue]
|
#+lastmod: [2025-08-08 Fri]
|
||||||
|
|
||||||
A literate programming file for a Comint-based MUD client.
|
A literate programming file for a Comint-based MUD client.
|
||||||
|
|
||||||
|
@ -104,10 +104,27 @@ You will want to customize your connections to the connections, as this program
|
||||||
|
|
||||||
For instance, you could set up a call to =setopt= or customize the =pud-worlds= variable, as in:
|
For instance, you could set up a call to =setopt= or customize the =pud-worlds= variable, as in:
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp :tangle no :eval no
|
||||||
|
(use-package pud
|
||||||
|
:custom
|
||||||
|
(pud-worlds
|
||||||
|
'(["Remote Moss-n-Puddles" 'ssh "howardabrams.com" 4000 "bobby"]
|
||||||
|
; ↑ No password? Should be in .authinfo.gpg
|
||||||
|
|
||||||
|
["Local Root" 'telnet "localhost" 4000 "suzy" "some-pass"]
|
||||||
|
; ↑ This has the password in your custom settings.
|
||||||
|
|
||||||
|
; ↓ Password from authinfo, special connection string:
|
||||||
|
["Local User" 'telnet "localhost" 4000 "rick" nil "login %s %s"])))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
Or set up the customization in the =init.el= file:
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp :tangle no :eval no
|
#+BEGIN_SRC emacs-lisp :tangle no :eval no
|
||||||
(setopt pud-worlds
|
(setopt pud-worlds
|
||||||
'(["Moss-n-Puddles" ssh "howardabrams.com" 4004 "howard" "" "connect %s %s"]
|
'(["Moss-n-Puddles" ssh "howardabrams.com" 4004 "howard" "" "\\nconnect %s %s\\n"]
|
||||||
["Moss-n-Puddles" ssh "howardabrams.com" 4004 "rick" "" "connect %s %s"]
|
["Moss-n-Puddles" ssh "howardabrams.com" 4004 "rick" "" "\\nconnect %s %s\\n"]
|
||||||
|
["Moss-n-Puddles" ssh "howardabrams.com" 4004 "darol" "" "\\nconnect %s %s\\n"]
|
||||||
["Local-Moss" telnet "localhost" 4000 "howard" "" ""]
|
["Local-Moss" telnet "localhost" 4000 "howard" "" ""]
|
||||||
["Local-Moss" telnet "localhost" 4000 "rick" "" ""]))
|
["Local-Moss" telnet "localhost" 4000 "rick" "" ""]))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
@ -174,8 +191,9 @@ The following functions are accessibility functions to the world entry.
|
||||||
world))
|
world))
|
||||||
|
|
||||||
(defun pud-world-network (world)
|
(defun pud-world-network (world)
|
||||||
"Return the network details for WORLD as a cons cell (HOST . PORT)."
|
"Return the network details for WORLD as a list.
|
||||||
(list (aref world 2) (format "%s" (aref world 3))))
|
[Connect-Type Host Port]."
|
||||||
|
(list (aref world 1) (aref world 2) (format "%s" (aref world 3))))
|
||||||
|
|
||||||
(defun pud-world-creds (world)
|
(defun pud-world-creds (world)
|
||||||
"Return the username and password from WORLD.
|
"Return the username and password from WORLD.
|
||||||
|
@ -197,14 +215,14 @@ And some basic functions I should expand.
|
||||||
#+BEGIN_SRC emacs-lisp :tangle no
|
#+BEGIN_SRC emacs-lisp :tangle no
|
||||||
(ert-deftest pud-world-name-test ()
|
(ert-deftest pud-world-name-test ()
|
||||||
(should (string-equal (pud-world-name "foobar") "foobar"))
|
(should (string-equal (pud-world-name "foobar") "foobar"))
|
||||||
(should (string-equal (pud-world-name ["foobar" "localhost" "4000"]) "foobar"))
|
(should (string-equal (pud-world-name ["foobar" 'telnet "localhost" "4000"]) "foobar"))
|
||||||
(should (string-equal (pud-world-name ["foobar" "localhost" "4000" ""]) "foobar"))
|
(should (string-equal (pud-world-name ["foobar" 'telnet "localhost" "4000" nil]) "foobar"))
|
||||||
(should (string-equal (pud-world-name ["foobar" "localhost" "4000" nil]) "foobar"))
|
(should (string-equal (pud-world-name ["foobar" 'telnet "localhost" "4000" ""]) "foobar"))
|
||||||
(should (string-equal (pud-world-name ["foobar" "localhost" "4000" "guest" "guest"]) "guest@foobar")))
|
(should (string-equal (pud-world-name ["foobar" 'telnet "localhost" "4000" "guest" "guest"]) "guest@foobar")))
|
||||||
|
|
||||||
(ert-deftest pud-world-network-test ()
|
(ert-deftest pud-world-network-test ()
|
||||||
(should (equal (pud-world-network ["foobar" telnet "overthere" "4000" "guest" "guest"]) '("overthere" "4000")))
|
(should (equal (pud-world-network ["foobar" telnet "overthere" "4000" "guest" "guest"]) '(telnet "overthere" "4000")))
|
||||||
(should (equal (pud-world-network ["foobar" ssh "overthere" 4000 "guest" "guest"]) '("overthere" "4000"))))
|
(should (equal (pud-world-network ["foobar" ssh "overthere" 4000 "guest" "guest"]) '(ssh "overthere" "4000"))))
|
||||||
|
|
||||||
(ert-deftest pud-world-creds-test ()
|
(ert-deftest pud-world-creds-test ()
|
||||||
;; Test with no match in authinfo!
|
;; Test with no match in authinfo!
|
||||||
|
@ -253,8 +271,9 @@ Command string to use, given a =world= with a connection type:
|
||||||
(defun pud-cli-command (world)
|
(defun pud-cli-command (world)
|
||||||
"Return a command string to pass to the shell.
|
"Return a command string to pass to the shell.
|
||||||
The WORLD is a vector with the hostname, see `pud-worlds'."
|
The WORLD is a vector with the hostname, see `pud-worlds'."
|
||||||
(seq-let (host port) (pud-world-network world)
|
(seq-let (connection-type host port) (pud-world-network world)
|
||||||
(cl-case (aref world 1)
|
(message "Dealing with: %s %s %s" connection-type host port)
|
||||||
|
(cl-case connection-type
|
||||||
(telnet (append (cons pud-telnet-path pud-cli-arguments)
|
(telnet (append (cons pud-telnet-path pud-cli-arguments)
|
||||||
(list host port)))
|
(list host port)))
|
||||||
(ssh (append (cons pud-ssh-path pud-cli-arguments)
|
(ssh (append (cons pud-ssh-path pud-cli-arguments)
|
||||||
|
@ -318,6 +337,7 @@ The main entry point to the program is the =pud-run= function:
|
||||||
(process (get-buffer-process buffer)))
|
(process (get-buffer-process buffer)))
|
||||||
;; if the process is dead then re-create the process and reset the
|
;; if the process is dead then re-create the process and reset the
|
||||||
;; mode.
|
;; mode.
|
||||||
|
(message "Gonna %s with %s" (car pud-cli) (cdr pud-cli))
|
||||||
(unless proc-alive
|
(unless proc-alive
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(apply 'make-comint-in-buffer "Pud" buffer (car pud-cli) nil (cdr pud-cli))
|
(apply 'make-comint-in-buffer "Pud" buffer (car pud-cli) nil (cdr pud-cli))
|
||||||
|
|
Loading…
Reference in a new issue