;;; socks.el --- A Socks v5 Client for Emacs
;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002,
-;; 2007 Free Software Foundation, Inc.
+;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: William M. Perry <wmperry@gnu.org>
;; Dave Love <fx@gnu.org>
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgroup socks nil
"SOCKS Support"
+ :version "22.2"
:prefix "socks-"
:group 'processes)
)
)
+(declare-function socks-original-open-network-stream "socks") ; fset
+
+(defvar socks-override-functions nil
+ "*Whether to overwrite the open-network-stream function with the SOCKSified
+version.")
+
+(if (fboundp 'socks-original-open-network-stream)
+ nil ; Do nothing, we've been here already
+ (defalias 'socks-original-open-network-stream
+ (symbol-function 'open-network-stream))
+ (if socks-override-functions
+ (defalias 'open-network-stream 'socks-open-network-stream)))
+
(defun socks-open-connection (server-info)
(interactive)
(save-excursion
((= authtype socks-authentication-null)
(and socks-debug (message "No authentication necessary")))
((= authtype socks-authentication-failure)
- (error "No acceptable authentication methods found."))
+ (error "No acceptable authentication methods found"))
(t
(let* ((auth-type (gethash 'authtype info))
(auth-handler (assoc auth-type socks-authentication-methods))
(error "Unsupported address type for HTTP: %d" atype)))
port)))
((equal version 4)
- (setq request (format
- "%c%c%c%c%s%s%c"
- version ; version
- command ; command
- (lsh port -8) ; port, high byte
- (- port (lsh (lsh port -8) 8)) ; port, low byte
- addr ; address
- (user-full-name) ; username
- 0 ; terminate username
- )))
+ (setq request (string-make-unibyte
+ (format
+ "%c%c%c%c%s%s%c"
+ version ; version
+ command ; command
+ (lsh port -8) ; port, high byte
+ (- port (lsh (lsh port -8) 8)) ; port, low byte
+ addr ; address
+ (user-full-name) ; username
+ 0 ; terminate username
+ ))))
((equal version 5)
- (setq request (format
- "%c%c%c%c%s%c%c"
- version ; version
- command ; command
- 0 ; reserved
- atype ; address type
- addr ; address
- (lsh port -8) ; port, high byte
- (- port (lsh (lsh port -8) 8)) ; port, low byte
- )))
+ (setq request (string-make-unibyte
+ (format
+ "%c%c%c%c%s%c%c"
+ version ; version
+ command ; command
+ 0 ; reserved
+ atype ; address type
+ addr ; address
+ (lsh port -8) ; port, high byte
+ (- port (lsh (lsh port -8) 8)) ; port, low byte
+ ))))
(t
(error "Unknown protocol version: %d" version)))
(process-send-string proc request)
(setq noproxy (cdr noproxy)))
route))
-(defvar socks-override-functions nil
- "*Whether to overwrite the open-network-stream function with the SOCKSified
-version.")
-
-(if (fboundp 'socks-original-open-network-stream)
- nil ; Do nothing, we've been here already
- (defalias 'socks-original-open-network-stream
- (symbol-function 'open-network-stream))
- (if socks-override-functions
- (defalias 'open-network-stream 'socks-open-network-stream)))
-
(defvar socks-services-file "/etc/services")
(defvar socks-tcp-services (make-hash-table :size 13 :test 'equal))
(defvar socks-udp-services (make-hash-table :size 13 :test 'equal))