]> code.delx.au - gnu-emacs/blobdiff - lisp/net/network-stream.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / net / network-stream.el
index b0d479f948e515577b7976f26ec96a6eae14ba1b..c2845d96a5db788319a60e63b84fc2e6097a5c56 100644 (file)
@@ -65,8 +65,8 @@ BUFFER is a buffer or buffer name to associate with the process.
  Process output goes at end of that buffer.  BUFFER may be nil,
  meaning that the process is not associated with any buffer.
 HOST is the name or IP address of the host to connect to.
-SERVICE is the name of the service desired, or an integer specifying
- a port number to connect to.
+SERVICE is the name of the service desired, or an integer or
integer string specifying a port number to connect to.
 
 The remaining PARAMETERS should be a sequence of keywords and
 values:
@@ -203,6 +203,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
 
 ;;;###autoload
 (defalias 'open-protocol-stream 'open-network-stream)
+(define-obsolete-function-alias 'open-protocol-stream 'open-network-stream
+  "25.2")
 
 (defun network-stream-open-plain (name buffer host service parameters)
   (let ((start (with-current-buffer buffer (point)))
@@ -310,6 +312,9 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
                                        :host (puny-encode-domain host)
                                         :service service))
            (network-stream-get-response stream start eoc)))
+        (unless (process-live-p stream)
+          (error "Unable to negotiate a TLS connection with %s/%s"
+                 host service))
        ;; Re-get the capabilities, which may have now changed.
        (setq capabilities
              (network-stream-command stream capability-command eo-capa))))
@@ -372,27 +377,29 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
                                     (plist-get parameters :nowait))
               (open-tls-stream name buffer host service)))
           (eoc (plist-get parameters :end-of-command)))
-      ;; Check certificate validity etc.
-      (when (and (gnutls-available-p) stream)
-       (setq stream (nsm-verify-connection stream host service)))
-      (if (null stream)
-         (list nil nil nil 'plain)
-       ;; If we're using tls.el, we have to delete the output from
-       ;; openssl/gnutls-cli.
-       (when (and (not (gnutls-available-p))
-                  eoc)
-         (network-stream-get-response stream start eoc)
-         (goto-char (point-min))
-         (when (re-search-forward eoc nil t)
-           (goto-char (match-beginning 0))
-           (delete-region (point-min) (line-beginning-position))))
-       (let ((capability-command (plist-get parameters :capability-command))
-             (eo-capa (or (plist-get parameters :end-of-capability)
-                          eoc)))
-         (list stream
-               (network-stream-get-response stream start eoc)
-               (network-stream-command stream capability-command eo-capa)
-               'tls))))))
+      (if (plist-get parameters :nowait)
+          (list stream nil nil 'tls)
+        ;; Check certificate validity etc.
+        (when (and (gnutls-available-p) stream)
+          (setq stream (nsm-verify-connection stream host service)))
+        (if (null stream)
+            (list nil nil nil 'plain)
+          ;; If we're using tls.el, we have to delete the output from
+          ;; openssl/gnutls-cli.
+          (when (and (not (gnutls-available-p))
+                     eoc)
+            (network-stream-get-response stream start eoc)
+            (goto-char (point-min))
+            (when (re-search-forward eoc nil t)
+              (goto-char (match-beginning 0))
+              (delete-region (point-min) (line-beginning-position))))
+          (let ((capability-command (plist-get parameters :capability-command))
+                (eo-capa (or (plist-get parameters :end-of-capability)
+                             eoc)))
+            (list stream
+                  (network-stream-get-response stream start eoc)
+                  (network-stream-command stream capability-command eo-capa)
+                  'tls)))))))
 
 (defun network-stream-open-shell (name buffer host service parameters)
   (require 'format-spec)