[evolution-data-server/camel-socks-proxy] Add new exceptions for SOCKS proxies



commit 0003eb884e90d4f200970ee2f4945686098be35e
Author: Federico Mena Quintero <federico novell com>
Date:   Thu Jul 22 15:09:32 2010 -0500

    Add new exceptions for SOCKS proxies
    
    We differentiate between "the proxy does not support our protocol"
    and "the proxy does not support our authentication type".
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 camel/camel-exception-list.def |    6 +++++-
 camel/camel-tcp-stream-raw.c   |   13 +++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/camel/camel-exception-list.def b/camel/camel-exception-list.def
index 9d2940f..300743f 100644
--- a/camel/camel-exception-list.def
+++ b/camel/camel-exception-list.def
@@ -38,4 +38,8 @@ CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
 
 
 /* CamelOperation */
-CAMEL_EXCEPTION_OPERATION_IN_PROGRESS = 400
+CAMEL_EXCEPTION_OPERATION_IN_PROGRESS = 400,
+
+/* SOCKS proxies in CamelTcpStream */
+CAMEL_EXCEPTION_PROXY_NOT_SUPPORTED = 500,
+CAMEL_EXCEPTION_PROXY_CANT_AUTHENTICATE
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index 3a31604..d191efc 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -841,10 +841,15 @@ socks5_initiate_and_request_authentication (CamelTcpStreamRaw *raw, PRFileDesc *
 		return FALSE;
 	}
 
-	if (!(reply[0] == 5		/* server supports SOCKS5 */
-	      && reply[1] == 0)) {	/* and it grants us no authentication (see request[2]) */
-		errno = ECONNREFUSED;
-		d (g_print ("  proxy replied with code %d %d\n", reply[0], reply[1]));
+	if (reply[0] != 5) {		/* server supports SOCKS5 */
+		camel_exception_set (ex, CAMEL_EXCEPTION_PROXY_NOT_SUPPORTED, _("The proxy host does not support SOCKS5"));
+		return FALSE;
+	}
+
+	if (reply[1] != 0) {		/* and it grants us no authentication (see request[2]) */
+		camel_exception_setv (ex, CAMEL_EXCEPTION_PROXY_CANT_AUTHENTICATE,
+				      _("Could not find a suitable authentication type: code 0x%x"),
+				      reply[1]);
 		return FALSE;
 	}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]