Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow TLS connections (and other) #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions rcirc.el
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ and the cdr part is used for encoding."
:type 'function
:group 'rcirc)

(defcustom rcirc-default-connect-function 'open-network-stream
"Function used to initiate a connection.
It should take the same arguments as `open-network-stream' does."
:group 'rcirc
:type 'function)

(defvar rcirc-nick nil)

(defvar rcirc-prompt-start-marker nil)
Expand Down Expand Up @@ -429,6 +435,7 @@ If ARG is non-nil, instead prompt for connection parameters."
rcirc-default-user-name))
(full-name (or (plist-get (cdr c) :full-name)
rcirc-default-full-name))
(connect-function (plist-get (cdr c) :connect-function))
(channels (plist-get (cdr c) :channels))
(password (plist-get (cdr c) :password)))
(when server
Expand All @@ -439,7 +446,8 @@ If ARG is non-nil, instead prompt for connection parameters."
(if (not connected)
(condition-case e
(rcirc-connect server port nick user-name
full-name channels password)
full-name channels password
connect-function)
(quit (message "Quit connecting to %s" server)))
(with-current-buffer (process-buffer connected)
(setq connected-servers
Expand Down Expand Up @@ -471,7 +479,8 @@ If ARG is non-nil, instead prompt for connection parameters."

;;;###autoload
(defun rcirc-connect (server &optional port nick user-name
full-name startup-channels password)
full-name startup-channels password
connect-function)
(save-excursion
(message "Connecting to %s..." server)
(let* ((inhibit-eol-conversion)
Expand All @@ -483,8 +492,9 @@ If ARG is non-nil, instead prompt for connection parameters."
(nick (or nick rcirc-default-nick))
(user-name (or user-name rcirc-default-user-name))
(full-name (or full-name rcirc-default-full-name))
(connect-function (or connect-function rcirc-default-connect-function))
(startup-channels startup-channels)
(process (make-network-process :name server :host server :service port-number)))
(process (funcall connect-function server nil server port-number)))
;; set up process
(set-process-coding-system process 'raw-text 'raw-text)
(switch-to-buffer (rcirc-generate-new-buffer-name process nil))
Expand Down Expand Up @@ -698,7 +708,7 @@ Function is called with PROCESS, COMMAND, SENDER, ARGS and LINE.")
"Send PROCESS a STRING plus a newline."
(let ((string (concat (encode-coding-string string rcirc-encode-coding-system)
"\n")))
(unless (eq (process-status process) 'open)
(unless (member (process-status process) '(open run))
(error "Network connection to %s is not open"
(process-name process)))
(rcirc-debug process string)
Expand Down