Commit 87c3f9da authored by David Byers's avatar David Byers
Browse files

Added support for SSH proxies

parent 91dab964
2002-06-22 David Byers <david.byers@swipnet.se>
* startup.el (lyskom): Renamed all proxy-* variables to
www-proxy-*. Changed open-network-stream to
lyskom-open-network-stream in order to support ssh proxies.
(lyskom-open-network-stream): New function.
(lyskom-setup-ssh-proxy): New function.
(lyskom): Use lyskom-open-network-stream to open network
connections.
2002-06-14 David Byers <david.byers@swipnet.se>
* review.el (kom-toggle-mark-as-read-prefix): New function toggles
state of kom-review-marks-as-read and then runs one single command
with the state toggled.
2002-06-21 Joel Rosdahl <joel@lysator.liu.se>
* swedish-strings.el, english-strings.el: kom-change-language no
......
......@@ -1220,7 +1220,24 @@ Don't ask for confirmation."
(lyskom-insert-string (lyskom-get-string-sol 'session-ended))
(lyskom-scroll)
(setq mode-line-process (lyskom-get-string 'mode-line-down))
(run-hooks 'kom-quit-hook))
(run-hooks 'kom-quit-hook)
(when (boundp 'lyskom-ssh-proxy)
(let* ((numleft (1- (get lyskom-ssh-proxy 'num-connected)))
(procname (symbol-name lyskom-ssh-proxy))
(bufname (concat " *" procname "*"))
(proc (get-process procname)))
(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"))
(delete-process proc)
(when (get-buffer bufname)
(save-excursion
(set-buffer bufname)
(goto-char (point-max))
(insert "\n--- closed connection ---\n")))))))
;;; ================================================================
......
......@@ -653,7 +653,7 @@ Read all about it at http://www.lysator.liu.se/history/")
(member-of-confs . "Member of (conferences):%18#1d\n")
(presentation . "Presentation: %25#1n\n")
(show-membership-list-also-q . "List memberships? ")
(not-allowed-see-confs . "You are not permitted to see which conferences %#1P is a member of.\n")
(not-allowed-see-confs . "%#1P is not a member of any conferences.\n")
(is-member-of . "\n%#1P is a member of the following conferences:\n")
(membership-list-header . "Last access Unread Conference\n\n")
(pers-membership-line . "%#1s%#2s%#3M %#4s\n")
......@@ -1782,6 +1782,9 @@ have been removed, you can fix the problem by giving the command
(aux-world-readable-name . "World-readable")
(aux-elisp-client-read-faq-name . "Read FAQ")
(aux-elisp-client-rejected-invitation-name . "Rejected invitation")
(review-marking-as-read . "Review marks as read")
(review-not-marking-as-read . "Review does not mark as read")
))
......@@ -2216,6 +2219,8 @@ have been removed, you can fix the problem by giving the command
(define-key lyskom-en-mode-map (kbd "b") 'lyskom-en-previous-prefix)
(define-key lyskom-en-mode-map (kbd "w") 'lyskom-en-who-prefix)
(define-key lyskom-en-mode-map (kbd "M-m") 'kom-toggle-mark-as-read-prefix)
(define-key lyskom-en-mode-map (kbd (lyskom-keys 'button2)) 'kom-button-click)
(define-key lyskom-en-mode-map (kbd (lyskom-keys 'button3)) 'kom-popup-menu)
(define-key lyskom-en-mode-map (kbd (lyskom-keys 'button2up)) 'kom-mouse-null)
......
......@@ -1096,36 +1096,17 @@ that, starts a new one."
(let* ((url-string (if (memq window-system '(win32 mswindows w32))
(list url)
(list "-n"
(format "%s" url))))
(proc (apply 'start-process "galeon"
nil
(if (listp kom-galeon-command)
(car kom-galeon-command)
kom-galeon-command)
(if (listp kom-galeon-command)
(append (cdr kom-galeon-command)
url-string)
url-string)))
(status 'run)
(exit nil))
(format "%s" url)))))
(lyskom-url-manager-starting manager)
(while (eq status 'run)
(accept-process-output)
(setq status (process-status proc)))
(setq exit (process-exit-status proc))
(cond ((and (eq status 'exit)
(eq exit 1))
(apply 'start-process "galeon"
nil
(if (listp kom-galeon-command)
(car kom-galeon-command)
kom-galeon-command)
(if (listp kom-galeon-command)
(append (cdr kom-galeon-command)
(list url))
(list url))))
(t nil))))
(apply 'start-process "galeon"
nil
(if (listp kom-galeon-command)
(car kom-galeon-command)
kom-galeon-command)
(if (listp kom-galeon-command)
(append (cdr kom-galeon-command)
url-string)
url-string))))
;; Added by Peter Liljenberg
(defun lyskom-view-url-lynx (url manager)
......
......@@ -73,6 +73,25 @@
(delq 0 (copy-sequence a)))
;;; ================================================================
;;; Temoporary change of mark-as-read
(defun kom-toggle-mark-as-read-prefix ()
"Read one key sequence and run one command with state of
kom-review-marks-texts-as-read toggled."
(interactive)
(let* ((kom-review-marks-texts-as-read (not kom-review-marks-texts-as-read))
(sequence (read-key-sequence
(format "%s: "
(lyskom-get-string
(if kom-review-marks-texts-as-read
'review-marking-as-read
'review-not-marking-as-read)))))
(command (lookup-key (current-local-map) sequence)))
(when (commandp command)
(call-interactively command))))
;;; ================================================================
;;; ]terse av, till - Review by X to Conference Y.
......
......@@ -158,27 +158,27 @@ clients of the event. See lyskom-mode for details on lyskom."
(t
(setq buffer (lyskom-generate-new-buffer host))
(setq name (buffer-name buffer))))
(let* ((proxy-host-string
(let* ((www-proxy-host-string
(cond ((stringp kom-www-proxy) kom-www-proxy)
((listp kom-www-proxy)
(or (cdr (lyskom-string-assoc host kom-www-proxy))
(cdr (assq t kom-www-proxy))
nil))
(t nil)))
(proxy-host nil)
(proxy-port nil)
(www-proxy-host nil)
(www-proxy-port nil)
(match (string-match "\\(.*\\):\\([0-9]+\\)"
(or proxy-host-string "")))
(or www-proxy-host-string "")))
(headers nil))
(setq proxy-host (or (and match
(match-string 1 proxy-host-string))
proxy-host-string)
proxy-port (or (and match
(setq www-proxy-host (or (and match
(match-string 1 www-proxy-host-string))
www-proxy-host-string)
www-proxy-port (or (and match
(string-to-int
(match-string 2
proxy-host-string)))
www-proxy-host-string)))
80))
(cond (proxy-host
(cond (www-proxy-host
(setq headers
(cond ((stringp kom-www-proxy-headers)
(list kom-www-proxy-headers))
......@@ -187,12 +187,12 @@ clients of the event. See lyskom-mode for details on lyskom."
kom-www-proxy-headers)
((and (listp kom-www-proxy-headers)
(consp (car kom-www-proxy-headers)))
(cdr (or (lyskom-string-assoc proxy-host
(cdr (or (lyskom-string-assoc www-proxy-host
kom-www-proxy-headers)
(assq t kom-www-proxy-headers))))))
(setq proc (open-network-stream name buffer
proxy-host
proxy-port))
(setq proc (lyskom-open-network-stream name buffer
www-proxy-host
www-proxy-port))
;; We do explicit coding
(set-process-coding-system proc 'no-conversion 'no-conversion)
......@@ -227,8 +227,8 @@ clients of the event. See lyskom-mode for details on lyskom."
(accept-process-output proc))
;; Now the proxy has connected to the kom server
)
(t (setq proc (open-network-stream name buffer
host port))
(t (setq proc (lyskom-open-network-stream name buffer
host port))
;; We do explicit coding
(set-process-coding-system proc 'no-conversion 'no-conversion))))
(switch-to-buffer buffer)
......@@ -343,6 +343,73 @@ clients of the event. See lyskom-mode for details on lyskom."
(string-match "^\r\n" output))
(set-process-filter proc 'lyskom-connect-filter))))
(defun lyskom-open-network-stream (name buffer host service)
(let ((relay (lyskom-setup-ssh-relay host service buffer)))
(if relay
(open-network-stream name
buffer
"127.0.0.1"
(get relay 'relay-port))
(open-network-stream name
buffer
host
service))))
(defun lyskom-setup-ssh-relay (server port kom-buffer)
(when kom-ssh-relay-host
(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))))
(unwind-protect
(save-excursion
(set-buffer (get-buffer-create bufname))
(if relay-port
(message (setq msg (concat "Using" msg)))
(when proc (delete-process proc))
(setq relay-port (+ 10000 (random 20000)))
(put procsym 'relay-host
(if (string-match "@" kom-ssh-relay-host)
(substring kom-ssh-relay-host (1+ (match-beginning 0)))
kom-ssh-relay-host))
(put procsym 'relay-port relay-port)
(put procsym 'num-connected 0)
(message (setq msg (concat "Opening" msg)))
(goto-char (point-max))
(insert "\n--- new connection ---\n")
(setq proc (start-process
procname
bufname
"ssh" "-n" "-x"
"-L" (format "%d:%s:%d" relay-port server port)
kom-ssh-relay-host
"sh -c \"while :; do echo ok; sleep 600; done\""))
(process-kill-without-query proc))
(while (progn
(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)))))
(sleep-for 0.5))
(setq proc nil)
(message (concat msg "done")))
(if proc (delete-process proc)))
(save-excursion
(set-buffer kom-buffer)
(put procsym 'num-connected (1+ (or (get procsym 'num-connected) 0)))
(make-local-variable 'lyskom-ssh-proxy)
(setq lyskom-ssh-proxy procsym))
)))
(defun lyskom-setup-client-for-server-version ()
......@@ -365,57 +432,6 @@ clients of the event. See lyskom-mode for details on lyskom."
(lyskom-set-feature long-conf-types t))))
;;;(defun lyskom-setup-client-check-version (spec version)
;;; (let ((relation (elt spec 0))
;;; (major (elt spec 1))
;;; (minor (elt spec 2))
;;; (revision (elt spec 3)))
;;; (cond ((eq relation '=)
;;; (and (or (null major) (= major (elt version 0)))
;;; (or (null minor) (= minor (elt version 1)))
;;; (or (null revision) (= revision (elt version 2)))))
;;; ((eq relation '>=)
;;; (or (and (= (elt version 0) major)
;;; (= (elt version 1) minor)
;;; (>= (elt version 2) revision))
;;; (and (= (elt version 0) major)
;;; (> (elt version 1) minor))
;;; (and (> (elt version 0) major))))
;;; ((eq relation '<)
;;; (or (and (= (elt version 0) major)
;;; (= (elt version 1) minor)
;;; (< (elt version 2) revision))
;;; (and (= (elt version 0) major)
;;; (< (elt version 1) minor))
;;; (and (< (elt version 0) major)))))))
;;;(defun lyskom-setup-client-for-server-version ()
;;; "Set up the supports list and flags for the current server. See
;;;variable documentation for lyskom-server-feautres"
;;; (let ((result nil)
;;; (flags nil))
;;; (mapcar (function
;;; (lambda (spec)
;;; (let ((spec-version (elt spec 0))
;;; (plist (elt spec 1)))
;;; (if (and (lyskom-setup-client-check-version
;;; spec-version
;;; lyskom-server-version))
;;; (mapcar
;;; (function
;;; (lambda (x)
;;; (cond ((consp x) (setq result (cons x result)))
;;; ((symbolp x) (setq flags (cons x flags)))
;;; (t (setq result (cons (cons x t)
;;; result))))))
;;; plist)))))
;;; lyskom-server-features)
;;; (mapcar (function (lambda (x) (set x t))) flags)
;;; (setq lyskom-server-supports result)))
(defun lyskom-connect-filter (proc output)
"Receive connection acknowledgement from server."
(if lyskom-debug-communications-to-buffer
......
......@@ -635,7 +635,7 @@ i svensk datorhistoria. L
(member-of-confs . "Medlem i (antal mten):%18#1d\n")
(presentation . "Presentation: %24#1n\n")
(show-membership-list-also-q . "Vill du se vilka mten personen r medlem i ocks? ")
(not-allowed-see-confs . "Du fr inte se vilka mten %#1P r medlem i.\n")
(not-allowed-see-confs . "%#1P r inte medlem i ngra mten.\n")
(is-member-of . "\n%#1P r medlem i fljande mten:\n")
(membership-list-header . "Senast inne Osett Namn\n\n")
(pers-membership-line . "%#1s%#2s%#3M %#4s\n")
......@@ -1794,7 +1794,9 @@ kommandot \"Spara variabler\".\n\n")
(aux-world-readable-name . "Lsbart utan inloggning")
(aux-elisp-client-read-faq-name . "Lst FAQ")
(aux-elisp-client-rejected-invitation-name . "Avvisad inbjudan")
(review-marking-as-read . "terse lsmarkerar")
(review-not-marking-as-read . "terse lsmarkerar inte")
))
(lyskom-language-var local lyskom-month-names sv
......@@ -2242,6 +2244,8 @@ kommandot \"Spara variabler\".\n\n")
(define-key lyskom-sv-mode-map [] 'lyskom-sv-review-prefix)
(define-key lyskom-sv-mode-map [] 'lyskom-sv-review-prefix)
(define-key lyskom-sv-mode-map (kbd "M-m") 'kom-toggle-mark-as-read-prefix)
(define-key lyskom-sv-mode-map (kbd (lyskom-keys 'button2)) 'kom-button-click)
(define-key lyskom-sv-mode-map (kbd (lyskom-keys 'button3)) 'kom-popup-menu)
(define-key lyskom-sv-mode-map (kbd (lyskom-keys 'button2up)) 'kom-mouse-null)
......
......@@ -1111,6 +1111,18 @@ time in some places. If nil, only include minutes and hours."
This variable will eventually be replaced with something else."
server)
(def-kom-var kom-ssh-relay-host nil
"*Host to which the session is to be tunneled through ssh through.
For this to work, ssh to the host must succeed without asking for a
password or passphrase.
Note: Storing this variable in the LysKOM server makes no sense.")
(def-kom-var lyskom-ssh-proxy nil
"When non-nil, the ssh proxy used for this buffer."
local
protected)
(def-kom-var kom-www-proxy nil
"*Non-nil indicates a WWW proxy to use for the connection.
This is useful behind a firewall if the proxy supports the CONNECT
......
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