Commit 3d2177cf authored by David Byers's avatar David Byers
Browse files

Fixed bug 258: Implementera kom-över-ssh

parent 87c3f9da
......@@ -1230,8 +1230,11 @@ Don't ask for confirmation."
(put lyskom-ssh-proxy 'num-connected numleft)
(when (and (<= numleft 0) proc)
(string-match "^ssh<\\([^:]*\\)" procname)
(message "Closing ssh connection to %s"
(or (match-string 1 procname) "unknown host"))
(lyskom-message
"%s"
(lyskom-format 'ssh-closing
(or (match-string 1 procname)
(lyskom-get-string 'ssh-unknown-host))))
(delete-process proc)
(when (get-buffer bufname)
(save-excursion
......
......@@ -1785,6 +1785,12 @@ have been removed, you can fix the problem by giving the command
(review-marking-as-read . "Review marks as read")
(review-not-marking-as-read . "Review does not mark as read")
(using-ssh-connection . "Using ssh connection to %#1s...")
(opening-ssh-connection . "Opening ssh connection to %#1s...")
(ssh-cant-connect . "Unable to open ssh connection: %s")
(ssh-closnig . "Closing ssh connection to %#1s")
(ssh-unknown-host . "unknown host")
))
......
......@@ -361,16 +361,19 @@ clients of the event. See lyskom-mode for details on lyskom."
(let* ((procname (format "ssh<%s:%s:%d>" kom-ssh-relay-host server port))
(bufname (concat " *" procname "*"))
(proc (get-process procname))
(msg (concat " ssh connection to " kom-ssh-relay-host "..."))
(procsym (intern procname))
(relay-port (and proc
(eq (process-status proc) 'run)
(get procsym 'relay-port))))
(get procsym 'relay-port)))
(msg nil))
(unwind-protect
(save-excursion
(set-buffer (get-buffer-create bufname))
(if relay-port
(message (setq msg (concat "Using" msg)))
(lyskom-message
"%s"
(lyskom-format (setq msg 'using-ssh-connection)
kom-ssh-relay-host))
(when proc (delete-process proc))
(setq relay-port (+ 10000 (random 20000)))
(put procsym 'relay-host
......@@ -379,7 +382,10 @@ clients of the event. See lyskom-mode for details on lyskom."
kom-ssh-relay-host))
(put procsym 'relay-port relay-port)
(put procsym 'num-connected 0)
(message (setq msg (concat "Opening" msg)))
(lyskom-message
"%s"
(lyskom-format (setq msg 'opening-ssh-connection)
kom-ssh-relay-host))
(goto-char (point-max))
(insert "\n--- new connection ---\n")
(setq proc (start-process
......@@ -394,14 +400,25 @@ clients of the event. See lyskom-mode for details on lyskom."
(goto-char (point-max))
(re-search-backward "^--- .* ---$" nil t)
(not (re-search-forward "^ok$" nil t)))
(if (re-search-forward "\\<refused\\|error\\|key not found\\>" nil t)
(error "Couldn't connect: %s"
(buffer-substring-no-properties
(progn (beginning-of-line) (point))
(progn (skip-chars-forward "^\n\r") (point)))))
(when (re-search-forward "\\<\\(Enter passphrase.*$\\|^.*password.*$\\)\\|refused\\|disconnect\\|denied\\|error\\|key not found\\>" nil t)
(cond ((match-string 1)
(process-send-string
proc
(concat (silent-read (match-string 1)) "\n"))
(delete-region (match-beginning 0)
(match-end 0)))
(t (error (lyskom-get-string 'ssh-cant-connect)
(buffer-substring-no-properties
(progn (beginning-of-line) (point))
(progn (skip-chars-forward "^\n\r")
(point)))))))
(sleep-for 0.5))
(setq proc nil)
(message (concat msg "done")))
(lyskom-message
"%s"
(lyskom-format (concat
(lyskom-format msg kom-ssh-relay-host)
(lyskom-get-string 'done)))))
(if proc (delete-process proc)))
(save-excursion
......
......@@ -1797,6 +1797,12 @@ kommandot \"Spara variabler\".\n\n")
(review-marking-as-read . "terse lsmarkerar")
(review-not-marking-as-read . "terse lsmarkerar inte")
(using-ssh-connection . "Anvnder ssh-uppkoppling till %#1s...")
(opening-ssh-connection . "ppnar ssh-uppkoppling till %#1s...")
(ssh-cant-connect . "Kan inte gra ssh-uppkopplingen: %s")
(ssh-closnig . "Stnger ssh-uppkopplingen till %#1s")
(ssh-unknown-host . "oknd vrd")
))
(lyskom-language-var local lyskom-month-names sv
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment