From b7c798a078dedcf48ed930dcfbf8d0000d40a75a Mon Sep 17 00:00:00 2001 From: discomfitor Date: Tue, 6 Dec 2011 04:48:55 +0000 Subject: [PATCH] fix some ssl socks buggies git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@65937 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore_con/ecore_con.c | 21 +++++++++++++++------ src/lib/ecore_con/ecore_con_socks.c | 7 +++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c index 4d22bba..a447db4 100644 --- a/src/lib/ecore_con/ecore_con.c +++ b/src/lib/ecore_con/ecore_con.c @@ -1015,6 +1015,12 @@ ecore_con_event_server_del(Ecore_Con_Server *svr) svr->event_count = eina_list_append(svr->event_count, e); _ecore_con_server_timer_update(svr); e->server = svr; + if (svr->ecs) + { + svr->ecs_state = svr->ecs->lookup ? ECORE_CON_SOCKS_STATE_RESOLVED : ECORE_CON_SOCKS_STATE_DONE; + eina_stringshare_replace(&svr->proxyip, NULL); + svr->proxyport = 0; + } ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e, _ecore_con_event_server_del_free, NULL); _ecore_con_event_count++; @@ -1028,6 +1034,7 @@ ecore_con_event_server_write(Ecore_Con_Server *svr, int num) e = ecore_con_event_server_write_alloc(); EINA_SAFETY_ON_NULL_RETURN(e); + INF("Wrote %d bytes", num); svr->event_count = eina_list_append(svr->event_count, e); e->server = svr; e->size = num; @@ -1704,8 +1711,8 @@ _ecore_con_cb_tcp_connect(void *data, { svr->handshaking = EINA_TRUE; svr->ssl_state = ECORE_CON_SSL_STATE_INIT; - DBG("beginning ssl handshake"); - if (ecore_con_ssl_server_init(svr)) + DBG("%s ssl handshake", svr->ecs_state ? "Queuing" : "Beginning"); + if ((!svr->ecs_state) && ecore_con_ssl_server_init(svr)) goto error; } @@ -2001,7 +2008,7 @@ _ecore_con_cl_read(Ecore_Con_Server *svr) if (svr->connecting && (svr_try_connect_plain(svr) != ECORE_CON_CONNECTED)) return; - if (svr->handshaking) + if (svr->handshaking && (!svr->ecs_state)) { DBG("Continuing ssl handshake"); if (!ecore_con_ssl_server_init(svr)) @@ -2009,8 +2016,9 @@ _ecore_con_cl_read(Ecore_Con_Server *svr) _ecore_con_server_timer_update(svr); } - if (!(svr->type & ECORE_CON_SSL)) + if (svr->ecs_state || !(svr->type & ECORE_CON_SSL)) { + errno = 0; num = read(svr->fd, buf, sizeof(buf)); /* 0 is not a valid return value for a tcp socket */ if ((num > 0) || ((num < 0) && (errno == EAGAIN))) @@ -2308,6 +2316,7 @@ _ecore_con_server_flush(Ecore_Con_Server *svr) size_t buf_len, buf_offset; const void *buf; + DBG("(svr=%p,buf=%p)", svr, svr->buf); #ifdef _WIN32 if (ecore_con_local_win32_server_flush(svr)) return; @@ -2333,7 +2342,7 @@ _ecore_con_server_flush(Ecore_Con_Server *svr) */ if (num <= 0) return; - if (svr->handshaking) + if ((!svr->ecs_state) && svr->handshaking) { DBG("Continuing ssl handshake"); if (ecore_con_ssl_server_init(svr)) @@ -2342,7 +2351,7 @@ _ecore_con_server_flush(Ecore_Con_Server *svr) return; } - if (!(svr->type & ECORE_CON_SSL)) + if (svr->ecs_state || (!(svr->type & ECORE_CON_SSL))) count = write(svr->fd, buf + buf_offset, num); else count = ecore_con_ssl_server_write(svr, buf + buf_offset, num); diff --git a/src/lib/ecore_con/ecore_con_socks.c b/src/lib/ecore_con/ecore_con_socks.c index d89a3e8..f3c241e 100644 --- a/src/lib/ecore_con/ecore_con_socks.c +++ b/src/lib/ecore_con/ecore_con_socks.c @@ -147,10 +147,14 @@ ecore_con_socks_read(Ecore_Con_Server *svr, unsigned char *buf, int num) ecore_con_event_proxy_bind(svr); } svr->ecs_state = ECORE_CON_SOCKS_STATE_DONE; - INF("PROXY STATE++"); + INF("PROXY CONNECTED"); if (svr->ecs_recvbuf) eina_binbuf_free(svr->ecs_recvbuf); svr->ecs_recvbuf = NULL; + svr->ecs_buf_offset = svr->ecs_addrlen = 0; + memset(svr->ecs_addr, 0, sizeof(svr->ecs_addr)); ecore_con_event_server_add(svr); + if (svr->buf && eina_binbuf_length_get(svr->buf)) + ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE); } return; error: @@ -165,7 +169,6 @@ ecore_con_socks_svr_init(Ecore_Con_Server *svr) if (!svr->ip) return EINA_FALSE; if (svr->ecs_buf) return EINA_FALSE; - if (svr->handshaking && svr->ssl_state) return EINA_FALSE; if (svr->ecs_state != ECORE_CON_SOCKS_STATE_INIT) return EINA_FALSE; ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); if (v4) -- 2.7.4